DB MCP Server

Registre officiel Données et bases de données

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

Installation

Ajoutez ceci à la configuration MCP de votre client (Claude Desktop : claude_desktop_config.json ; Cursor : .cursor/mcp.json ; VS Code et les autres utilisent la même forme « mcpServers »).

PYPI package db-mcp-server
Claude Code
claude mcp add db-mcp-server -e 'DB_TYPE=<DB_TYPE>' -e 'DB_DATABASE=<DB_DATABASE>' -e 'DB_MODE=read-only' -e 'DB_HOST=localhost' -e 'DB_PORT=<DB_PORT>' -e 'DB_USER=<DB_USER>' -e 'DB_PASSWORD=<your db_password>' -e 'DB_URL=<your db_url>' -e 'SSH_HOST=<SSH_HOST>' -e 'SSH_PORT=22' -e 'SSH_USER=<SSH_USER>' -e 'SSH_KEY=<SSH_KEY>' -e 'SSH_PASSWORD=<your ssh_password>' -- uvx db-mcp-server==1.2.1
Configuration JSON (Claude Desktop, Cursor, VS Code)
{
    "mcpServers": {
        "db-mcp-server": {
            "command": "uvx",
            "args": [
                "db-mcp-server==1.2.1"
            ],
            "env": {
                "DB_TYPE": "<DB_TYPE>",
                "DB_DATABASE": "<DB_DATABASE>",
                "DB_MODE": "read-only",
                "DB_HOST": "localhost",
                "DB_PORT": "<DB_PORT>",
                "DB_USER": "<DB_USER>",
                "DB_PASSWORD": "<your db_password>",
                "DB_URL": "<your db_url>",
                "SSH_HOST": "<SSH_HOST>",
                "SSH_PORT": "22",
                "SSH_USER": "<SSH_USER>",
                "SSH_KEY": "<SSH_KEY>",
                "SSH_PASSWORD": "<your ssh_password>"
            }
        }
    }
}

Variables d'environnement

  • DB_TYPE obligatoire Database type
  • DB_DATABASE obligatoire Database name
  • DB_MODE Access mode
  • DB_HOST Database host (MySQL/PostgreSQL)
  • DB_PORT Database port (MySQL: 3306, PostgreSQL: 5432)
  • DB_USER Database user (MySQL default: root, PostgreSQL default: postgres)
  • DB_PASSWORD secret Database password (MySQL/PostgreSQL, optional)
  • DB_URL secret MongoDB connection URL (required for MongoDB, e.g. mongodb://...)
  • SSH_HOST SSH bastion host for tunneling (MySQL/PostgreSQL only)
  • SSH_PORT SSH port
  • SSH_USER SSH username (default: current OS user)
  • SSH_KEY Path to SSH private key (e.g. ~/.ssh/id_rsa)
  • SSH_PASSWORD secret SSH password (if no key provided)

Documentation

Tirée du README du projet sur GitHub, actualisée chaque semaine. Les liens ouvrent GitHub.

Sommaire
  1. db-mcp-server
  2. Installation
  3. Configuration
  4. Usage in .mcp.json
  5. Tools
  6. License

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

Questions fréquentes

Qu'est-ce que DB MCP Server ?

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

Comment installer DB MCP Server ?

Il s'exécute sur votre machine. Dans Claude Code : claude mcp add db-mcp-server -e 'DB_TYPE=<DB_TYPE>' -e 'DB_DATABASE=<DB_DATABASE>' -e 'DB_MODE=read-only' -e 'DB_HOST=localhost' -e 'DB_PORT=<DB_PORT>' -e 'DB_USER=<DB_USER>' -e 'DB_PASSWORD=<your db_password>' -e 'DB_URL=<your db_url>' -e 'SSH_HOST=<SSH_HOST>' -e 'SSH_PORT=22' -e 'SSH_USER=<SSH_USER>' -e 'SSH_KEY=<SSH_KEY>' -e 'SSH_PASSWORD=<your ssh_password>' -- uvx db-mcp-server==1.2.1. Pour les autres clients, collez la configuration JSON de cette page dans leurs réglages MCP.

Faut-il une clé API pour DB MCP Server ?

Oui. Il attend DB_TYPE, DB_DATABASE, DB_PASSWORD, DB_URL, SSH_PASSWORD, à renseigner dans sa configuration.

DB MCP Server est-il open source ?

Oui. Son code est sur GitHub sous licence MIT.

Qui maintient DB MCP Server ?

Il est publié par stucchi. AI.tn le référence sans le maintenir ni le recommander.

Issu du registre MCP officiel. Être listé n'est pas une recommandation : vérifiez le code et les permissions d'un serveur avant de lui donner accès à vos données.