FreePeak DB

Databases

A powerful multi-database server implementing the Model Context Protocol (MCP) to provide AI assistants with structured access to databases.

Your AI app calls the FreePeak DB MCP server, which does the databases work and sends the result back to the chat.

About FreePeak DB

FreePeak DB is a community MCP server from FreePeak, filed in our directory under databases. A powerful multi-database server implementing the Model Context Protocol (MCP) to provide AI assistants with structured access to databases.

At a glance

Publisher
FreePeak (community)
Runs
See the README for setup
Written in
Go
License
MIT
GitHub stars
488

How to set up FreePeak DB

  1. Follow the install steps in the FreePeak DB README; it is written in Go, so have that toolchain ready.
  2. Check the FreePeak DB README for keys or settings; the registry lists none that FreePeak DB requires.
  3. Add FreePeak DB to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the FreePeak DB tools to confirm the connection.
  5. Run one read-only task with FreePeak DB first, and keep your app asking before each tool call until the results look right.

FreePeak DB compared with similar servers

  • Atlas by cyanheads has fewer GitHub stars than FreePeak DB (481 against 488); both are community servers, and both run locally.
  • Pgmcp by subnetmarco has more GitHub stars than FreePeak DB (544 against 488); both are community servers, and both run locally.
  • Memento by gannonh has fewer GitHub stars than FreePeak DB (426 against 488); both are community servers, and both run locally.

Before you connect FreePeak DB

  • Give FreePeak DB its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each FreePeak DB tool call until you trust what it does with them.
  • Treat text that FreePeak DB fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for FreePeak DB on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for FreePeak DB

How marketing and sales teams put FreePeak DB to work, by company size. Pick the size closest to yours and start FreePeak DB on one use case.

Small business

  • A small business with its own app can ask FreePeak DB plain questions about customers and orders, without writing SQL.
  • Owners can use FreePeak DB to pull a list of customers who haven't bought in 90 days and plan a win-back email.
  • FreePeak DB runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Marketing analysts can connect FreePeak DB to answer campaign questions from the warehouse directly, instead of waiting on the data team's queue.
  • Lifecycle teams can use FreePeak DB to build audience lists from product data and check counts before a send.
  • Start FreePeak DB on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises should point FreePeak DB at a read replica with a read-only role, so agents query freely without risk to production data.
  • Data teams can expose curated views through FreePeak DB, so marketing gets self-serve answers without access to raw customer tables.
  • FreePeak DB is a community server, so have security review the code and pin a version before FreePeak DB touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

FreePeak DB README

From FreePeak/db-mcp-server on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

Multi Database MCP Server

A powerful multi-database server implementing the Model Context Protocol (MCP) to provide AI assistants with structured access to databases.

Overview • Core Concepts • Features • Supported Databases • Deployment Options • Configuration • Available Tools • Examples • Troubleshooting • Contributing 📄 Product Requirements, current capabilities, roadmap & decisions

Overview

The DB MCP Server provides a standardized way for AI models to interact with multiple databases simultaneously. Built on the FreePeak/cortex framework, it enables AI assistants to execute SQL queries, manage transactions, explore schemas, and analyze performance across different database systems through a unified interface.

Core Concepts

Multi-Database Support

Unlike traditional database connectors, DB MCP Server can connect to and interact with multiple databases concurrently:

{
  "connections": [
    {
      "id": "mysql1",
      "type": "mysql",
      "host": "localhost",
      "port": 3306,
      "name": "db1",
      "user": "user1",
      "password": "password1"
    },
    {
      "id": "postgres1",
      "type": "postgres",
      "host": "localhost",
      "port": 5432,
      "name": "db2",
      "user": "user2",
      "password": "password2"
    },
    {
      "id": "oracle1",
      "type": "oracle",
      "host": "localhost",
      "port": 1521,
      "service_name": "XEPDB1",
      "user": "user3",
      "password": "password3"
    }
  ]
}
Dynamic Tool Generation

For each connected database, the server automatically generates specialized tools:

// For a database with ID "mysql1", these tools are generated:
query_mysql1       // Execute SQL queries
execute_mysql1     // Run data modification statements
transaction_mysql1 // Manage transactions
schema_mysql1      // Explore database schema
performance_mysql1 // Analyze query performance
Clean Architecture

