clickhouse-mcp
Read-only MCP server for large-scale cross-sectional quant analysis of US stock market data (1.49 billion rows) using ClickHouse.
README
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 |
|---|---|
get_ohlcv |
OHLCV bars for one symbol over a date range at 1m/5m/15m/1h/1d/1w |
get_indicators |
One materialised / runtime indicator series (ma20, rsi14, macd_hist, …) |
screen_stocks |
Full-market technical-indicator scan (e.g. "today's RSI<30 oversold list") |
get_correlation_matrix |
Pairwise return-correlation matrix for 2–50 symbols (Pearson / Spearman) |
run_safe_sql |
Disabled by default raw-SQL escape hatch (single read-only SELECT only) |
health_check |
Local probe + optional ClickHouse reachability check |
get_server_info |
Version + tool list (offline) |
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 connection
Configure 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=usa
Run it:
uv run clickhouse-mcp
Register 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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。