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.0b1.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.0b1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file clickhouse_mcp_agent-0.5.0b1.tar.gz.

File metadata

  • Download URL: clickhouse_mcp_agent-0.5.0b1.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.0b1.tar.gz
Algorithm Hash digest
SHA256 782752d3c82f7a20d55e54026b0cfcb7337349e5c99b35ac9bce504da12ea338
MD5 070d2c5c1b7eb0ee0b65fd5fa61043a6
BLAKE2b-256 bbe0375fcf07d8763db75dabcf4814f1f41cc2b3782afa6ec4bea1072278f98b

See more details on using hashes here.

Provenance

The following attestation bundles were made for clickhouse_mcp_agent-0.5.0b1.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.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for clickhouse_mcp_agent-0.5.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 853add5a12b8b13d3d0d88cca77c5f6c861fe7bbb5ad48f8e81db59aeea8248a
MD5 15ca330b290ba62e4790976487ba88c0
BLAKE2b-256 c20895e9c7b9c56813d6f7b83fe58b23d84305a43b13ab8647817d9d43004c51

See more details on using hashes here.

Provenance

The following attestation bundles were made for clickhouse_mcp_agent-0.5.0b1-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