The server follows Clean Architecture principles with these layers:

  1. Domain Layer: Core business entities and interfaces
  2. Repository Layer: Data access implementations
  3. Use Case Layer: Application business logic
  4. Delivery Layer: External interfaces (MCP tools)

Features

  • Simultaneous Multi-Database Support: Connect to multiple MySQL, PostgreSQL, SQLite, and Oracle databases concurrently
  • Lazy Loading Mode: Defer connection establishment until first use - perfect for setups with 10+ databases (enable with --lazy-loading flag)
  • Database-Specific Tool Generation: Auto-creates specialized tools for each connected database
  • Clean Architecture: Modular design with clear separation of concerns
  • OpenAI Agents SDK Compatibility: Full compatibility for seamless AI assistant integration
  • Dynamic Database Tools: Execute queries, run statements, manage transactions, explore schemas, analyze performance
  • Unified Interface: Consistent interaction patterns across different database types
  • Connection Management: Simple configuration for multiple database connections
  • Health Check: Automatic validation of database connectivity on startup
  • Production Guardrails: Per-database read_only checks (best-effort, applied to both query_* and execute_* tools; use least-privilege database users for a hard guarantee), max_rows result truncation with explicit notices, and per-query timeouts
Production Guardrails

Protect agent sessions against runaway queries and accidental writes:

Setting Scope Effect
"read_only": true per database Best-effort defense in depth, not a security boundary. A textual check runs for both query and execute tools and rejects statements it does not recognize. Functions called from a SELECT may not be recognized, so the check can miss a write. Engine session defaults are a second layer, not a security boundary on their own: PostgreSQL/TimescaleDB sessions start with default_transaction_read_only=on, MySQL with transaction_read_only=1, and SQLite opens mode=ro. Oracle has no session-level read-only switch; the connector refuses to connect with credentials that hold write privileges. For strong guarantees, connect with a database account that only has SELECT privileges. On MySQL, the account must also lack the FILE privilege, which grants server-side file access.
"max_rows": 1000 per database Truncates result sets at N rows and appends an explicit Truncated: showing first N rows (max_rows=N) notice so the model knows to refine its query instead of losing context. 0 (default) means unlimited. LIMIT max_rows+1 is added where the statement can be rewritten (PostgreSQL/TimescaleDB, MySQL, SQLite), so the database stops at the cap; otherwise the result is truncated after N rows. Select-list functions with side effects (for example nextval()) run for at most max_rows+1 rows.
"masking_rules": [...] per database Masks values of result columns whose name matches a rule's regex before they leave the server, applies to every query shape including SELECT *. Strategies: "fixed_string" (replace with value), "null", and "partial" (keep_last trailing characters visible; shorter values fully masked). First matching rule wins; invalid patterns or unknown strategies abort config load (fail closed); masked-cell counts are reported in the result footer. masking_rules match the result column name returned by the database; mask_pii also detects common PII formats in values. See docs/design/column-masking-scoping.md.
"mask_pii": true per database Redacts PII in query results by content shape, not just column name: emails, phone numbers, Luhn-valid card numbers, SSNs, IPv4 addresses and 19+ digit identifiers are replaced with [EMAIL]/[PHONE]/[CREDIT_CARD]/[SSN]/[IP_ADDRESS]/[LONG_NUMBER] when they appear as a whole pattern inside a single cell, including free-text columns. Best-effort: values split across columns, non-standard formats, and names or addresses are not detected, and masking runs after the database has returned the data. Columns named like email/card_number/iban are redacted whole. Operator-controlled: once set, an agent cannot turn it off (the per-query mask_pii parameter is additive only). Composes with masking_rules.
"query_timeout": 30 per database Cancels statements that exceed the timeout in seconds; enforced at the repository layer for every tool (queries, statements, transactions, explain, schema inspection). Unset defaults to 30s; -1 disables. Env-only deployments can set QUERY_TIMEOUT_SECONDS to fill connections without an explicit value (JSON keeps precedence).
"max_query_cost": 50000 per database Denies a SELECT or WITH through the query tool when its EXPLAIN planner-cost estimate is above the limit. Explain with analyze=true is estimated first and refused above the limit. PostgreSQL, TimescaleDB and MySQL only; startup fails on other engines and on a negative value. An estimate that cannot be obtained or read denies the query. 0 (default) means off. A caller limit from an agent key or OIDC role can lower it further. See docs/governance.md.
DB_MCP_API_KEY or DB_MCP_API_KEY_FILE process Shared Bearer key for Streamable HTTP. Set exactly one source (flag, env or file); Streamable HTTP refuses to start without authentication. Calls with this key use the principal api-key. The key file is read once at startup.
DB_MCP_OIDC_ISSUER + DB_MCP_OIDC_AUDIENCE process OIDC bearer tokens on Streamable HTTP: discovery at startup, signature, issuer and audience checks, and the sub claim as the principal. When set, OIDC replaces the shared key.
DB_MCP_API_SCOPES process Scopes granted to the shared key (default db:read) and required on every request under OIDC, except that a roles file supplies each token's scopes instead. Each tool call also needs its own scope: db:read, db:write or db:admin. See Tool scopes.
DB_MCP_AGENT_KEYS_FILE process Per-agent keys: each agent gets a digest, an id (its audit principal), scopes and a database allowlist. Streamable HTTP only; cannot be combined with OIDC. Every agent key, "*" included, uses the unified tools only, so the server needs -unified-tools.
DB_MCP_OIDC_ROLES_FILE process Maps one token claim to a grant (scopes, databases, optional max_query_cost). The first matching role in file order applies; a token that matches no role is denied everything. Requires DB_MCP_OIDC_ISSUER and -unified-tools.
DB_MCP_RESOURCE_URL process Serves RFC 9728 protected resource metadata at /.well-known/oauth-protected-resource and adds a WWW-Authenticate challenge to /mcp 401 and 403 responses. Requires DB_MCP_OIDC_ISSUER.
DB_MCP_AUDIT_LOG=/path/audit.jsonl process Appends one JSONL record per executed statement, timestamp, op (query/execute/tx_*), database, statement (capped at 10,000 bytes), duration, error. Includes rejected attempts against read-only databases. Best-effort writes never fail a query; file is created with 0600. Also records calls refused by a tool scope or by an agent key's database allowlist (op: "denied", Streamable HTTP only) and the tool field; DB_MCP_AUDIT_REQUIRED=true makes startup fail unless the log opens, and DB_MCP_AUDIT_PRINCIPAL labels records that have no principal (stdio).

