Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
How to build a SlackBot agent using ClickHouse MCP server
In this guide, you’ll learn how to build a SlackBot agent. This bot allows you to ask questions about your ClickHouse data directly from Slack, using natural language. It uses the ClickHouse MCP server and PydanticAI.Example projectThe code for this example can be found in the examples repository.
Prerequisites
- You’ll need to have
uvinstalled - You’ll need access to a Slack workspace
- You’ll need an Anthropic API key, or API key from another LLM provider
Create a Slack App
- Go to slack.com/apps and click
Create New App. - Choose option
From scratchand give your app a name. - Select your Slack workspace.
Install the app to your workspace
Next, you’ll need to add the app created in the previous step to your workspace. You can follow the instructions for “Add apps to your Slack workspace” in the Slack documentation.Configure Slack app settings
- Go to
App Home- Under
Show Tabs→Messages Tab: EnableAllow users to send Slash commands and messages from the messages tab - Go to
Socket Mode- Enable
Socket Mode - Note down the
Socket Mode Handlerfor the environment variableSLACK_APP_TOKEN
- Enable
- Go to
OAuth & Permissions- Add the following
Bot Token Scopes:app_mentions:readassistant:writechat:writeim:historyim:readim:writechannels:history
- Install the app to your workspace and note down the
Bot User OAuth Tokenfor the environment variableSLACK_BOT_TOKEN.
- Add the following
- Go to
Event Subscriptions- Enable
Events - Under
Subscribe to bot events, add:app_mentionassistant_thread_startedmessage:im
- Save Changes
- Enable
- Under
Add environment variables (.env)
Create a .env file in the project root with the following environment variables
which will allow your app to connect to ClickHouse’s SQL playground.Using the bot
-
Start the bot:
-
In Slack:
- Mention the bot in a channel:
@yourbot Who are the top contributors to the ClickHouse git repo? - Reply to the thread with a mention:
@yourbot how many contributions did these users make last week? - DM the bot:
Show me all tables in the demo database.
- Mention the bot in a channel: