Back to Browse

Db MCP Server

Developer ToolsLow Risk10.0MCP RegistryLocal
Free

Server data from the Official MCP Registry

Database MCP server for MySQL, PostgreSQL, MongoDB, and SQLite with SSH tunneling support.

About

Database MCP server for MySQL, PostgreSQL, MongoDB, and SQLite with SSH tunneling support.

Security Report

10.0
Low Risk10.0Low Risk

Valid MCP server (1 strong, 4 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry. Trust signals: trusted author (9/9 approved).

12 files analyzed · 1 issue found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

file_system

Check that this permission is expected for this type of plugin.

database

Check that this permission is expected for this type of plugin.

env_vars

Check that this permission is expected for this type of plugin.

HTTP Network Access

Connects to external APIs or services over the internet.

What You'll Need

Set these up before or after installing:

Database typeOptional

Environment variable: DB_TYPE

Database nameOptional

Environment variable: DB_DATABASE

Access modeOptional

Environment variable: DB_MODE

Database host (MySQL/PostgreSQL)Optional

Environment variable: DB_HOST

Database port (MySQL: 3306, PostgreSQL: 5432)Optional

Environment variable: DB_PORT

Database user (MySQL default: root, PostgreSQL default: postgres)Optional

Environment variable: DB_USER

Database password (MySQL/PostgreSQL, optional)Required

Environment variable: DB_PASSWORD

MongoDB connection URL (required for MongoDB, e.g. mongodb://...)Required

Environment variable: DB_URL

SSH bastion host for tunneling (MySQL/PostgreSQL only)Optional

Environment variable: SSH_HOST

SSH portOptional

Environment variable: SSH_PORT

SSH username (default: current OS user)Optional

Environment variable: SSH_USER

Path to SSH private key (e.g. ~/.ssh/id_rsa)Optional

Environment variable: SSH_KEY

SSH password (if no key provided)Required

Environment variable: SSH_PASSWORD

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "io-github-stucchi-db": {
      "args": [
        "db-mcp-server"
      ],
      "command": "uvx"
    }
  }
}

Documentation

View on GitHub

From the project's GitHub 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_TYPEYesmysql
DB_DATABASEYesDatabase name
DB_PASSWORDYesPassword
DB_HOSTNolocalhostHost
DB_PORTNo3306Port
DB_USERNorootUser
DB_MODENoread-onlyread-only or read-write

PostgreSQL

VariableRequiredDefaultDescription
DB_TYPEYespostgresql
DB_DATABASEYesDatabase name
DB_PASSWORDYesPassword
DB_HOSTNolocalhostHost
DB_PORTNo5432Port
DB_USERNopostgresUser
DB_MODENoread-onlyread-only or read-write

MongoDB

VariableRequiredDefaultDescription
DB_TYPEYesmongodb
DB_DATABASEYesDatabase name
DB_URLYesConnection URL (mongodb://...)
DB_MODENoread-onlyread-only or read-write

SQLite

VariableRequiredDefaultDescription
DB_TYPEYessqlite
DB_PATHYesPath 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_HOSTNoSSH bastion host (activates tunneling)
SSH_PORTNo22SSH port
SSH_USERNoCurrent OS userSSH username
SSH_KEYNoPath to private key (~/.ssh/id_rsa)
SSH_PASSWORDNoSSH 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

Reviews

No reviews yet

Be the first to review this server!