MCP ClickHouse Server

0.3.0 · active · verified Fri Apr 17

An MCP server for ClickHouse. This library provides a FastAPI-based application that allows configuration of a ClickHouse database via MCP (Mediation Control Plane) and fetches data using a REST API. It is currently at version 0.3.0 and typically follows an iterative release cadence with feature additions and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically run the MCP ClickHouse server using uvicorn. Note that `MCP_CLICKHOUSE_DB_URL` must be set for the server to function correctly. After running, you can access the API at `http://localhost:8000` (e.g., `http://localhost:8000/health`). For typical use, the CLI command `mcp-clickhouse start` is also available after installation.

import uvicorn
import os
from mcp_clickhouse.server.main import app

# Set required environment variables for ClickHouse connection
# In a real scenario, you would provide actual credentials or use a .env file.
os.environ['MCP_CLICKHOUSE_DB_URL'] = os.environ.get('MCP_CLICKHOUSE_DB_URL', 'clickhouse://user:password@localhost:8123/default')

if __name__ == "__main__":
    print(f"Starting MCP ClickHouse server on http://0.0.0.0:8000")
    print(f"Using ClickHouse DB URL: {os.environ['MCP_CLICKHOUSE_DB_URL']}")
    uvicorn.run(app, host="0.0.0.0", port=8000)

view raw JSON →