Databricks MCP Server
A Model Context Protocol server that lets LLM clients answer business questions in natural language over a Databricks dataset without writing SQL by hand.
README
Databricks MCP Server — Natural-Language Analytics POC
A small Model Context Protocol server that lets an LLM client (e.g. Claude Desktop) answer business questions in natural language over a Databricks dataset — without writing SQL by hand.
It runs against the public samples.nyctaxi.trips dataset that ships with every
Databricks workspace, so it's reproducible by anyone.
What it exposes (the three MCP primitives)
| Primitive | Name | Purpose |
|---|---|---|
| Tool | run_query |
Executes a read-only SQL query against samples.nyctaxi.trips and returns the rows. |
| Resource | schema://nyctaxi |
Curated schema + metric definitions and gotchas — the context layer that makes the generated SQL correct. |
| Prompts | revenue_by_month, busiest_pickup_zones, trips_by_hour, fare_distance_summary |
Ready-made business questions. |
Safety / governance
Two layers, on purpose:
- App-level guard (
is_read_only): only a singleSELECT/WITHstatement is accepted; any write/DDL keyword (INSERT,UPDATE,DROP, ...) is rejected, and aLIMIT 1000is appended when missing. - The real guarantee: connect with a Databricks token whose grants are read-only on the catalog. App guards reduce footguns; permissions are what actually protect the data. Never give an LLM a write-capable credential.
Architecture
Claude Desktop ──stdio──► MCP server (this repo) ──Databricks SQL connector──► samples.nyctaxi.trips
(client) tool · resource · prompts (read-only)
run_query doesn't open the connection in-process — it shells out to
query_runner.py (subprocess.run(..., stdin=subprocess.DEVNULL, capture_output=True)).
See the note below for why.
Implementation note: why run_query uses a subprocess
Both points were reproduced and verified on Windows + the FastMCP stdio
transport (Claude Desktop and the MCP Inspector). Symptom in both: the tool call
hangs and the client returns MCP error -32001: Request timed out at ~60s, even
though the same query runs in ~4s with the connector directly.
-
sql.connect()stalls ~60s when called inside the server process. From a clean child process it connects in ~2s; inside the FastMCP process it blocks until the client's request times out. It stalls on the event-loop thread and on a worker thread, so it's a process-level interaction with the connector — not just the event loop being blocked. Running the query in a child process avoids it. (Disabling telemetry /use_cloud_fetchdoes not help.) -
stdin=subprocess.DEVNULLis required on the child. A stdio MCP server's own stdin is the JSON-RPC pipe from the client. A child started with the defaultstdin=Noneinherits that pipe handle and hangs until the client gives up (~60s). Detaching stdin makes it return at query speed.capture_output=Truealready detaches stdout/stderr — stdin is the one that's easy to miss, so piping the query out to a subprocess without it does not fix the hang.
Gotcha — don't launch the Inspector from Git Bash on Windows. MSYS2 rewrites the POSIX-looking
DATABRICKS_HTTP_PATH(/sql/1.0/warehouses/…→C:/Program Files/Git/sql/1.0/warehouses/…), so the server gets a 404, not a timeout. Use PowerShell orcmd. Claude Desktop passes env vars directly and is unaffected.
Run it
Prereqs: Python 3.11+, uv, a Databricks workspace
with a running SQL Warehouse and the samples catalog.
Windows / PowerShell (recommended on Windows — see the Git Bash gotcha above):
cd "C:\path\to\databricks-mcp"
uv sync # first time only
# from SQL Warehouses -> Connection details, plus a personal access token.
# These live only in THIS PowerShell window (nothing is written to disk):
$env:DATABRICKS_HOST = "dbc-xxxxxxxx-xxxx.cloud.databricks.com"
$env:DATABRICKS_HTTP_PATH = "/sql/1.0/warehouses/xxxxxxxxxxxxxxxx"
$env:DATABRICKS_TOKEN = "dapixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# launch the browser inspector, then run a query from its UI:
npx @modelcontextprotocol/inspector uv run server.py
<details> <summary><b>macOS / Linux (bash)</b></summary>
uv sync
export DATABRICKS_HOST="adb-....azuredatabricks.net"
export DATABRICKS_HTTP_PATH="/sql/1.0/warehouses/...."
export DATABRICKS_TOKEN="dapi...."
npx @modelcontextprotocol/inspector uv run server.py
</details>
Connect to Claude Desktop
Copy claude_desktop_config.example.json into your Claude Desktop config
(%APPDATA%\Claude\claude_desktop_config.json on Windows,
~/Library/Application Support/Claude/claude_desktop_config.json on macOS),
fill in your real values, and restart Claude Desktop. Then ask things like:
"What were the busiest pickup zones, and how does monthly revenue trend?"
Notes
samples.nyctaxi.tripsis a public Databricks dataset; no private data is used.- Secrets live in env vars / the Claude Desktop config, both git-ignored.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。