Skip to main content
Glama
jvanvalkenhoef

clickhouse-mcp

clickhouse-mcp

A read-only Model Context Protocol server for ClickHouse. It gives an AI agent a small set of tools to explore a ClickHouse instance and investigate observability data (logs, metrics, traces) without being able to write or mutate anything.

Built as a reference for wiring agents onto a petabyte-scale analytics platform: the agent discovers the schema, samples data, and runs guarded read-only SQL to answer questions like "why did p99 latency spike at 02:14?".

Tools

Tool

What it does

list_databases

SHOW DATABASES

list_tables

SHOW TABLES FROM <db>

describe_table

DESCRIBE TABLE <db>.<table>

show_create_table

SHOW CREATE TABLE (schema + engine + settings)

sample_rows

SELECT * FROM <db>.<table> LIMIT n (peek at the shape)

query

Arbitrary read-only SQL (SELECT/WITH/SHOW/DESCRIBE/EXPLAIN)

Related MCP server: db-connect-mcp

Safety

  • Verb guard: only SELECT / WITH / SHOW / DESCRIBE / EXPLAIN / EXISTS are allowed; write/DDL verbs (INSERT, CREATE, DROP, ALTER, TRUNCATE, …) are rejected.

  • Limits: every query sets max_result_rows and max_execution_time, and the rows returned to the model are capped (with a truncation note) to protect its context window.

  • Defence in depth: still point this at a read-only ClickHouse user. The app-level guard is a first line, not the only one.

Prerequisites

  • Node.js 20+

  • Any ClickHouse instance. Easiest is local docker (no setup, includes system.* observability tables to play with):

    docker run -d --name ch -p 8123:8123 -p 9000:9000 clickhouse/clickhouse-server

Install

git clone <your-fork-url> clickhouse-mcp && cd clickhouse-mcp
npm install
cp .env.example .env        # then edit if your ClickHouse needs auth

Verify it talks to ClickHouse

npm run self-test
# Connecting to http://localhost:8123
# databases: [ 'default', 'system', 'INFORMATION_SCHEMA', ... ]
# version: [ { v: '25.x.x.x' } ]
# OK

Run as an MCP server (stdio)

npm start

Use it from a client

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "clickhouse": {
      "command": "npx",
      "args": ["tsx", "/absolute/path/to/clickhouse-mcp/src/index.ts"],
      "env": {
        "CLICKHOUSE_URL": "http://localhost:8123",
        "CLICKHOUSE_USERNAME": "default",
        "CLICKHOUSE_PASSWORD": ""
      }
    }
  }
}

Claude Code:

claude mcp add clickhouse -e CLICKHOUSE_URL=http://localhost:8123 -- npx tsx /absolute/path/to/clickhouse-mcp/src/index.ts

MCP Inspector (great for debugging the tools directly):

npx @modelcontextprotocol/inspector npx tsx src/index.ts

Then ask an agent: "What tables are in the system database? Show recent slow queries from system.query_log grouped by minute."

License

MIT

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    quality
    A
    maintenance
    Production-ready MCP server designed to empower AI agents and LLMs to interact seamlessly with ClickHouse. It exposes your ClickHouse database as a set of standardized tools and resources that adhere to the MCP protocol, making it easy for agents built on OpenAI, Claude, or other platforms to query, explore, and analyse your data.
    Last updated
    37
  • A
    license
    A
    quality
    A
    maintenance
    A read-only MCP server for exploratory data analysis across PostgreSQL, MySQL, and ClickHouse databases, providing safe, read-only access with comprehensive analysis capabilities.
    Last updated
    10
    6
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jvanvalkenhoef/mcp_server_clickhouse'

If you have feedback or need assistance with the MCP directory API, please join our Discord server