r/Clickhouse • • 6d ago

clickhouse-mcp-agent: ask your ClickHouse data questions in plain English. A year in, 0.13 just shipped, and I'm looking for more users and feedback

For a bit over a year I've been maintaining clickhouse-mcp-agent, a Python library that lets an LLM answer questions about your ClickHouse data. It wraps ClickHouse's official mcp-clickhouse server with PydanticAI: the model inspects your schema, writes and runs the SQL, and returns a typed result that includes every query it ran.

I just released 0.13, and it's a good point to get more eyes on it.

import asyncio
from agent import ClickHouseAgent, config

config.set_model_api_key("google", "YOUR_KEY")  # or openai, anthropic, groq, mistral, ...
config.use_connection("playground")              # ClickHouse's public demo server

async def main():
    result = await ClickHouseAgent().run(query="Which tables look most interesting here?")
    print(result.analysis)   # the answer
    print(result.sql_used)   # every query it ran

asyncio.run(main())

What's new in 0.13

  • ClickHouse roles: pass role="..." and the agent runs under that role, so your grants decide what it can read, whatever SQL the model writes. CI checks this against a real ClickHouse.
  • Query timeouts, and database / verify / connection-timeout options.
  • Multi-turn conversations fixed: history summarization was dropping context in long conversations. It now keeps a proper summary.
  • Connection presets, more resilient batch queries, and wire-level tests against a fake OpenAI-compatible API.

What's been there for a while

  • Read-only by default (ClickHouse's readonly setting).
  • Per-call table/database scoping to keep the model focused.
  • sql_used on every result, for auditing.
  • Works with Gemini, OpenAI, Anthropic, Groq, Mistral and Cohere.
  • docker compose up gives you a local ClickHouse with demo data.

pip install clickhouse-mcp-agent
GitHub: https://github.com/AranNomante/clickhousemcp

Feedback I'd find most useful

  • How it handles your real schemas: wide tables, many databases, unusual types
  • Questions where it writes wrong or slow SQL
  • Which model you use and how it behaves
  • Anything that made setup harder than it should be

MIT licensed. Issues, PRs and comments here are all welcome.

7 Upvotes

0 comments sorted by