Each record also says who ran the statement and how much it touched. These fields are additive and omitted when unknown, so existing consumers keep working:

  • principal: the authenticated caller. For OIDC it is the token subject (sub); for the static API key it is api-key; for a per-agent key it is the key's id. Omitted for stdio and other unauthenticated transports, unless DB_MCP_AUDIT_PRINCIPAL labels them.
  • session: the MCP session ID, when the transport has one (Streamable HTTP). It is written to the owner-only (0600) audit file. Omitted otherwise.
  • rows: the number of rows shown for a query, capped at max_rows when the result is truncated (a query matching 100 rows with max_rows=3 records rows: 3); rows affected for an execute; rows affected for a transaction execute, counted before commit, so a later rollback does not change the recorded count. Omitted when the statement failed or the engine did not report a count.
  • tool: the MCP tool name of the call, such as query or execute. Written for calls that come through Streamable HTTP; stdio and SSE calls do not carry it.
  • op: "denied": a call refused by a tool scope, or by an agent key's database allowlist, before it reached the database. error holds the reason and rows is omitted. Written only for Streamable HTTP.

Example line (placeholder values):

{"ts":"2026-11-18T10:15:30.123456789Z","op":"query","database":"app","statement":"SELECT id FROM orders LIMIT 5","duration_ms":1.234,"principal":"user@example.com","session":"mcp-session-example","rows":5}

Defense in depth: read-only is best-effort and is not a guarantee. The layers are the application check, engine session defaults (not a security boundary on their own), and the database user's privileges. For strong guarantees, connect with a database account that only has SELECT privileges.

The production controls guide, with the agent keys file format, the authorization rules and a worked pilot example, is in docs/governance.md.

Supported Databases

