Multi-database MCP server with SSH tunnels, read-only mode, and schema filtering
Project description
db-mcp-py
Multi-database MCP server with built-in SSH tunnels, read-only mode, and schema filtering.
Credits & References
This project is a Python reimplementation inspired by FreePeak/db-mcp-server (Go, MIT License, 372+ stars). The original project provides multi-database MCP support for MySQL, PostgreSQL, SQLite, Oracle, and TimescaleDB.
Why rewrite? We needed features the upstream doesn't provide and the solo-maintainer project has slow response times:
- Built-in SSH tunnel management (jump hosts, port forwarding)
- Read-only mode by default (no accidental writes)
- Schema filtering (whitelist specific schemas per connection)
- Environment variable expansion in config
- Graceful degradation (if 1 of N databases is unreachable, serve the rest)
- VPN/network detection before connecting
- Python ecosystem integration (uvx, PyPI, MCP SDK)
Features
- Multi-database: Connect to N PostgreSQL databases simultaneously
- SSH tunnels: Built-in asyncssh tunnels with jump host support — no external scripts needed
- Read-only: Only
queryandschematools exposed. Noexecute,transaction, or DDL - Schema filtering: Per-connection
schemaswhitelist — only expose relevant tables - Env var expansion: Use
${DB_PASSWORD},${HOME}etc. in config - Graceful degradation: Unreachable databases are skipped, rest keeps working
- Network detection: Optional VPN check before attempting connections
- Reconnect: Automatic retry on connection loss with exponential backoff
- Unified tools: Single
querytool withdatabaseparameter (inspired by FreePeak v1.9.0)
Installation
# Via uvx (recommended)
uvx db-mcp-py --config config.json
# Via pip
pip install db-mcp-py
db-mcp-py --config config.json
Configuration
{
"defaults": {
"read_only": true,
"query_timeout": 30,
"max_connections": 5
},
"connections": [
{
"id": "mir_dev",
"host": "10.202.171.138",
"port": 5433,
"database": "p9scdevmir",
"user": "mir_intranet",
"password": "${MIR_DEV_PASSWORD}",
"schemas": ["mir", "public"],
"require_vpn": true
},
{
"id": "sicar_dev",
"host": "localhost",
"port": 5433,
"database": "car_nacional",
"user": "car_nacional",
"schemas": ["usr_geocar_aplicacao"],
"tunnel": {
"ssh_host": "coreapi-sicar-dev",
"remote_host": "localhost",
"remote_port": 5433,
"local_port": 5435
}
},
{
"id": "coreapi_dev",
"host": "localhost",
"port": 5433,
"database": "pgsc_dev_coreapi",
"user": "postgres",
"tunnel": {
"ssh_host": "coreapi-db-dev",
"remote_host": "localhost",
"remote_port": 5433,
"local_port": 5434
}
}
]
}
Tunnel with jump host
{
"tunnel": {
"ssh_host": "target-server",
"jump_host": "bastion.example.com",
"remote_host": "localhost",
"remote_port": 5433,
"local_port": 5435
}
}
MCP Tools
| Tool | Description |
|---|---|
list_databases |
List all connected databases with status |
query |
Execute read-only SQL query on a database |
schema |
Get table/column information for a database |
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file db_mcp_py-0.1.0.tar.gz.
File metadata
- Download URL: db_mcp_py-0.1.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bdc84106095c93515d8ac5ed056a77a2eed74b50c168432202f4d7a4446ef5d
|
|
| MD5 |
1cd5a6a9c92c64b2171432ed80626499
|
|
| BLAKE2b-256 |
67f8bfaecea3812123548e730145a0e3eb27c14f30fc1aca84aa6088a04a85fb
|
File details
Details for the file db_mcp_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: db_mcp_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87fe23528405a89fab4d64a10950aa451d407105834b5cb68b94b4ecb0b1806d
|
|
| MD5 |
a65c35975966b570cf3c54c693b2b33e
|
|
| BLAKE2b-256 |
e195b1d085f0ec8e85a2cad21c30e60f86cd04e345a157dadb52c5c1a834db0f
|