Skip to main content

MCP server for MySQL, PostgreSQL, and MongoDB databases — one instance per database, no Docker required

Project description

db-mcp-server

MCP server for MySQL, PostgreSQL, and MongoDB databases. One instance per database, no Docker required.

Installation

uvx db-mcp-server

Configuration

Configure via environment variables. Each instance connects to a single database.

MySQL

Variable Required Default Description
DB_TYPE Yes mysql
DB_DATABASE Yes Database name
DB_PASSWORD Yes Password
DB_HOST No localhost Host
DB_PORT No 3306 Port
DB_USER No root User
DB_MODE No read-only read-only or read-write

PostgreSQL

Variable Required Default Description
DB_TYPE Yes postgresql
DB_DATABASE Yes Database name
DB_PASSWORD Yes Password
DB_HOST No localhost Host
DB_PORT No 5432 Port
DB_USER No postgres User
DB_MODE No read-only read-only or read-write

MongoDB

Variable Required Default Description
DB_TYPE Yes mongodb
DB_DATABASE Yes Database name
DB_URL Yes Connection URL (mongodb://...)
DB_MODE No read-only read-only or read-write

SSH Tunnel (MySQL / PostgreSQL)

Optionally connect through an SSH bastion host. Set SSH_HOST to activate.

Variable Required Default Description
SSH_HOST No SSH bastion host (activates tunneling)
SSH_PORT No 22 SSH port
SSH_USER No Current OS user SSH username
SSH_KEY No Path to private key (~/.ssh/id_rsa)
SSH_PASSWORD No SSH password (if no key)

At least one of SSH_KEY or SSH_PASSWORD is required when SSH_HOST is set. SSH tunneling is not supported for MongoDB.

Usage in .mcp.json

{
  "mcpServers": {
    "db-prod": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": {
        "DB_TYPE": "mysql",
        "DB_MODE": "read-only",
        "DB_HOST": "db.example.com",
        "DB_PORT": "3306",
        "DB_USER": "root",
        "DB_PASSWORD": "secret",
        "DB_DATABASE": "myapp"
      }
    }
  }
}

With SSH tunnel

{
  "mcpServers": {
    "db-behind-bastion": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": {
        "DB_TYPE": "postgresql",
        "DB_HOST": "10.0.0.5",
        "DB_PORT": "5432",
        "DB_USER": "postgres",
        "DB_PASSWORD": "secret",
        "DB_DATABASE": "myapp",
        "SSH_HOST": "bastion.example.com",
        "SSH_USER": "deploy",
        "SSH_KEY": "~/.ssh/id_rsa"
      }
    }
  }
}

For multiple databases, add multiple instances:

{
  "mcpServers": {
    "db-prod": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": { "DB_TYPE": "mysql", "DB_DATABASE": "prod", "..." : "..." }
    },
    "db-analytics": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": { "DB_TYPE": "postgresql", "DB_DATABASE": "analytics", "..." : "..." }
    },
    "db-staging": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": { "DB_TYPE": "mongodb", "DB_DATABASE": "staging", "..." : "..." }
    }
  }
}

Tools

MySQL

  • query — Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH)
  • execute — Execute write SQL (INSERT, UPDATE, DELETE) — requires DB_MODE=read-write
  • describe — Describe table structure
  • list_tables — List all tables
  • status — Show connection info

PostgreSQL

  • query — Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH)
  • execute — Execute write SQL (INSERT, UPDATE, DELETE) — requires DB_MODE=read-write
  • describe — Describe table structure (column info from information_schema)
  • list_tables — List all tables in the public schema
  • status — Show connection info

MongoDB

  • query — Find documents in a collection
  • describe — Collection stats ($collStats)
  • list_collections — List all collections
  • aggregate — Execute aggregation pipelines ($out/$merge blocked on read-only)
  • status — Show connection info

License

MIT

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

db_mcp_server-1.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

db_mcp_server-1.1.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file db_mcp_server-1.1.1.tar.gz.

File metadata

  • Download URL: db_mcp_server-1.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for db_mcp_server-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a02ab2dba4e20efc9ee58fe2ecbfbd5d6ca2aa4e3472a9b2d8f3768c13a32619
MD5 20b0b2bec3e3d5fd581b6103e2521c0f
BLAKE2b-256 168dee0ad14535e0e3a77ea21799e1fde0716a7aec946dfdbb11b5fbb0daf612

See more details on using hashes here.

File details

Details for the file db_mcp_server-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: db_mcp_server-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for db_mcp_server-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb91505960b0f271c714528bc20fbe58fdfdd393264b58f83aab6973c198b9ac
MD5 3eeb4e698033fc871005c96a43dc0787
BLAKE2b-256 92909d2e29daec43b4e3f5094c432385a8d457be207482365b95726495eabdbc

See more details on using hashes here.

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