Database Status Features
MySQL ✅ Full Support Queries, Transactions, Schema Analysis, Performance Insights
PostgreSQL ✅ Full Support (v9.6-17) Queries, Transactions, Schema Analysis, Performance Insights
SQLite ✅ Full Support File-based & In-memory databases, SQLCipher encryption support
Oracle ✅ Full Support (10g-23c) Queries, Transactions, Schema Analysis, RAC, Cloud Wallet, TNS
TimescaleDB ✅ Full Support Time-Series Queries, Hypertable Discovery (write policies via SQL)

Deployment and transport status

The safest local integration is STDIO. HTTP transports are still under hardening; do not expose the current server directly to a shared network.

Personal/local STDIO (recommended)
# Build from the audited source revision
make build

# Use a private, single-connection config
./bin/server -t stdio -c /absolute/path/to/config.local.json

For Cursor, point the client at the actual build output and use absolute paths:

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

Use a read-only database account and a bounded query_timeout for a personal PostgreSQL/MySQL connection. For SQLite, use an absolute database_path and "read_only": true when the agent only needs to inspect data.

Legacy SSE (compatibility only)

The historical Cortex SSE transport has no built-in authentication. It is disabled by default and must only be enabled explicitly behind a trusted private reverse proxy:

./bin/server -t sse -h 127.0.0.1 -p 9092 \
  -allow-insecure-sse -c /absolute/path/to/config.local.json

Do not use this mode for a shared deployment. The legacy endpoint does not apply the API key (DB_MCP_API_KEY, DB_MCP_API_KEY_FILE, or -api-key); terminate TLS, authentication, and network policy at the proxy. A future release will replace it with a maintained Streamable HTTP implementation.

Streamable HTTP (experimental)

The streamable endpoint is backed by the maintained Go MCP SDK and supports stateful sessions, JSON or SSE responses, notifications, GET/DELETE session lifecycle, and JSON-RPC dispatch. The process refuses to start it without an API key; keep it behind a private TLS gateway until the identity and conformance rollout is complete.

Provide the key through exactly one source: DB_MCP_API_KEY, DB_MCP_API_KEY_FILE, or the -api-key flag. Setting more than one is a startup error. The flag is visible in the process list, so it logs a warning; prefer the file or env var. Use the file form with Docker or Kubernetes secrets:

# Docker secret mounted at /run/secrets/db_mcp_api_key
docker run --rm -p 127.0.0.1:9092:9092 \
  -e TRANSPORT_MODE=streamable \
  -e DB_MCP_API_KEY_FILE=/run/secrets/db_mcp_api_key \
  -v "$(pwd)/config.local.json:/app/config.json:ro" \
  -v "$(pwd)/db_mcp_api_key:/run/secrets/db_mcp_api_key:ro" \
  db-mcp-server:local

The key file is read once at startup. A rotated Kubernetes or Docker secret takes effect only after the server restarts. The key is not read for the stdio or SSE transports, so a blank key or a missing key file does not stop them.

For browser-origin requests, set an explicit comma-separated allowlist:

MCP_ALLOWED_ORIGINS=https://agent.example.com

The SDK applies these request rules to the streamable endpoint:

  • When the server listens on a loopback address (the default -h 127.0.0.1), a request whose Host header is not a loopback name is rejected with 403.
  • Each MCP_ALLOWED_ORIGINS entry must be scheme://host[:port], with no path, query, fragment, or trailing slash. Invalid entries are logged and ignored, so browser requests from that origin still get 403.
  • A JSON Content-Type may carry parameters, such as application/json; charset=utf-8.

The built-in static bearer key is a bounded pilot mechanism. It grants db:read by default; set DB_MCP_API_SCOPES=db:read,db:write only for a trusted write client. db:admin is reserved for controlled administration. Set DB_MCP_OIDC_ISSUER and DB_MCP_OIDC_AUDIENCE to use OIDC discovery, JWKS signature validation, issuer/audience checks, and subject identity for shared deployments; database-specific scopes are still intentionally not enabled until that policy is defined.

Tool scopes

The scope a call needs is decided by the statement or operation it runs, not by the tool name alone:

