An MCP server for Databend.
Project description
MCP Server for Databend
Connect AI assistants to your Databend database safely. This MCP server enables Claude, Cursor, and other AI tools to query and analyze your data without risking production changes.
Works with Claude Desktop, Claude Code, Cursor, Windsurf, Codex, Gemini CLI, and any MCP-compatible agent. Learn more at databend.com/mcp.
What is MCP?
Model Context Protocol (MCP) lets AI assistants securely access external data sources. This server gives AI read access to your entire database, while restricting writes to isolated sandbox areas.
Use Cases:
- Ask AI to analyze sales data: "Show me top customers this quarter"
- Generate reports: "Create a summary table of user signups by region"
- Debug queries: "Why is this query slow?"
- Explore schema: "What tables contain customer information?"
AI can freely experiment in its sandbox without affecting production data.
Why Safe?
Session Sandbox Isolation - Each AI session gets a unique prefix (mcp_sandbox_{session_id}_):
- ✅ AI can freely create/modify/delete objects with its prefix
- ✅ AI can read all data (SELECT, SHOW, DESCRIBE)
- ❌ AI cannot modify production data
Example:
-- ✅ AI can do this safely in sandbox
CREATE DATABASE mcp_sandbox_abc123_analysis
CREATE OR REPLACE TABLE mcp_sandbox_abc123_analysis.results (id INT)
INSERT INTO mcp_sandbox_abc123_analysis.results VALUES (1)
UPDATE mcp_sandbox_abc123_analysis.results SET id=2
DROP TABLE mcp_sandbox_abc123_analysis.results
SELECT * FROM production.sales -- Read-only access
-- ❌ AI cannot do this
DROP TABLE production.users
UPDATE production.orders SET status='cancelled'
CREATE OR REPLACE TABLE production.temp (id INT)
Defense in Depth:
- Database user permissions (primary)
- MCP sandbox validation (additional layer)
- SQL standardization to prevent bypass attempts
Quick Start
Install
uv tool install mcp-databend
Configure
Claude Code:
claude mcp add mcp-databend --env DATABEND_DSN='databend://user:pwd@host:443/db?warehouse=wh' -- uv tool run mcp-databend
Other MCP Clients:
{
"mcpServers": {
"mcp-databend": {
"command": "uv",
"args": ["tool", "run", "mcp-databend"],
"env": {
"DATABEND_DSN": "databend://user:pwd@host:443/db?warehouse=wh"
}
}
}
}
Get your connection string from Databend Cloud (free tier) or docs.
Local Mode: Set LOCAL_MODE=true to use embedded Databend (stores in .databend/).
Available Tools
| Tool | Description |
|---|---|
execute_sql |
Execute SQL with sandbox validation |
execute_multi_sql |
Execute multiple SQL statements |
show_databases |
List all databases |
show_tables |
List tables in database |
describe_table |
Get table schema |
get_session_sandbox_prefix |
Get current session prefix |
list_session_sandbox_databases |
List sandbox databases |
create_session_sandbox_database |
Create sandbox database |
show_stages / list_stage_files / create_stage |
Stage management |
show_connections |
List connections |
Configuration
| Variable | Default | Description |
|---|---|---|
DATABEND_DSN |
- | Connection string |
LOCAL_MODE |
false |
Use local Databend |
DATABEND_QUERY_TIMEOUT |
300 |
Query timeout (seconds) |
DATABEND_MCP_SERVER_TRANSPORT |
stdio |
Transport: stdio, http, sse |
DATABEND_MCP_BIND_HOST |
127.0.0.1 |
Bind host for HTTP/SSE |
DATABEND_MCP_BIND_PORT |
8001 |
Bind port for HTTP/SSE |
Development
git clone https://github.com/databendlabs/mcp-databend
cd mcp-databend
uv sync
# Run locally
uv run python -m mcp_databend.main
# Debug
npx @modelcontextprotocol/inspector -e LOCAL_MODE=1 uv run python -m mcp_databend.main
# Test
uv run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_databend-0.3.0.tar.gz.
File metadata
- Download URL: mcp_databend-0.3.0.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b50df05823fc7f18489162790bc7f56bbf243d9940bd1d1ede16dca1813a5eb6
|
|
| MD5 |
6fc9f592d8eb4173e29fda415c84883f
|
|
| BLAKE2b-256 |
3e4a3377ce96a1430d1ff73d3fd6afbebab4752b908e488f82659029db4c4c47
|
Provenance
The following attestation bundles were made for mcp_databend-0.3.0.tar.gz:
Publisher:
python-publish.yml on databendlabs/mcp-databend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_databend-0.3.0.tar.gz -
Subject digest:
b50df05823fc7f18489162790bc7f56bbf243d9940bd1d1ede16dca1813a5eb6 - Sigstore transparency entry: 844761338
- Sigstore integration time:
-
Permalink:
databendlabs/mcp-databend@03110042396b5b78f0f562a919f83dea4b09a4cc -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/databendlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@03110042396b5b78f0f562a919f83dea4b09a4cc -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_databend-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mcp_databend-0.3.0-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd21d635fcf391b3d5e5433006409f0ab9898283342d51aeb9e25c3bbd5e098d
|
|
| MD5 |
b6474b2f74f442346c0e4c71dd862c23
|
|
| BLAKE2b-256 |
d2f12ea24aa0316d28950a1e2163aa1cee4021e31b2e5489627c65b95fb1efa2
|
Provenance
The following attestation bundles were made for mcp_databend-0.3.0-py3-none-any.whl:
Publisher:
python-publish.yml on databendlabs/mcp-databend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_databend-0.3.0-py3-none-any.whl -
Subject digest:
fd21d635fcf391b3d5e5433006409f0ab9898283342d51aeb9e25c3bbd5e098d - Sigstore transparency entry: 844761345
- Sigstore integration time:
-
Permalink:
databendlabs/mcp-databend@03110042396b5b78f0f562a919f83dea4b09a4cc -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/databendlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@03110042396b5b78f0f562a919f83dea4b09a4cc -
Trigger Event:
release
-
Statement type: