Skip to main content

AI agent for ClickHouse database analysis via MCP

Project description

ClickHouse MCP Agent

version

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clickhouse_mcp_agent-0.5.0b0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clickhouse_mcp_agent-0.5.0b0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

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

Hashes for clickhouse_mcp_agent-0.5.0b0.tar.gz
Algorithm Hash digest
SHA256 1abf059386dffdc1fd7d4a6ba03eaf70f211fca39c5a84feea86372dd7217bf8
MD5 3e74597d84e6cc6904c76e7b109facf7
BLAKE2b-256 feae2ab029ba679020de68a70a95ab0536d7e7aebb6ce78669468e3a053a5a05

See more details on using hashes here.

Provenance

The following attestation bundles were made for clickhouse_mcp_agent-0.5.0b0.tar.gz:

Publisher: publish-pypi.yml on AranNomante/clickhousemcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file clickhouse_mcp_agent-0.5.0b0-py3-none-any.whl.

File metadata

File hashes

Hashes for clickhouse_mcp_agent-0.5.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d4913f6accf9e302a130bc51837eaffc2d704bf1eedd4189845e2ea71429cf2
MD5 52826cc4df1b02695c4eff41bda430eb
BLAKE2b-256 0f26513261ccc7bc728380eceddb6fd8d3e237a72e4d7d561b360e2bce5f7726

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page