Tool db:read db:write
query, query_<db> statement passes the SQL write guard as read-only statement is a write (DELETE, DROP, SELECT ... INTO, a stacked or data-modifying write, COPY, unknown verb)
explain, explain_<db> statement is read-only statement is a write (checked with or without analyze)
performance_<db> stats, slow_queries, engine_slow_queries, suggest, suggest_indexes, workload_suggestions, index_health, db_health reset, validate_suggestions, any other action
schema, describe, health, filter_tables, list_databases always never
timescaledb_* list_hypertables, get_compression_settings, get_retention_policy, list_continuous_aggregates, get_continuous_aggregate_info; time_series_query and analyze_time_series when the SQL they build is read-only every other operation, including unknown ones
execute*, transaction* never always

A call whose SQL, action, or operation is missing or not a string fails closed to db:write, as do unknown tool names. Arguments that are not a JSON object are rejected before the scope check. db:admin allows every tool. Stdio connections carry no token and are not scope-checked.

The SQL check is the textual classifier in internal/usecase/sql_guard.go. It is a best-effort gate, not a parser or a sandbox, so run read-scoped clients against a least-privilege database user.

Stdio is a trusted local mode. A stdio session carries no token, so it has no scope and no caller-level read-only flag: the READ ONLY transaction that a db:read grant gets on PostgreSQL and TimescaleDB applies only to authenticated callers. A database configured with read_only: true still runs its reads in that transaction. Give a stdio session only the database privileges you want the local agent to have.

Per-agent keys (DB_MCP_AGENT_KEYS_FILE)

Give each agent its own key, identity, scopes and database allowlist by pointing DB_MCP_AGENT_KEYS_FILE at a JSON list. Only SHA-256 digests are stored. Agent keys can call only the unified tools, so start the server with -unified-tools (there is no environment variable for it). With the file set and the flag off, the server refuses to start:

[
  {"id": "reporting-agent", "key_sha256": "<64 hex chars>", "scopes": ["db:read"], "databases": ["sales"]},
  {"id": "ops-agent", "key_sha256": "<64 hex chars>", "scopes": ["db:read", "db:write"], "databases": ["*"]}
]

Generate a random key for each agent, and store only its SHA-256 digest in the file. The key is the agent's bearer token, so give it to the agent and keep it out of the file:

KEY="$(openssl rand -hex 32)"                          # give this to the agent
printf '%s' "$KEY" | shasum -a 256 | cut -d' ' -f1     # put this in key_sha256

Keys do not expire. To rotate, generate a new key, replace the entry's key_sha256 (or add a new entry and remove the old one), and restart the server: the file is read only at startup.

  • scopes is required: one or more of db:read, db:write, db:admin.
  • databases is required and must be non-empty. List database ids from the config, or use "*" (alone or among other values) for every database. Matching is exact and case-sensitive; a missing or non-string database argument is denied.
  • The allowlist is per configured database, not per schema or table. A connection that can reach other schemas can reach them through SQL, so give each database a least-privilege DB user.
  • Scope and allowlist both apply to every call. An allowlisted key may call only the unified tools (query, execute, transaction, performance, explain, describe, health, schema, filter_tables) with a database argument; per-database tool names (query_<id>) are denied. TimescaleDB tools (timescaledb_*) are not in that list, so agent keys cannot use them. list_databases is always callable and lists only the databases in the key's allowlist ("*" lists all). The audit log records the entry id as the principal.
  • Discovery is not limited by the allowlist. tools/list returns the unified tool descriptions and the database parameter description, and both name every configured database id to any authenticated key. The allowlist controls which databases a key can use, not which ids it can see. Do not rely on database ids being secret.
  • Streamable HTTP only. With stdio or SSE the file is ignored: the server logs a warning and prints it to stderr (stdout carries MCP traffic).
  • Cannot be combined with OIDC. With streamable HTTP, setting DB_MCP_OIDC_ISSUER together with this file is a startup error.
  • DB_MCP_API_SCOPES applies only to the legacy key (DB_MCP_API_KEY or DB_MCP_API_KEY_FILE), never to agent keys. The legacy key, when also set, still works after the agent keys are checked, and it is the only key a streamable server needs when no agent keys file is set.

