AI agent for ClickHouse database analysis via MCP
Project description
ClickHouse MCP Agent
AI agent for ClickHouse database analysis via MCP (Model Context Protocol).
Features
- Query ClickHouse databases using AI models
- Structured output: analysis, SQL used, confidence
- Easy connection management (predefined or custom)
- Conversational context and message history with robust summarization/pruning
- No CLI or environment setup required
Supported Providers
- OpenAI
- Anthropic
- Google Gemini
- Groq
- Mistral
- Cohere
Usage
- Configure your model, API key, and connection using the runtime config API.
- Run queries using the
ClickHouseAgent. - Multi-model/provider support is automatic—just set the API key for each provider.
See the examples/ directory for full, canonical usage scripts
Output
Each call to ClickHouseAgent.run() returns a RunResult object with the following fields:
messages: The full (pruned) message history after the run (for conversational context).new_messages: Only the new messages generated in the latest turn.last_message: The last message in the conversation (usually the latest assistant response).usage: Token and usage statistics for the run.analysis: Natural language results with SQL queries (from the model output).sql_used: The SQL query that was executed.confidence: Confidence level (1-10) for the analysis.
This structure allows you to maintain conversational context, track usage, and access both the structured and conversational outputs of each query.
Requirements
- Python 3.10+
- AI API key for your chosen provider (OpenAI, Anthropic, Google/Gemini, Groq, Mistral, Cohere)
All dependencies are handled by pyproject.toml.
Roadmap
✅ Completed Features
- MCP Integration: PydanticAI + ClickHouse MCP server integration
- Query Execution: SQL query generation and execution via MCP
- Schema Inspection: Database, table, and column exploration
- Connection Management: Multiple connection configurations (playground, custom)
- RBAC Support: Per-query user credentials via config
- Dynamic Connections: Runtime connection configuration, no environment dependencies
- Direct API Key Passing: Pass AI API keys directly to agent (model_api_key)
- Structured Output: ClickHouseOutput with analysis, SQL, and confidence
- Type Safety: Full type annotations and mypy compliance
- Code Quality: Black formatting, isort, flake8 linting
- Multi-Model Support: Runtime selection of provider/model and API key management
- Message History: Robust message_history parameter for conversational context with summarization and pruning
- Conversational Agent: Persistent memory and context across queries
🚧 Planned / In Progress
- Improved Error Handling: More robust error and exception management
- Advanced Output Formatting: Customizable output for downstream applications
Contributing
Open an issue or pull request for features or fixes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clickhouse_mcp_agent-0.5.0b0.tar.gz.
File metadata
- Download URL: clickhouse_mcp_agent-0.5.0b0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1abf059386dffdc1fd7d4a6ba03eaf70f211fca39c5a84feea86372dd7217bf8
|
|
| MD5 |
3e74597d84e6cc6904c76e7b109facf7
|
|
| BLAKE2b-256 |
feae2ab029ba679020de68a70a95ab0536d7e7aebb6ce78669468e3a053a5a05
|
Provenance
The following attestation bundles were made for clickhouse_mcp_agent-0.5.0b0.tar.gz:
Publisher:
publish-pypi.yml on AranNomante/clickhousemcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clickhouse_mcp_agent-0.5.0b0.tar.gz -
Subject digest:
1abf059386dffdc1fd7d4a6ba03eaf70f211fca39c5a84feea86372dd7217bf8 - Sigstore transparency entry: 389574032
- Sigstore integration time:
-
Permalink:
AranNomante/clickhousemcp@2311906d2c88eb25e10d82abc05708b325c5a5c3 -
Branch / Tag:
refs/tags/v0.5.0b0 - Owner: https://github.com/AranNomante
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@2311906d2c88eb25e10d82abc05708b325c5a5c3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file clickhouse_mcp_agent-0.5.0b0-py3-none-any.whl.
File metadata
- Download URL: clickhouse_mcp_agent-0.5.0b0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d4913f6accf9e302a130bc51837eaffc2d704bf1eedd4189845e2ea71429cf2
|
|
| MD5 |
52826cc4df1b02695c4eff41bda430eb
|
|
| BLAKE2b-256 |
0f26513261ccc7bc728380eceddb6fd8d3e237a72e4d7d561b360e2bce5f7726
|
Provenance
The following attestation bundles were made for clickhouse_mcp_agent-0.5.0b0-py3-none-any.whl:
Publisher:
publish-pypi.yml on AranNomante/clickhousemcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clickhouse_mcp_agent-0.5.0b0-py3-none-any.whl -
Subject digest:
0d4913f6accf9e302a130bc51837eaffc2d704bf1eedd4189845e2ea71429cf2 - Sigstore transparency entry: 389574073
- Sigstore integration time:
-
Permalink:
AranNomante/clickhousemcp@2311906d2c88eb25e10d82abc05708b325c5a5c3 -
Branch / Tag:
refs/tags/v0.5.0b0 - Owner: https://github.com/AranNomante
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@2311906d2c88eb25e10d82abc05708b325c5a5c3 -
Trigger Event:
release
-
Statement type: