Skip to main content

An MCP server for Databend.

Project description

MCP Server for Databend

PyPI - Version

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:

  1. Database user permissions (primary)
  2. MCP sandbox validation (additional layer)
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_databend-0.3.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_databend-0.3.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

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

Hashes for mcp_databend-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b50df05823fc7f18489162790bc7f56bbf243d9940bd1d1ede16dca1813a5eb6
MD5 6fc9f592d8eb4173e29fda415c84883f
BLAKE2b-256 3e4a3377ce96a1430d1ff73d3fd6afbebab4752b908e488f82659029db4c4c47

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_databend-0.3.0.tar.gz:

Publisher: python-publish.yml on databendlabs/mcp-databend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mcp_databend-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd21d635fcf391b3d5e5433006409f0ab9898283342d51aeb9e25c3bbd5e098d
MD5 b6474b2f74f442346c0e4c71dd862c23
BLAKE2b-256 d2f12ea24aa0316d28950a1e2163aa1cee4021e31b2e5489627c65b95fb1efa2

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page