Interact with ClickHouse databases through the Model Context Protocol
Altinity MCP Server
A Model Context Protocol (MCP) server that provides tools for interacting with ClickHouse® databases. This server enables AI assistants and other MCP clients to query, analyze, and interact with ClickHouse® databases through a standardized protocol.
Features
- Multiple Transport Options: Support for STDIO, HTTP, and Server-Sent Events (SSE) transports
- OAuth 2.0 Authorization: Forward Bearer tokens to ClickHouse for token-based authentication via OIDC providers (see OAuth 2.0 Documentation)
- JWE Authentication: Optional JWE-based authentication with encryption for secure database access
- TLS Support: Full TLS encryption support for both ClickHouse® connections and MCP server endpoints
- Comprehensive Tools: Built-in tools for listing tables, describing schemas, and executing queries
- Dynamic Tools: Automatically generate MCP tools from ClickHouse® views (see Dynamic Tools Documentation)
- Resource Templates: Dynamic resource discovery for database schemas and table information
- Query Prompts: AI-assisted query building and optimization prompts
- Configuration Management: Flexible configuration via files, environment variables, or CLI flags
- Hot Reload: Dynamic configuration reloading without server restart
Quick Start
Using STDIO Transport (Default)
# Basic usage with default settings
./altinity-mcp --clickhouse-host localhost --clickhouse-port 8123
# With custom database and credentials
./altinity-mcp \
--clickhouse-host clickhouse.example.com \
--clickhouse-port 9000 \
--clickhouse-protocol tcp \
--clickhouse-database analytics \
--clickhouse-username reader \
--clickhouse-password secret123 \
--clickhouse-limit 5000
Using HTTP Transport with OpenAPI
./altinity-mcp \
--transport http \
--address 0.0.0.0 \
--port 8080 \
--clickhouse-host localhost \
--openapi http
Using SSE Transport with JWE Authentication and OpenAPI
./altinity-mcp \
--transport sse \
--port 8080 \
--allow-jwe-auth \
--jwe-secret-key "your-jwe-encryption-secret" \
--jwt-secret-key "your-jwt-signing-secret" \
--clickhouse-host localhost \
--openapi http
Integration Guide
For detailed instructions on integrating Altinity MCP with various AI tools and platforms, see our Integration Guide.
Installation & Deployment
Using Docker
docker run -it --rm ghcr.io/altinity/altinity-mcp:latest --clickhouse-host clickhouse
Kubernetes with Helm
From OCI helm registry (recommended)
# Install from OCI registry
helm install altinity-mcp oci://ghcr.io/altinity/altinity-mcp/helm/altinity-mcp \
--set config.clickhouse.host=clickhouse.example.com \
--set config.clickhouse.database=default \
--set config.clickhouse.limit=5000
From local helm chart
git clone https://github.com/Altinity/altinity-mcp
cd altinity-mcp
helm install altinity-mcp ./helm/altinity-mcp \
--set config.clickhouse.host=clickhouse-service \
--set config.clickhouse.database=analytics \
--set config.server.transport=http \
--set config.server.port=8080
For detailed Helm chart configuration options, see Helm Chart README.
Docker Compose
version: '3.8'
services:
altinity-mcp:
build: .
ports:
- "8080:8080"
environment:
- CLICKHOUSE_HOST=clickhouse
- MCP_TRANSPORT=http
- MCP_PORT=8080
depends_on:
- clickhouse
entrypoint: ["/bin/sh", "-c", "/bin/altinity-mcp"]
clickhouse:
image: clickhouse/clickhouse-server:latest
ports:
- "8123:8123"
From Source
git clone https://github.com/altinity/altinity-mcp.git
cd altinity-mcp
go build -o altinity-mcp ./cmd/altinity-mcp
Configuration
Configuration File
Create a YAML or JSON configuration file:
# config.yaml
clickhouse:
host: "localhost"
port: 8123
database: "default"
username: "default"
password: ""
protocol: "http"
read_only: false
max_execution_time: 600
tls:
enabled: fa
Tools (3)
list_tablesList all tables available in the ClickHouse databasedescribe_schemaRetrieve the schema definition for a specific tableexecute_queryExecute a SQL query against the ClickHouse databaseEnvironment Variables
CLICKHOUSE_HOSTThe hostname of the ClickHouse serverMCP_TRANSPORTTransport protocol to use (stdio, http, sse)MCP_PORTPort for HTTP or SSE transportConfiguration
{"mcpServers": {"altinity-mcp": {"command": "./altinity-mcp", "args": ["--clickhouse-host", "localhost", "--clickhouse-port", "8123"]}}}