Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 8 min read How-to mediumAdept

Agentic analytics in Slack with ClickHouse, MCP, and PydanticAI

A Slack bot built with PydanticAI and the Anthropic API answers natural-language analytics questions by querying ClickHouse through the mcp-clickhouse MCP server. The walkthrough covers Slack app setup in Socket Mode (scopes, events, tokens), launching the MCP server on demand via MCPServerStdio (simpler to manage, at some latency cost), configuring the Agent with a system prompt, and handling DMs and mentions with thread history passed as context. Logs show the LLM listing tools, databases and tables before issuing SQL against the public sql.clickhouse.com playground.

Related posts

  • Agentic BI in Slack: MCP-powered analytics and visualisations

    ClickHouse mediumAdept

    A Slack bot answers analytical questions by having an LLM query ClickHouse through MCP tools, and it now adds charts in about 50 lines of Python. The system prompt asks the model to emit a Vega-Lite JSON spec when a chart is useful, and the bot renders it to PNG with vl-convert and uploads it to the thread alongside a summary and the SQL. The main tradeoffs are that plotted data passes through the LLM's context window, so thousands of points aren't practical, and that charts aren't interactive or brand-styled and every request re-runs the query. Dashboards stay for curated KPIs, while chat handles exploratory questions.

  • Integrating with ClickHouse MCP

    ClickHouse mediumAdept

    The open-source mcp-clickhouse server can be wired into five Python agent frameworks: Agno, DSPy, LangChain, LlamaIndex and PydanticAI. Each example uses uv to launch the server over stdio, points it at the public ClickHouse SQL Playground, and uses Anthropic Claude models. The frameworks differ mainly in ceremony. PydanticAI and Agno take the server directly, while DSPy needs a Signature class and manual conversion of MCP tools. LlamaIndex's default max_function_calls of 5 was too low to answer questions and had to be raised to 10. ClickHouse also plans a remote MCP server built into ClickHouse Cloud.

  • Building an agentic app with ClickHouse MCP and CopilotKit

    ClickHouse mediumAdept

    A natural-language analytics dashboard for UK property prices can be built by combining an LLM (Claude Sonnet 3.7), the ClickHouse MCP Server and CopilotKit in a Next.js app. The LLM turns a prompt into SQL, CopilotKit's MCP client runs it against ClickHouse over SSE, and the model then calls a `generateChart` action defined with `useCopilotAction` to render the result via ECharts. The walkthrough covers swapping in the Anthropic adapter, running the MCP server with fastmcp, and sharing chart state with `useCopilotReadable`. It recommends a read-only ClickHouse user with restricted databases, quotas and a limited settings profile so the model cannot reach data or run queries beyond what is intended.

  • Agent-Facing Analytics

    ClickHouse easyNovice

    AI agents are emerging as a new user persona for real-time analytics databases, generating high volumes of concurrent, iterative exploratory SQL queries on behalf of users. Real-time OLAP systems suit these workloads because of fresh data, fast aggregations, high concurrency and consolidated domain data, but could adapt further through templated query endpoints, LLM-oriented SQL extensions for data discovery, LLMs.txt documentation, server-side agent memory and caching, and short-lived task-scoped access tokens. The ClickHouse MCP server demonstrates the idea today, exposing tools to list databases, list tables and run SELECT queries for models like Claude.

  • Agentic coding with ClickHouse. One person, one data stack, one full-stack application

    ClickHouse easyNovice

    A ClickHouse Solutions Architect with no frontend or backend background built ClickShop, a full-stack retail analytics demo, in a couple of days using Cursor. The stack uses Next.js on Vercel with per-persona workspaces, PostgreSQL for transactions synced to ClickHouse via ClickPipes CDC, and a Bronze/Silver/Gold medallion layout built on materialized views. On top sit 18 LibreChat agents, plus two observability layers: Langfuse for LLM tracing and cost, and ClickStack over OpenTelemetry for infrastructure. Open source components, Cursor skills and MCP database connectors reduce AI guesswork, though iteration, review and token costs remain significant.

The quest for software engineering knowledge.

Look:
Layout: