---
title: "Agentic analytics in Slack with ClickHouse, MCP, and PydanticAI"
description: "A Slack bot built with PydanticAI and the Anthropic API answers natural-language analytics questions by querying ClickHouse through the mcp-clickhouse MCP server."
url: "https://swe.quest/articles/agentic-analytics-in-slack-with-clickhouse-mcp-and-pydanticai-d12acfde3a87c76f"
canonical: "https://clickhouse.com/blog/agentic-analytics-slack-clickhouse-mcp"
source: "ClickHouse"
published: "2025-07-23"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["ai-agents","analytics","python","llms"]
---

# Agentic analytics in Slack with ClickHouse, MCP, and PydanticAI

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-07-23, 8 min read, How-to. Original: [https://clickhouse.com/blog/agentic-analytics-slack-clickhouse-mcp](https://clickhouse.com/blog/agentic-analytics-slack-clickhouse-mcp)

## Summary

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.

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)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- Python async basics ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- Slack app configuration ([easy posts on Configuration management](https://swe.quest/tags/configuration.md?difficulty=easy))
- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

ClickHouse, MCP, PydanticAI, Slack, Anthropic Claude, mcp-clickhouse, Slack Bolt

## Related posts

- [Agentic BI in Slack: MCP-powered analytics and visualisations](https://swe.quest/articles/agentic-bi-in-slack-mcp-powered-analytics-and-visualisations-7d7452bde1510bc3.md): ClickHouse · 2025-08-27 · Medium · 7 min read · AI agents, Analytics & OLAP, LLMs, Python
  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.
- [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.
- [Building an agentic app with ClickHouse MCP and CopilotKit](https://swe.quest/articles/building-an-agentic-app-with-clickhouse-mcp-and-copilotkit-8a892e5035cf8b12.md): ClickHouse · 2025-06-12 · Medium · 9 min read · AI agents, Analytics & OLAP, React, LLMs
  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.
- [Agent-Facing Analytics](https://swe.quest/articles/agent-facing-analytics-abbe75281484a032.md): ClickHouse · 2025-02-13 · Easy · 13 min read · AI agents, Analytics & OLAP, Databases, LLMs
  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.
- [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.

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)
