clickhouse-mcp
Queries a USA-market ClickHouse warehouse with 1.49 billion rows of 1-minute bars across 1,388 symbols for large-scale, cross-sectional quant analysis.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@clickhouse-mcp screen stocks with RSI below 30 today"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
clickhouse-mcp
A read-only Model Context Protocol (MCP) server that queries a USA-market ClickHouse warehouse — 1.49 billion rows of 1-minute bars across 1,388 symbols (1991–2026) plus L1 aggregates and L2 materialised technical indicators — and exposes it to MCP-aware agents for large-scale, cross-sectional quant analysis that single-symbol REST MCP servers cannot do.
It is the 6th read-only server in the kevinkda MCP ecosystem (schwab-marketdata / schwab-positions / sec-edgar / polygon-news / yfinance), and deliberately stays independent because its authentication (ClickHouse host/user/password) and data shape (columnar deep history) differ from the REST-based siblings.
Tools (7, all read-only)
Tool | Purpose |
| OHLCV bars for one symbol over a date range at 1m/5m/15m/1h/1d/1w |
| One materialised / runtime indicator series (ma20, rsi14, macd_hist, …) |
| Full-market technical-indicator scan (e.g. "today's RSI<30 oversold list") |
| Pairwise return-correlation matrix for 2–50 symbols (Pearson / Spearman) |
| Disabled by default raw-SQL escape hatch (single read-only SELECT only) |
| Local probe + optional ClickHouse reachability check |
| Version + tool list (offline) |
Related MCP server: clickhouse-mcp-server
Quickstart
git clone https://github.com/kevinkda/clickhouse-mcp
cd clickhouse-mcp
uv sync --extra dev
cp .env.example .env # then fill in your read-only ClickHouse connectionConfigure the connection in .env (see Security):
CLICKHOUSE_MCP_HOST=your-clickhouse-host
CLICKHOUSE_MCP_HTTP_PORT=8123
CLICKHOUSE_MCP_USER=mcp_readonly
CLICKHOUSE_MCP_PASSWORD=...
CLICKHOUSE_MCP_DATABASE=usaRun it:
uv run clickhouse-mcpRegister with an MCP client
{
"mcpServers": {
"clickhouse": {
"command": "uv",
"args": ["run", "clickhouse-mcp"],
"cwd": "/absolute/path/to/clickhouse-mcp",
"env": {
"CLICKHOUSE_MCP_HOST": "your-clickhouse-host",
"CLICKHOUSE_MCP_HTTP_PORT": "8123",
"CLICKHOUSE_MCP_USER": "mcp_readonly",
"CLICKHOUSE_MCP_PASSWORD": "...",
"CLICKHOUSE_MCP_DATABASE": "usa"
}
}
}
}Security
This server touches financial data, so it is hardened accordingly. See
docs/SECURITY.md and
docs/THREAT_MODEL.md.
Dedicated read-only ClickHouse account — point
CLICKHOUSE_MCP_USERat an account created withreadonly = 1andGRANT SELECTonly, never an admin user. Defence in depth: every query is also issued with the ClickHouse session settingreadonly=1plusmax_execution_time/max_result_rowsguardrails.Parameterised, never concatenated —
get_ohlcv/get_indicators/screen_stocks/get_correlation_matrixvalidate every symbol / indicator / date through anchored regexes + allow-lists and bind them as ClickHouse query parameters. User input never lands in the SQL string.run_safe_sqldisabled by default — gated behindCLICKHOUSE_MCP_ALLOW_RAW_SQL=true; even when enabled it enforces SELECT-only single statements, rejects DDL/DML + comments, forces aLIMIT, and inheritsreadonly=1+ the resource guardrails.SSRF-safe — the ClickHouse host is read from env at startup and is never derived from tool input; no argument can redirect the outbound connection.
Credentials redacted — every exception runs its text through
redact_secrets, so a password / DSN can never leak viarepr(exc)or logs.
Quant use cases unlocked
CH is the "full-market + deep-history + batch" engine; the REST MCP siblings are "real-time + fundamentals + news". Together they close the loop:
Full-market technical scan — RSI/MACD/Bollinger/MA signals across all 1,388 symbols (single-symbol MCP cannot scan the market).
Cross-sectional factor ranking — value/momentum/quality scoring across the universe on a columnar store.
Multi-symbol correlation matrix — portfolio / pairs prerequisite; CH batch read beats fetching symbols one at a time.
Cross-source quant playbook — CH historical signal → schwab real-time price → sec-edgar fundamentals → polygon news.
Development
bash scripts/local-ci.sh # ruff + mypy + bandit + pip-audit + pytest (100% cov)Tests never touch a live ClickHouse — clickhouse_connect is mocked.
License
MIT — see LICENSE.
Available Tools
7 toolsget_correlation_matrixB
Return the pairwise return-correlation matrix for 2-50 symbols.
Inputs: end (required), start (required), symbols (required), method, +1 more. Returns: object
get_indicatorsC
Return one technical-indicator series (e.g. ma20, rsi14, macd_hist).
Inputs: end (required), start (required), symbol (required), indicator (required), +2 more. Returns: object
get_ohlcvA
Return OHLCV bars for one symbol over [start, end] at frequency.
frequency is one of 1m/5m/15m/1h/1d/1w. start / end are
ISO dates (YYYY-MM-DD), inclusive.
Inputs: end (required), start (required), symbol (required), limit, +1 more. Returns: object
get_server_infoA
Local server metadata. Never calls ClickHouse.
Inputs: no named parameters. Returns: object
health_checkA
Local health probe + optional ClickHouse reachability check.
Inputs: no named parameters. Returns: object
run_safe_sqlA
Run a single read-only SELECT (DISABLED by default).
Off unless CLICKHOUSE_MCP_ALLOW_RAW_SQL=true. Even when enabled only single read-only SELECT statements are allowed (readonly=1, forced LIMIT, execution-time + result-row guardrails). Prefer the structured tools.
Inputs: query (required), limit. Returns: object
screen_stocksA
Full-market technical-indicator scan.
filters is a list of {indicator, operator, value} where
operator is one of gt/gte/lt/lte/eq (e.g.
[{"indicator": "rsi14", "operator": "lt", "value": 30}] for an
oversold screen). as_of is an ISO date or omitted for latest.
Inputs: filters (required), as_of, limit, frequency. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a clear unique purpose: get_correlation_matrix for correlations, get_indicators for single indicator series, get_ohlcv for price data, screen_stocks for market scans, plus server info, health, and raw SQL. No two tools overlap in functionality.
Naming uses snake_case but mixes verbs: most start with 'get_' (4 tools), but health_check, run_safe_sql, and screen_stocks use different verb patterns. While readable, the inconsistency could cause minor confusion.
With 7 tools, the set is well-scoped for a financial data server. It covers core operations without being bloated or sparse.
The server covers essential read-only financial data operations (OHLCV, indicators, correlations, scanning). A minor gap is the lack of a tool to list available symbols, but the screen_stocks tool can partially compensate. Raw SQL access is available as a fallback.
Maintenance
Related MCP Connectors
The stock market, in SQL — scan, replay, or subscribe across ~12k US tickers and top 100 cryptos.
Research-only MCP server: your AI as a quant research desk. 90 tools, no trades, no brokers.
Production MCP server for US equity and options intelligence: real-time IV radar, Monte Carlo simulation, options pressure, strategy backtesting, AI prediction, pre-trade risk analysis, and automated stock research reports.
Historical tick, order book and settlement data for Polymarket and Predict.fun crypto up/down markets, plus smart-money lists and backtest quotes, over a read-only MCP server.
Related MCP Servers
- AlicenseAqualityBmaintenanceA read-only MCP server for exploratory data analysis across PostgreSQL, MySQL, and ClickHouse databases, providing safe, read-only access with comprehensive analysis capabilities.1067 PyPI6MIT
- FlicenseAqualityDmaintenanceRead-only MCP server for ClickHouse that allows listing databases and tables, describing schemas, and running SELECT queries.4-
- AlicenseAqualityBmaintenanceA read-only-by-default Model Context Protocol (MCP) server for ClickHouse with schema discovery, parameterized SELECT-only queries, execution-plan analysis, and opt-in writes per profile. Profile-based configuration serves multiple clusters from one toolset deployment.81MIT
- FlicenseAqualityCmaintenanceRead-only SQL MCP server for quantitative finance data (DuckDB) with stock quotes, financials, and historical K-lines, enabling cross-database JOIN queries.1-