db-mcp
Enables natural-language querying of ClickHouse databases, with read-only query validation and a self-improving semantic layer.
Provides git-based collaboration for connection configurations and semantic-layer changes, including initializing sync, syncing changes, and pulling updates from a remote repository.
Enables natural-language querying of MySQL databases, with read-only query validation and a self-improving semantic layer.
Enables natural-language querying of PostgreSQL databases, with read-only query validation and a self-improving semantic layer.
Enables natural-language querying of Trino databases, with read-only query validation and a self-improving semantic layer.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
db-mcp
Your teams are copy-pasting company data into Claude. Give them a safe way to do it.
db-mcp is an open-source MCP server that connects Claude Desktop to your databases—with a self-improving semantic layer that gets smarter with every query.
No infrastructure needed. Runs locally. Data never leaves your network.
Installation
curl -fsSL https://download.apelogic.ai/db-mcp/install.sh | shRelated MCP server: Neon Enterprise MCP Gateway
Why db-mcp?
Ask Claude, get answers — Stop waiting for reports. Query your data in natural language without SQL, copy-pasting schemas, or context-setting
Self-improving semantic layer — Auto-generates descriptions of your schema, then learns from every query to improve accuracy over time
Runs on your desktop — No cloud infrastructure, no data leaving your network. Uses your existing database credentials and access controls
Git-style collaboration — Data teams review and approve semantic layer improvements. You stay in control, users get accurate answers
Open source & auditable — MIT licensed, fully transparent, no vendor lock-in
Who is db-mcp for?
Role | Benefit |
Business Teams | Ask Claude questions about your data and get accurate answers instantly—no SQL required |
Data Teams | Turn your warehouse into an agent-ready platform with a semantic layer that builds itself |
IT & Security | Govern AI data access with full interaction history, read-only enforcement, and cost guards |
How It Works
From install to insight in four steps:
Install — Download db-mcp to your laptop. No infrastructure needed—runs locally in minutes
Connect — Add data sources using your existing credentials. Your security posture stays intact
Query — Ask Claude questions across your connected data. Every query is validated before execution
Improve — The semantic layer learns from usage. Review and approve improvements with a git-style workflow
Quick Start
# Configure your database and Claude Desktop
db-mcp init
# Check configuration
db-mcp statusSupported Agents
Claude Desktop
The default setup works with Claude Desktop. Follow the Quick Start instructions above.
OpenClaw
db-mcp works with OpenClaw via mcporter:
# Install mcporter (MCP bridge for OpenClaw)
npm i -g mcporter
# Configure db-mcp for OpenClaw
db-mcp initOr manually add to ~/.openclaw/workspace/config/mcporter.json:
{
"mcpServers": {
"db-mcp": {
"command": "db-mcp",
"args": ["start"]
}
}
}Supported Databases
PostgreSQL
ClickHouse
Trino
MySQL
SQL Server
Security & Governance
Runs locally — Data stays on your machine, never routed through external servers
Read-only by default — Query validation and cost guards prevent accidental data modification
Uses existing RBAC — Connects with your database credentials and respects your access controls
Full audit trail — Complete interaction history for compliance and debugging
Open source — Fully auditable, MIT licensed
Commands
Setup & Configuration
Command | Description |
| Interactive setup wizard - configure database and Claude Desktop |
| Show current configuration status |
| Open config file in editor |
Connection Management
Command | Description |
| List all configured connections |
| Switch to a different connection |
| Edit connection credentials (.env file) |
| Rename a connection |
| Remove a connection |
| Run a command for all connections |
Server & Diagnostics
Command | Description |
| Start the MCP server (stdio mode for Claude Desktop) |
| Start local trace console (view MCP server activity) |
| Manage trace capture for diagnostics and learning |
Git Sync (Team Collaboration)
Command | Description |
| Enable git sync for an existing connection |
| Sync connection changes with git remote |
| Pull connection updates from git remote |
Migration
Command | Description |
| Migrate from legacy storage format to new connection structure |
Configuration
Connection data is stored in ~/.db-mcp/:
~/.db-mcp/
├── config.yaml # Global config, active connection
└── connections/{name}/
├── .env # Database credentials (gitignored)
├── state.yaml # Onboarding state
├── schema/
│ └── descriptions.yaml # Table/column descriptions
├── domain/
│ └── model.md # Domain model documentation
├── training/
│ ├── examples.yaml # Query examples (NL → SQL mappings)
│ └── instructions.yaml # Custom SQL generation rules
└── .git/ # Optional git sync for team sharingConfiguration Artifacts
File | Purpose |
| Global settings: active connection, preferences |
| Database URL and credentials (never committed to git) |
| Onboarding progress (discovery → review → domain-building → complete) |
| Human-readable descriptions of tables and columns |
| Business domain documentation for the LLM |
| Known-good query examples to guide SQL generation |
| Custom rules and constraints for SQL generation |
Environment Variables
Variable | Description |
| Connection string (required) |
| Override active connection |
| Override connection directory path |
| Logging verbosity (default: INFO) |
Development
# Clone
git clone https://github.com/apelogic-ai/db-mcp.git
cd db-mcp
# Install dependencies
uv sync
# Run locally
cd packages/core
uv run db-mcp --help
# Lint
cd packages/core && uv run ruff check . --fix
cd packages/ui && bun run lint
# Build binary
cd packages/core
uv run python scripts/build.pyTesting
93 tests across three layers:
# Python unit tests (49 tests)
cd packages/core
uv run pytest tests/ -v
# UI unit tests (20 tests)
cd packages/ui
bun run test
# UI E2E tests (24 tests)
cd packages/ui
bunx playwright testAll tests run in CI via GitHub Actions on every push and PR. See docs/testing.md for the full testing guide.
Tool Coverage Check
Verify that 100% of MCP tools implemented in the codebase are exposed by the MCP server at runtime:
# Run the tool coverage audit (default SQL mode)
python scripts/tool_coverage_audit.py
# Test different configuration modes
python scripts/tool_coverage_audit.py --config api
python scripts/tool_coverage_audit.py --config shell
python scripts/tool_coverage_audit.py --config metabase
# Verbose output with all tool names
python scripts/tool_coverage_audit.py --verbose
# JSON output for CI integration
python scripts/tool_coverage_audit.py --jsonThe audit returns exit code 0 on success (100% coverage) and 1 on failure.
Project Structure
db-mcp/
├── packages/
│ ├── core/ # Main application (db-mcp)
│ ├── models/ # Shared Pydantic models (db-mcp-models)
│ └── ui/ # Next.js control plane UI
├── docs/ # Design documents
├── scripts/ # Installation scripts
└── .github/workflows/ # CI/CDRoadmap
See docs/ for design documents on planned features:
Metrics Layer - Semantic metric definitions (DAU, revenue, etc.)
Desktop App - Electron GUI with visual query builder
Knowledge Extraction - Learn from query traces automatically
Data Gateway - Unified access to multiple data sources
Resources
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI assistants to connect to 17+ databases and query/analyze data using natural language via MCP and HTTP APIs, supporting platforms like Claude Desktop, Cursor, and VS Code.42105 npmMIT
- FlicenseBqualityCmaintenanceEnables Claude Desktop and custom AI agents to securely access enterprise Postgres databases and Notion knowledge bases via MCP, with read-only SQL enforcement, audit logging, and API-key authentication.1-
- AlicenseBqualityBmaintenanceEnables AI agents to safely describe, query, and compute metrics across SQL databases using open-format semantic models, custom context, and skills, with read-only and dialect-checked execution.11Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to query DuckDB, Postgres, and BigQuery through a governed, read-only layer with a semantic model, SQL guard, role-based row policies, PII pseudonymization, audit logging, and cost caps.218 PyPIMIT