← Back to directory
D

DBMCP Database MCP Server

Community
Single-binary SQL database MCP server with built-in PII redaction and write-prevention
GitHub source repository ↗
★ 30 Stars Category · Database Popular
67FMRS · C

DBMCP is a well-engineered database MCP server: a single ~7 MB binary covering MySQL/MariaDB, PostgreSQL, and SQLite, read-only by default and backed by AST-level SQL validation, single-statement enforcement, and dangerous-function blocking — a solid security posture. Its standout features are the opt-in 46-type regex PII redaction and fail-closed ONNX NER detection. The tool surface is complete (schema discovery, querying, explain plans, optional writes) with stdio and HTTP transports and cursor pagination. Caveats: redaction is off by default, write mode requires careful risk assessment, and it is a third-party project rather than an official offering from the database vendors.

Reliability
9/20
Security and permissions
15/20
Maintenance
13/20
Documentation
17/20
Setup experience
13/20
Read the FMRS scoring method →

DBMCP (ai.haymon/dbmcp) is an open-source (MIT-licensed) database MCP server maintained by haymon-ai, supporting MySQL/MariaDB, PostgreSQL, and SQLite. It ships as a ~7 MB single binary with no Python/Node/Docker runtime dependencies, and offers stdio and HTTP (streamable-http) transports. It runs in read-only mode by default (write tools hidden), with opt-in regex-based PII redaction (46 built-in entity types across 7 categories) and optional ONNX Runtime ML/NER detection (persons, locations, etc.). Connections support SSL/TLS, connection pooling, and query timeouts.

Tools

listDatabases
Lists accessible databases, paginated via cursor/nextCursor; not available for SQLite.
listTables
Lists tables in a database with optional search and detailed mode (schema, columns, constraints, indexes, triggers metadata), paginated.
listViews
Lists views in a database with optional search and detailed per-backend metadata, paginated.
listTriggers
Lists user-defined table triggers (excluding internal constraint/foreign-key triggers), with search and detailed mode, paginated.
listFunctions
Lists user-defined SQL functions (MySQL/MariaDB and PostgreSQL), with search and detailed mode, paginated.
listProcedures
Lists user-defined stored procedures (MySQL/MariaDB and PostgreSQL 11+), with search and detailed mode, paginated.
listMaterializedViews
Lists materialized views in the public schema (PostgreSQL only), with search and detailed mode, paginated.
readQuery
Executes a read-only SQL query (SELECT, SHOW, DESCRIBE, USE, EXPLAIN) with enforced SQL validation; SELECT results paginate via cursor.
writeQuery
Executes a write SQL query (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP); only available when read-only mode is disabled.
createDatabase
Creates a database if it doesn't exist; only when read-only mode is disabled; not available for SQLite.
dropDatabase
Drops an existing database (refuses to drop the currently connected one); only when read-only mode is disabled; not available for SQLite.
dropTable
Drops a table from a database; PostgreSQL supports a cascade parameter; only when read-only mode is disabled.
explainQuery
Returns the execution plan for a SQL query, with optional analyze for actual execution statistics (PostgreSQL/MySQL); in read-only mode, EXPLAIN ANALYZE is restricted to read-only statements.

Setup

macOS/Linux/WSL: run curl -fsSL https://dbmcp.haymon.ai/install.sh | bash; Windows PowerShell: irm https://dbmcp.haymon.ai/install.ps1 | iex; Windows CMD: curl -fsSL https://dbmcp.haymon.ai/install.cmd -o install.cmd && install.cmd && del install.cmd. Also installable via Docker (ghcr.io/haymon-ai/dbmcp), Cargo, and other methods. After installation, add a .mcp. in your project root configuring the dbmcp stdio subcommand with DB_BACKEND, DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, etc. For HTTP mode, start the server yourself (e.g. dbmcp http ...) and point the client at http://127.0.0.1:9001/mcp with "type": "http".

claude_desktop_config.json
{"mcpServers":{"dbmcp":{"command":"dbmcp","args":["stdio"],"env":{"DB_BACKEND":"mysql","DB_HOST":"127.0.0.1","DB_PORT":"3306","DB_USER":"root","DB_PASSWORD":"secret","DB_NAME":"mydb"}}}}

Fit and risk

Best for

  • Users who need safe, read-only AI access to SQL databases
  • Teams with data-privacy requirements needing PII redaction
  • Developers wanting a zero-dependency, single-binary deployment
  • Environments using multiple database backends

Not for

  • Users who cannot supply or configure database credentials
  • Users expecting unrestricted write access without understanding write-mode risks
  • Users of databases other than MySQL/MariaDB, PostgreSQL, or SQLite

Required permissions

  • Requires database host, port, username, and password (DB_PASSWORD treated as a secret)
  • Read-only by default; disabling it lets the AI execute writes, and create/drop databases and tables
  • SSL/TLS connections require DB_SSL_CA/CERT/KEY certificate paths
  • Optional NER redaction requires a local ONNX model directory

Risks and side effects

  • With read-only mode disabled, the AI can modify or delete data directly, including dropDatabase/dropTable
  • PII redaction is off by default; sensitive data in query results goes to the LLM unredacted unless enabled
  • Regex redaction is not foolproof, and ML/NER detection depends on model quality; v1 is English-only
  • HTTP mode may expose database access if allowed-origins/allowed-hosts are misconfigured
  • EXPLAIN ANALYZE actually executes the query, so beware of side effects and cost

Troubleshooting

  1. Confirm a subcommand (stdio or http) is given; running with no subcommand exits with an error
  2. Check that DB_BACKEND is one of mysql, mariadb, postgres, or sqlite
  3. Verify database host, port (3306 for MySQL, 5432 for PostgreSQL), and credentials
  4. If write tools are missing, check whether DB_READ_ONLY is still the default true
  5. For HTTP failures, check host/port (default 127.0.0.1:9001) and allowed-origins/allowed-hosts settings
  6. When enabling NER, ensure the model directory contains config., tokenizer., model.onnx; unloadable models abort startup
  7. Debug stdio mode with npx @modelcontextprotocol/inspector, or test the HTTP endpoint with curl

Use cases

Safely let AI assistants explore schema and data in production or dev databases read-only
Unified querying and analysis across MySQL, PostgreSQL, and SQLite
Automatically redact PII in query output before it reaches an LLM
Analyze slow queries with explainQuery execution plans

Supported clients

Claude DesktopFull support
CursorFull support
Claude CodeFull support