mcpField
D
DB MCP Server

DB MCP Server

Local
github.com/stucchiDatabases2Updated 31w ago

About DB MCP Server

DB MCP Server connects an MCP client to one MySQL, PostgreSQL, MongoDB, or SQLite database per instance. It provides query and schema tools, with optional write access and SSH tunneling for supported databases.

Key features

  1. 01MySQL, PostgreSQL, MongoDB, and SQLite support
  2. 02Database queries and schema inspection
  3. 03Optional read-write mode
  4. 04SSH tunneling for MySQL and PostgreSQL
  5. 05SQLite access over SSH

Use cases

  1. 01Query a database from an MCP client
  2. 02Inspect tables or collections
  3. 03Connect to databases behind an SSH bastion

MCP support

The server exposes database query, schema, listing, and status tools to MCP clients; write tools are available when configured for read-write mode. Each instance connects to a single database.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"stucchi-db": {
"command": "uvx",
"args": [
"db-mcp-server"
],
"env": {
"DB_TYPE": "<DB_TYPE>",
"DB_DATABASE": "<DB_DATABASE>",
"DB_MODE": "<DB_MODE>",
"DB_HOST": "<DB_HOST>",
"DB_PORT": "<DB_PORT>",
"DB_USER": "<DB_USER>",
"DB_PASSWORD": "<DB_PASSWORD>",
"DB_URL": "<DB_URL>",
"SSH_HOST": "<SSH_HOST>",
"SSH_PORT": "<SSH_PORT>",
"SSH_USER": "<SSH_USER>",
"SSH_KEY": "<SSH_KEY>",
"SSH_PASSWORD": "<SSH_PASSWORD>"
}
}
}
}
Run commanduvx db-mcp-server
Environment variables to set
DB_TYPEDatabase type
DB_DATABASEDatabase name
DB_MODEAccess mode
DB_HOSTDatabase host (MySQL/PostgreSQL)
DB_PORTDatabase port (MySQL: 3306, PostgreSQL: 5432)
DB_USERDatabase user (MySQL default: root, PostgreSQL default: postgres)
DB_PASSWORDSecretDatabase password (MySQL/PostgreSQL, optional)
DB_URLSecretMongoDB connection URL (required for MongoDB, e.g. mongodb://...)
SSH_HOSTSSH bastion host for tunneling (MySQL/PostgreSQL only)
SSH_PORTSSH port
SSH_USERSSH username (default: current OS user)
SSH_KEYSecretPath to SSH private key (e.g. ~/.ssh/id_rsa)
SSH_PASSWORDSecretSSH password (if no key provided)

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
pypidb-mcp-server1.2.1

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

db-mcp-server

MCP server for MySQL, PostgreSQL, MongoDB, and SQLite 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
VariableRequiredDefaultDescription
DB_TYPEYes—mysql
DB_DATABASEYes—Database name
DB_PASSWORDYes—Password
DB_HOSTNolocalhostHost
DB_PORTNo3306Port
DB_USERNorootUser
DB_MODENoread-onlyread-only or read-write
PostgreSQL
VariableRequiredDefaultDescription
DB_TYPEYes—postgresql
DB_DATABASEYes—Database name
DB_PASSWORDYes—Password
DB_HOSTNolocalhostHost
DB_PORTNo5432Port
DB_USERNopostgresUser
DB_MODENoread-onlyread-only or read-write
MongoDB
VariableRequiredDefaultDescription
DB_TYPEYes—mongodb
DB_DATABASEYes—Database name
DB_URLYes—Connection URL (mongodb://...)
DB_MODENoread-onlyread-only or read-write
SQLite
VariableRequiredDefaultDescription
DB_TYPEYes—sqlite
DB_PATHYes—Path to .db file (local or remote with SSH)
DB_DATABASENofilenameDisplay name
DB_MODENoread-onlyread-only or read-write
SSH Tunnel (MySQL / PostgreSQL)

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

For SQLite over SSH, the remote .db file is downloaded via SFTP before querying. In read-write mode, changes are uploaded back on shutdown.

VariableRequiredDefaultDescription
SSH_HOSTNo—SSH bastion host (activates tunneling)
SSH_PORTNo22SSH port
SSH_USERNoCurrent OS userSSH username
SSH_KEYNo—Path to private key (~/.ssh/id_rsa)
SSH_PASSWORDNo—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

SQLite (local)
{
  "mcpServers": {
    "db-local": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": {
        "DB_TYPE": "sqlite",
        "DB_PATH": "/path/to/database.db"
      }
    }
  }
}
SQLite over SSH
{
  "mcpServers": {
    "db-remote": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": {
        "DB_TYPE": "sqlite",
        "DB_PATH": "/remote/path/to/database.db",
        "SSH_HOST": "server.example.com",
        "SSH_USER": "deploy",
        "SSH_KEY": "~/.ssh/id_rsa"
      }
    }
  }
}
{
  "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
SQLite
  • 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 (PRAGMA table_info)
  • list_tables — List all tables
  • 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

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.