db-mcp-server

by @FreePeak

Db MCP Server

Query MySQL, PostgreSQL, SQLite (with SQLCipher), Oracle, and TimescaleDB concurrently via a single MIT-licensed Go binary (`FreePeak/db-mcp-server`). It pairs local `stdio` and authenticated Streamable HTTP with PII masking, EXPLAIN cost caps, OIDC/agent scopes, and JSONL audit logs.

Databases487goMIT

Server facts

db-mcp-server

GitHub stars

487

Last commit

Nov 29, 2026

Runtime

go

License

MIT

Project

Author
FreePeak
License
MIT
Category
Databases

Tech

Runtime
go
Transports
stdiostreamable-httpsse
Remote access
No
Authentication
Optional DB credentials; Streamable HTTP requires Bearer API key, agent keys, or OIDC

Activity

GitHub stars
487
Last commit
Data as of

Tags

  • database mcp server
  • mcp server

Overview

Backend engineers searching for a production-aware `db mcp` server can bridge MySQL, PostgreSQL (v9.6-17), SQLite (including SQLCipher encryption), Oracle (10g-23c with RAC, Cloud Wallet, and TNS), and TimescaleDB using `FreePeak/db-mcp-server`. Compiled in Go (Go 1.25+ from source, or via Docker/npm releases with built-in SHA-256 binary updates), it recommends local `stdio` (`./bin/server -t stdio -c config.json`) for Cursor and desktop clients while also shipping an experimental Streamable HTTP transport (`-t streamable`, port 9092) that refuses to start without authentication—accepting a static Bearer secret (`DB_MCP_API_KEY` or a mounted key file), per-agent SHA-256 digests (`DB_MCP_AGENT_KEYS_FILE`), or OIDC JWT validation configured via `DB_MCP_OIDC_ISSUER` alongside `DB_MCP_OIDC_AUDIENCE`. Legacy SSE stays disabled unless `-allow-insecure-sse` is passed.

By default, the server generates per-database tools (`query_<id>`, `execute_<id>`, `transaction_<id>`, `schema_<id>`, `performance_<id>`, `explain_<id>`, `describe_<id>`, `health_<id>`, plus TimescaleDB hypertable tools), or collapses them via `--unified-tools` so large multi-database configs stay flat at 1.25–1.6k tokens and avoid Claude tool-count limits (add `--lazy-loading` for 10+ databases). Operational guardrails include best-effort `read_only` checks alongside least-privilege DB users, `max_rows` truncation, regex column `masking_rules`, content-shape `mask_pii` redaction, `query_timeout` (default 30s), `max_query_cost` planner-cost caps, pre-mutation rollback snapshots (last 25 per DB), and `0600` JSONL audit logging (`DB_MCP_AUDIT_LOG`).

Install & configure

Requirements

  • Go 1.25+ (`make build`) for source builds, or Docker / npm release binary
  • Database configuration JSON (`config.json`, `DB_CONFIG`, or env vars) with credentials supplied via `password_env` or `password_file`
  • Bearer auth (`DB_MCP_API_KEY`, `DB_MCP_API_KEY_FILE`, `DB_MCP_AGENT_KEYS_FILE`, or OIDC env vars) required when starting Streamable HTTP
Documented launch / install command
make build && ./bin/server -t stdio -c config.json

Build with `make build` and launch locally via `./bin/server -t stdio -c /absolute/path/to/config.local.json`. Add `--unified-tools` when connecting multiple databases to Claude and `--lazy-loading` for 10+ databases. Docker defaults to authenticated Streamable HTTP on port 9092 (health on 9093).

Config file · macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Use Settings → Developer → Edit Config when available. Do not assume a Linux configuration path; check the client documentation for your platform. Remote servers use the app’s connector flow when supported, not the local stdio file shown here. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Desktop configuration
{
  "mcpServers": {
    "local-db": {
      "command": "/absolute/path/to/db-mcp-server/bin/server",
      "args": [
        "-t",
        "stdio",
        "-c",
        "/absolute/path/to/config.local.json"
      ]
    }
  }
}

Read the Claude Desktop setup guide

Config file · Project: .cursor/mcp.json

User: ~/.cursor/mcp.json

The project path is relative to the workspace root. The tilde denotes your user home directory. Use Cursor’s MCP settings to confirm which configuration and scope your installed version is reading. Merge this example with existing settings; do not overwrite unrelated servers.

Cursor configuration
{
  "mcpServers": {
    "local-db": {
      "command": "/absolute/path/to/db-mcp-server/bin/server",
      "args": [
        "-t",
        "stdio",
        "-c",
        "/absolute/path/to/config.local.json"
      ]
    }
  }
}

Read the Cursor setup guide

Config file · Workspace: .vscode/mcp.json

For user scope, use the “MCP: Open User Configuration” command if available. Do not guess a user configuration path across operating systems, profiles, containers, or remote workspaces; check the client documentation. Merge this example with existing settings; do not overwrite unrelated servers.

VS Code configuration
{
  "servers": {
    "local-db": {
      "type": "stdio",
      "command": "/absolute/path/to/db-mcp-server/bin/server",
      "args": [
        "-t",
        "stdio",
        "-c",
        "/absolute/path/to/config.local.json"
      ]
    }
  }
}