The server refuses to start on: invalid JSON; an unknown field (for example expires_at, since keys do not expire); data after the list; an empty file ([]); a missing or empty scopes or databases; a missing, blank or whitespace-padded id; a duplicate id or key_sha256; a key_sha256 that is not 64 hex characters or is the SHA-256 of the empty string; an unknown scope; and the file set without -unified-tools. Errors name the entry id, never the key.

Docker image

The image defaults to the authenticated Streamable HTTP transport (TRANSPORT_MODE=streamable). It refuses to start without DB_MCP_API_KEY, DB_MCP_API_KEY_FILE, DB_MCP_AGENT_KEYS_FILE, or OIDC configuration, and the container exits non-zero with an authentication error otherwise. It runs as an unprivileged user, omits an embedded config (mount one at /app/config.json), and serves an unauthenticated /health probe on port 9093 in both HTTP modes.

# Build a local image from this source revision
docker build -t db-mcp-server:local .

# Default: Streamable HTTP. Export the key in your shell; it is passed through, not written to disk.
docker run --rm -p 127.0.0.1:9092:9092 -p 127.0.0.1:9093:9093 \
  -e DB_MCP_API_KEY \
  -v "$(pwd)/config.local.json:/app/config.json:ro" \
  db-mcp-server:local

Agent keys need the unified tools, and the image's default command does not pass -unified-tools. Override the command so the server gets the flag:

docker run --rm -p 127.0.0.1:9092:9092 -p 127.0.0.1:9093:9093 \
  -e DB_MCP_AGENT_KEYS_FILE=/app/agent-keys.json \
  -v "$(pwd)/config.local.json:/app/config.json:ro" \
  -v "$(pwd)/agent-keys.json:/app/agent-keys.json:ro" \
  db-mcp-server:local /app/server -t streamable -h 0.0.0.0 -p 9092 -c /app/config.json -unified-tools

Legacy SSE has no built-in authentication. It runs only when both variables are set explicitly, and only on a private network behind a trusted proxy:

docker run --rm -p 127.0.0.1:9092:9092 -p 127.0.0.1:9093:9093 \
  -e TRANSPORT_MODE=sse -e ALLOW_INSECURE_SSE=true \
  -v "$(pwd)/config.local.json:/app/config.json:ro" \
  db-mcp-server:local

The image is a development and demo artifact, not a hardened public image. For a team deployment, put the Streamable endpoint behind a TLS/OIDC gateway with a private network and an external secret store.

Source Code Installation

Building from source requires Go 1.25 or newer (go.mod sets go 1.25.0). CI and the published Docker and npm release builds use Go 1.26.

# Clone the repository
git clone https://github.com/FreePeak/db-mcp-server.git
cd db-mcp-server

# Build the server
make build

# Run the server
./bin/server -t stdio -c config.json

Configuration

Database Configuration File

Create a config.json file with your database connections. schema_version: 1 enables strict unknown-field validation:

{
  "schema_version": 1,
  "connections": [
    {
      "id": "mysql1",
      "type": "mysql",
      "host": "mysql1",
      "port": 3306,
      "name": "db1",
      "user": "user1",
      "password_env": "DB_MCP_MYSQL_PASSWORD",
      "query_timeout": 60,
      "max_open_conns": 20,
      "max_idle_conns": 5,
      "conn_max_lifetime_seconds": 300,
      "conn_max_idle_time_seconds": 60,
      "read_only": false,
      "max_rows": 1000,
      "masking_rules": [
        { "pattern": "(?i)email", "strategy": "fixed_string", "value": "***MASKED***" },
        { "pattern": "(?i)(ssn|tax_id)", "strategy": "null" }
      ]
    },
    {
      "id": "postgres1",
      "type": "postgres",
      "host": "postgres1",
      "port": 5432,
      "name": "db1",
      "user": "user1",
      "password_env": "DB_MCP_POSTGRES_PASSWORD"
    },
    {
      "id": "sqlite_app",
      "type": "sqlite",
      "database_path": "./data/app.db",
      "journal_mode": "WAL",
      "cache_size": 2000,
      "read_only": false,
      "use_modernc_driver": true,
      "query_timeout": 30,
      "max_open_conns": 1,
      "max_idle_conns": 1
    },
    {
      "id": "sqlite_encrypted",
      "type": "sqlite",
      "database_path": "./data/secure.db",
      "encryption_key": "your-secret-key-here",
      "journal_mode": "WAL",
      "use_modernc_driver": false
    },
    {
      "id": "sqlite_memory",
      "type": "sqlite",
      "database_path": ":memory:",
      "cache_size": 1000,
      "use_modernc_driver": true
    }
  ]
}
Secret references

