# ClickHouse (MCP Server)

> Query ClickHouse clusters and chDB from AI assistants

- Type: MCP server
- Publisher: ClickHouse (official)
- Categories: Data & Analytics
- Website: https://github.com/ClickHouse/mcp-clickhouse
- Source: https://github.com/ClickHouse/mcp-clickhouse
- Transport: stdio
- Launch command: uv run --with mcp-clickhouse --python 3.12 mcp-clickhouse
- Sign-in: api-key
- Environment variables: CLICKHOUSE_HOST, CLICKHOUSE_PORT, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, CLICKHOUSE_SECURE
- GitHub stars: 879
- Listed: 2024-12-25

## About

Official ClickHouse MCP server for running SQL queries and listing databases and tables on a ClickHouse cluster, read-only by default. Optionally exposes chDB for querying local files and URLs with the embedded ClickHouse engine.

## Install

1. **Add the server to Codex**

   Codex CLI:

   ```bash
   codex mcp add clickhouse --env CLICKHOUSE_HOST=YOUR_CLICKHOUSE_HOST --env CLICKHOUSE_PORT=YOUR_CLICKHOUSE_PORT --env CLICKHOUSE_USER=YOUR_CLICKHOUSE_USER --env CLICKHOUSE_PASSWORD=YOUR_CLICKHOUSE_PASSWORD --env CLICKHOUSE_SECURE=YOUR_CLICKHOUSE_SECURE -- uv run --with mcp-clickhouse --python 3.12 mcp-clickhouse
   ```

   config.toml:

   ```toml
   [mcp_servers.clickhouse]
   command = "uv"
   args = ["run", "--with", "mcp-clickhouse", "--python", "3.12", "mcp-clickhouse"]
   
   [mcp_servers.clickhouse.env]
   CLICKHOUSE_HOST = "YOUR_CLICKHOUSE_HOST"
   CLICKHOUSE_PORT = "YOUR_CLICKHOUSE_PORT"
   CLICKHOUSE_USER = "YOUR_CLICKHOUSE_USER"
   CLICKHOUSE_PASSWORD = "YOUR_CLICKHOUSE_PASSWORD"
   CLICKHOUSE_SECURE = "YOUR_CLICKHOUSE_SECURE"
   ```

   Agents SDK:

   ```python
   from agents import Agent, Runner
   from agents.mcp import MCPServerStdio
   
   async with MCPServerStdio(
       name="ClickHouse",
       params={"command": "uv", "args": ["run", "--with", "mcp-clickhouse", "--python", "3.12", "mcp-clickhouse"]},
   ) as server:
       agent = Agent(name="Assistant", mcp_servers=[server])
       result = await Runner.run(agent, "List the databases on my ClickHouse cluster")
       print(result.final_output)
   ```

## Tools

- `run_query`
- `list_databases`
- `list_tables`
- `run_chdb_select_query`

## Example prompts

- "List the databases on my ClickHouse cluster"
- "What are the top 10 events by count yesterday?"
- "Describe the tables in the analytics database"

## Also available as

- app: [ClickHouse](https://chatgptplugins.directory/apps/clickhouse.md)

## Related

- [Supabase](https://chatgptplugins.directory/mcp/supabase.md): Manage Supabase databases, migrations, edge functions and logs
- [Graphiti MCP](https://chatgptplugins.directory/mcp/graphiti.md): Temporal knowledge graph memory for agents, by Zep
- [MCP Toolbox for Databases](https://chatgptplugins.directory/mcp/mcp-toolbox-databases.md): Google's open-source MCP server for 20+ databases
- [PostHog](https://chatgptplugins.directory/mcp/posthog.md): Query product analytics, feature flags, experiments and errors in PostHog
- [Apify](https://chatgptplugins.directory/mcp/apify.md): Run thousands of Apify Actors for scraping and automation from your agent
- [Firecrawl](https://chatgptplugins.directory/mcp/firecrawl.md): Scrape, search, crawl and interact with live web pages for LLMs

---
Source: https://chatgptplugins.directory/mcp/clickhouse · Index: https://chatgptplugins.directory/llms.txt · Independent and community-run. Not affiliated with or endorsed by OpenAI. ChatGPT is a trademark of OpenAI.
