---
title: "Building an agentic app with ClickHouse MCP and CopilotKit"
description: "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."
url: "https://swe.quest/articles/building-an-agentic-app-with-clickhouse-mcp-and-copilotkit-8a892e5035cf8b12"
canonical: "https://clickhouse.com/blog/building-an-agentic-application-with-clickhouse-mcp-server-and-copilotkit"
source: "ClickHouse"
published: "2025-06-12"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["ai-agents","analytics","react","llms"]
---

# Building an agentic app with ClickHouse MCP and CopilotKit

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-06-12, 9 min read, How-to. Original: [https://clickhouse.com/blog/building-an-agentic-application-with-clickhouse-mcp-server-and-copilotkit](https://clickhouse.com/blog/building-an-agentic-application-with-clickhouse-mcp-server-and-copilotkit)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [React](https://swe.quest/tags/react.md) (Web & mobile)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- React and Next.js ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- LLM tool calling ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

ClickHouse, Model Context Protocol, CopilotKit, Claude Sonnet 3.7, fastmcp, Next.js, ECharts

## Related posts

- [Agentic coding with ClickHouse. One person, one data stack, one full-stack application](https://swe.quest/articles/agentic-coding-with-clickhouse-one-person-one-data-stack-one-full-stack-ca4c2d9fd47cef68.md): ClickHouse · 2026-04-14 · Easy · 13 min read · AI for coding, Analytics & OLAP, Observability, AI agents
  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.
- [Agentic analytics in Slack with ClickHouse, MCP, and PydanticAI](https://swe.quest/articles/agentic-analytics-in-slack-with-clickhouse-mcp-and-pydanticai-d12acfde3a87c76f.md): ClickHouse · 2025-07-23 · Medium · 8 min read · AI agents, Analytics & OLAP, Python, LLMs
  A Slack bot built with PydanticAI and the Anthropic API answers natural-language analytics questions by querying ClickHouse through the mcp-clickhouse MCP server.
- [AI Functions in ClickHouse: Upgrade your SQL to the AI age](https://swe.quest/articles/ai-functions-in-clickhouse-upgrade-your-sql-to-the-ai-age-11cec6552950f306.md): ClickHouse · 2026-09-11 · Medium · 12 min read · LLMs, SQL, RAG & retrieval, Analytics & OLAP, Cost optimization
  ClickHouse's beta AI Functions call LLM and embedding providers directly from SQL.
- [Building a RAG pipeline for Google Analytics with ClickHouse and Amazon Bedrock](https://swe.quest/articles/building-a-rag-pipeline-for-google-analytics-with-clickhouse-and-amazon-bedrock-e2945701d51424da.md): ClickHouse · 2023-11-21 · Medium · 26 min read · RAG & retrieval, LLMs, Vector search, Analytics & OLAP, Cloud platforms
  A natural language interface over raw Google Analytics data stored in ClickHouse is built as a multi-step RAG pipeline that generates SQL from user questions using Amazon Bedrock models.
- [Integrating with ClickHouse MCP](https://swe.quest/articles/integrating-with-clickhouse-mcp-1c5887029a6fb2f3.md): ClickHouse · 2025-06-05 · Medium · 7 min read · AI agents, LLMs, Python, Analytics & OLAP
  The open-source mcp-clickhouse server can be wired into five Python agent frameworks: Agno, DSPy, LangChain, LlamaIndex and PydanticAI.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