Do not put production credentials directly in JSON. Use either an environment variable name or a mounted secret file per connection:

{
  "id": "prod",
  "type": "postgres",
  "host": "db.internal",
  "port": 5432,
  "name": "app",
  "user": "mcp_reader",
  "password_env": "DB_MCP_PROD_PASSWORD"
}

password_file and encryption_key_env/encryption_key_file are also supported. Relative file paths resolve from the config file directory; an inline value cannot be combined with a reference. The resolved value stays in process memory and is not printed by the config loader.

Command-Line Options
# Basic syntax
./bin/server -t <transport> -c <config-file>

# HTTP transport options (legacy SSE requires an explicit opt-in)
./bin/server -t sse -h <hostname> -p <port> -allow-insecure-sse -c <config-file>

# Lazy loading mode (recommended for 10+ databases)
./bin/server -t stdio -c <config-file> --lazy-loading

# Customize log directory (useful for multi-project setups)
./bin/server -t stdio -c <config-file> -log-dir /tmp/db-mcp-logs

# Inline database configuration
./bin/server -t stdio -db-config '{"connections":[...]}'

# Environment variable configuration
export DB_CONFIG='{"connections":[...]}'
./bin/server -t stdio

# Print the build version
./bin/server --version

# Upgrade to the latest published release (verifies SHA-256, swaps the binary)
./bin/server update
./bin/server update -check          # only report whether a newer release exists
./bin/server update -version 1.13.0 # install a specific release

Available Flags:

  • -t, -transport: Transport mode (stdio, legacy sse, or experimental streamable)
  • -c, -config: Path to database configuration file
  • -p, -port: HTTP port (default: 9092)
  • -h, -host: HTTP bind host (default: 127.0.0.1)
  • --version: Print the build version and exit
  • -allow-insecure-sse: Explicitly allow legacy SSE for a private development proxy
  • -api-key: Bearer key for the experimental Streamable HTTP entrypoint. Visible in the process list and logs a warning; prefer DB_MCP_API_KEY_FILE or DB_MCP_API_KEY
  • -log-level: Log level (debug, info, warn, error)
  • -log-dir: Directory for log files (default: ./logs in current directory)
  • -db-config: Inline JSON database configuration
  • -lazy-loading: Establish connections on first use
  • -unified-tools: Register one tool set with a database parameter

Updating: db-mcp-server update resolves the latest GitHub release, checks the download against the release's SHA256SUMS manifest, and replaces the running binary in place (the previous binary is left untouched if verification fails). It installs the asset matching your OS and architecture, restart the server afterwards. On Windows a running executable cannot be replaced, so update through the npm installer there. -check reports without downloading; -force reinstalls the current version.

Environment Variables

Values in a .env file are loaded first; real environment variables take precedence. A JSON config file (CONFIG_PATH/DB_CONFIG_FILE) takes precedence over inline and legacy database variables.

