Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Read-only MCP server for large-scale cross-sectional quant analysis of US stock market data (1.49 billion rows) using ClickHouse.

README.md

clickhouse-mcp

![test](https://github.com/kevinkda/clickhouse-mcp/actions/workflows/test.yml)

中文 README

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_USER at an

account created with readonly = 1 and GRANT SELECT only, never an admin user. Defence in depth: every query is also issued with the ClickHouse session setting readonly=1 plus max_execution_time / max_result_rows guardrails.

  • Parameterised, never concatenatedget_ohlcv / get_indicators /

screen_stocks / get_correlation_matrix validate 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_sql disabled by default — gated behind

CLICKHOUSE_MCP_ALLOW_RAW_SQL=true; even when enabled it enforces SELECT-only single statements, rejects DDL/DML + comments, forces a LIMIT, and inherits readonly=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 via repr(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.

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Databases servers.