How to build an AI agent with Chainlit and the ClickHouse MCP Server
This guide explores how to combine Chainlit's powerful chat interface framework with the ClickHouse Model Context Protocol (MCP) Server to create interactive data applications. Chainlit enables you to build conversational interfaces for AI applications with minimal code, while the ClickHouse MCP Server provides seamless integration with ClickHouse's high-performance columnar database.
Prerequisites
- You'll need an Anthropic API key
- You'll need to have
uv
installed
Basic Chainlit app
You can see an example of a basic chat app by running the following:
Then navigate to http://localhost:8000
Adding ClickHouse MCP Server
Things get more interesting if we add the ClickHouse MCP Server.
You'll need to update your .chainlit/config.toml
file to allow the uv
command
to be used:
Find the full config.toml
file in the examples repository
There's some glue code to get MCP Servers working with Chainlit, so we'll need to run this command to launch Chainlit instead:
To add the MCP Server, click on the plug icon in the chat interface, and then add the following command to connect to use the ClickHouse SQL Playground:
If you want to use your own ClickHouse instance, you can adjust the values of the environment variables.
You can then ask it questions like this:
- Tell me about the tables that you have to query
- What's something interesting about New York taxis?