Read the VS Code setup guide

Config file · macOS/Linux: ~/.codeium/windsurf/mcp_config.json

Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json

Open the MCP configuration through Windsurf’s settings when possible to confirm the active file. Paths can differ in managed or future releases; check the client documentation if this location is not present. Merge this example with existing settings; do not overwrite unrelated servers.

Windsurf configuration
{
  "mcpServers": {
    "local-db": {
      "command": "/absolute/path/to/db-mcp-server/bin/server",
      "args": [
        "-t",
        "stdio",
        "-c",
        "/absolute/path/to/config.local.json"
      ]
    }
  }
}

Read the Windsurf setup guide

Config file · Project scope: .mcp.json at the repository root

The project file uses mcpServers. For user scope, use claude mcp add --scope user rather than assuming .mcp.json in your home directory is the user configuration. Check the client documentation for managed settings and storage details. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Code configuration
{
  "mcpServers": {
    "local-db": {
      "type": "stdio",
      "command": "/absolute/path/to/db-mcp-server/bin/server",
      "args": [
        "-t",
        "stdio",
        "-c",
        "/absolute/path/to/config.local.json"
      ]
    }
  }
}

Read the Claude Code setup guide

Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.

Tools

Source: repository README. Tool descriptions are a documented snapshot, not a live capability check.

ToolWhat it does
queryExecute SELECT queries and return tabular results, supporting additive `mask_pii` redaction and `max_rows` caps.
executeRun INSERT, UPDATE, or DELETE statements with optional offline `dry_run` risk classification and pre-mutation snapshots.
transactionManage explicit begin, execute, commit, rollback transactions plus `list_snapshots` and `rollback_snapshot` undo actions.
schemaInspect tables, columns, indexes, and foreign keys across connected databases.
generate_schemaGenerate SQL or code artifacts from an existing database schema.
performanceRun slow-query tracking, static SQL linting, index/workload suggestions, PostgreSQL `hypopg` validation, and index/DB health checks.
explainReturn query execution plans (with optional `analyze: true` on PostgreSQL/MySQL) while honoring read-only and cost limits.
describeInspect columns, indexes, and row estimates for a specific table via engine catalog queries.
healthReport connectivity, ping latency, pool status, and buffer-cache hit ratios.
timescaledb_timeseries_queryExecute time-bucketed, filtered, and windowed queries against TimescaleDB hypertables.
timescaledb_analyze_timeseriesAnalyze trend and seasonality summaries for a TimescaleDB table column.
timescaledb_list_hypertablesList TimescaleDB hypertables with time columns and dimension counts (read-only).
timescaledb_compression_settingsInspect compression settings configured on TimescaleDB hypertables (read-only).
timescaledb_retention_policyShow configured TimescaleDB data retention policies (read-only).
timescaledb_list_continuous_aggregatesList TimescaleDB continuous aggregates with bucket intervals and refresh policies (read-only).
timescaledb_continuous_aggregate_infoInspect detailed metadata for a specific TimescaleDB continuous aggregate (read-only).

Use cases

  • Query PostgreSQL, MySQL, Oracle, and local SQLite databases side by side in a single Cursor or Claude session.
  • Give AI agents read-only production troubleshooting access guarded by `max_rows`, `mask_pii`, `masking_rules`, `max_query_cost`, and JSONL audit trails.
  • Diagnose slow SQL workloads using `performance` index suggestions and PostgreSQL `hypopg` hypothetical index validation.
  • Issue scoped per-agent Bearer keys (`db:read`, `db:write`, database allowlists) over Streamable HTTP for multi-agent reporting pipelines.

Strengths

  • Broad relational coverage (MySQL, PostgreSQL, SQLite/SQLCipher, Oracle 10g-23c with Cloud Wallet/RAC/TNS, and TimescaleDB) in a compiled Go binary.
  • `--unified-tools` keeps tool-schema token cost flat (1.25–1.6k tokens) regardless of database count, resolving Claude tool-limit issues.
  • Defense-in-depth governance: `read_only`, `max_rows`, `query_timeout`, `max_query_cost`, regex masking + PII redaction, rollback snapshots, OIDC/agent scopes, and JSONL audit logging.
  • Secret references (`password_env`, `password_file`) keep credentials out of JSON configs and process logs.

Limitations

  • Streamable HTTP transport is marked experimental and requires an external TLS gateway for shared team deployments.
  • Application-level `read_only` checks and `mask_pii` are best-effort defenses, so operators still need least-privilege `SELECT`-only database accounts.
  • TimescaleDB write-policy management is not exposed as dedicated tools (must run via SQL), and per-agent keys cannot invoke TimescaleDB tools.

db-mcp-server setup notes

  • db-mcp-server's example uses stdio, while its catalog transports are stdio / streamable-http / sse; use the example's connection type.

Frequently asked questions

Build or install the binary and point your MCP config to `./bin/server -t stdio -c /absolute/path/to/config.local.json --unified-tools`. Passing `--unified-tools` registers consolidated tools taking a `database` argument (keeping wire payload flat at 1.25–1.6k tokens instead of multiplying tools per database), and adding `--lazy-loading` defers connections until first use.

Related MCP servers