Variable Default Purpose
CONFIG_PATH / DB_CONFIG_FILE config.json Path to the multi-database JSON config
DB_CONFIG , Inline JSON database configuration (used when no file is present)
TRANSPORT_MODE stdio (Docker image: streamable) Transport mode when -t is not passed
SERVER_PORT 9092 HTTP port
MCP_ALLOWED_ORIGINS empty Comma-separated browser origins allowed by experimental Streamable HTTP
DB_MCP_API_KEY empty Bearer key for experimental Streamable HTTP; keep it in a secret manager
DB_MCP_API_KEY_FILE empty Path to a file holding the Bearer key (trailing newline trimmed; an empty or whitespace-only file is an error). Use for Docker/Kubernetes secrets
ALLOW_INSECURE_SSE unset Docker image only: true passes -allow-insecure-sse so TRANSPORT_MODE=sse can start
DB_MCP_API_SCOPES db:read Required/granted scopes: db:read, db:write, and/or db:admin
DB_MCP_AGENT_KEYS_FILE empty JSON file of per-agent key digests, scopes and database allowlists (see above)
DB_MCP_OIDC_ISSUER empty OIDC issuer URL; when set, OIDC/JWT verification replaces the static pilot key
DB_MCP_OIDC_AUDIENCE empty Required OIDC audience/client ID
DB_MCP_RESOURCE_URL empty Public URL of /mcp (for example https://db.example.com/mcp); with DB_MCP_OIDC_ISSUER it serves OAuth protected resource metadata (RFC 9728) so MCP clients can discover the identity provider
LOG_LEVEL info Log verbosity (debug, info, warn, error)
DISABLE_LOGGING false true/1 silences logging entirely
DB_TYPE, DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME engine defaults Single-database fallback when no JSON config exists
QUERY_TIMEOUT_SECONDS unset Fills connections that don't set their own query_timeout; negative disables the cap. JSON configs keep precedence.
DB_MCP_AUDIT_LOG unset Optional append-only JSONL audit path
DB_MCP_AUDIT_PRINCIPAL unset Principal recorded for audit records with no authenticated caller (stdio sessions); a token principal always wins
DB_MCP_AUDIT_REQUIRED unset true/1 makes startup fail unless DB_MCP_AUDIT_LOG is set and its file can be opened
VERBOSE unset true/1 sets the startup log level to debug (the default is error, i.e. silent unless LOG_LEVEL is set)
MCP_DISABLE_LOGGING unset true/1 discards MCP protocol logs (writer-level switch, independent of LOG_LEVEL/DISABLE_LOGGING)

SQLite Configuration Options

When using SQLite databases, you can leverage these additional configuration options:

SQLite Connection Parameters
Parameter Type Default Description
database_path string Required Path to SQLite database file or :memory: for in-memory
encryption_key string - Key for SQLCipher encrypted databases
read_only boolean false Open database in read-only mode
max_rows integer unlimited Maximum rows returned per query; larger results are truncated with an explicit notice. Works on all database types; the query tool also caps the query server-side (see Production Guardrails).
cache_size integer 2000 SQLite cache size in pages
journal_mode string "WAL" Journal mode: DELETE, TRUNCATE, PERSIST, WAL, OFF
use_modernc_driver boolean true Use modernc.org/sqlite (CGO-free) or mattn/go-sqlite3
SQLite Examples
Basic File Database
{
  "id": "my_sqlite_db",
  "type": "sqlite",
  "database_path": "./data/myapp.db",
  "journal_mode": "WAL",
  "cache_size": 2000
}
Encrypted Database (SQLCipher)
{
  "id": "encrypted_db",
  "type": "sqlite",
  "database_path": "./data/secure.db",
  "encryption_key": "your-secret-encryption-key",
  "use_modernc_driver": false
}
In-Memory Database
{
  "id": "memory_db",
  "type": "sqlite",
  "database_path": ":memory:",
  "cache_size": 1000
}
Read-Only Database
{
  "id": "reference_data",
  "type": "sqlite",
  "database_path": "./data/reference.db",
  "read_only": true,
  "journal_mode": "DELETE"
}

Oracle Configuration Options

When using Oracle databases, you can leverage these additional configuration options:

Read the rest of the FreePeak DB README on GitHub

Questions about FreePeak DB

What is the FreePeak DB MCP server?

A powerful multi-database server implementing the Model Context Protocol (MCP) to provide AI assistants with structured access to databases. FreePeak DB is maintained by FreePeak on GitHub at FreePeak/db-mcp-server, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the FreePeak DB MCP server?

FreePeak DB doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (FreePeak/db-mcp-server). Like most servers, FreePeak DB ends with a command or URL you paste into your AI app's MCP config.

Does FreePeak DB need an API key?

The registry lists no required keys for FreePeak DB. Check the FreePeak DB README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is FreePeak DB an official MCP server?

No. FreePeak DB is a community server maintained by FreePeak. Community servers can be excellent; read the code and the open issues before you give FreePeak DB access to company data.

What license is FreePeak DB under?

FreePeak DB is released under the MIT license, according to its GitHub repository. The license covers the code of FreePeak DB; the service it connects to has its own terms.