Server data from the Official MCP Registry
Multi-database MCP server for PostgreSQL, MySQL, and ClickHouse
Multi-database MCP server for PostgreSQL, MySQL, and ClickHouse
Valid MCP server (2 strong, 1 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry.
5 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.
This plugin requests these system permissions. Most are normal for its category.
Set these up before or after installing:
Environment variable: DATABASE_URL
Add this to your MCP configuration file:
{
"mcpServers": {
"io-github-yugui923-db-connect-mcp": {
"env": {
"DATABASE_URL": "your-database-url-here"
},
"args": [
"db-connect-mcp"
],
"command": "uvx"
}
}
}From the project's GitHub README.
A read-only MCP (Model Context Protocol) server for exploratory data analysis across multiple database systems. This server provides safe, read-only access to PostgreSQL, MySQL, and ClickHouse databases with comprehensive analysis capabilities.

Install:
pip install db-connect-mcp
Add to Claude Desktop claude_desktop_config.json:
{
"mcpServers": {
"db-connect": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
}
}
}
}
Restart Claude Desktop and start querying your database!
Note: Using
python -m db_connect_mcpensures the command works even if Python's Scripts directory isn't in your PATH.
Tip: db-connect-mcp works best with databases that have proper comments on tables and columns. When your database includes descriptive comments, the MCP server can provide richer context to AI assistants, leading to better understanding of your data model and more accurate query suggestions.
Adding comments in PostgreSQL:
COMMENT ON TABLE users IS 'Registered user accounts with profile information';
COMMENT ON COLUMN users.email IS 'Primary email address, used for authentication';
COMMENT ON COLUMN users.is_verified IS 'Whether email has been verified via confirmation link';
Adding comments in MySQL:
ALTER TABLE users COMMENT = 'Registered user accounts with profile information';
ALTER TABLE users MODIFY COLUMN email VARCHAR(255) COMMENT 'Primary email address, used for authentication';
The server automatically retrieves and displays these comments when describing tables, helping AI assistants understand the purpose and semantics of your data.
See the SSH Tunnel Guide for configuration details.
pip install db-connect-mcp
That's it! The package is now ready to use.
For developers: See Development Guide for setting up a development environment.
Create a .env file with your database connection string:
DATABASE_URL=your_database_connection_string_here
The server automatically detects the database type and adds appropriate read-only parameters.
The server now provides more flexible and secure URL handling:
jdbc:postgresql://... โ postgresql+asyncpg://...jdbc:mysql://... โ mysql+aiomysql://...jdbc:postgres://, jdbc:mariadb://)postgresql, postgres, pg, psql, pgsqlmysql, mariadb, mariaclickhouse, ch, clickPostgreSQL:
# Simple URL (driver automatically added)
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
# Common variations (all normalized to postgresql+asyncpg)
DATABASE_URL=postgres://user:pass@host:5432/db # Heroku, AWS RDS style
DATABASE_URL=pg://user:pass@host:5432/db # Short form
DATABASE_URL=psql://user:pass@host:5432/db # CLI style
# JDBC URLs (automatically converted)
DATABASE_URL=jdbc:postgresql://user:pass@host:5432/db # From Java apps
DATABASE_URL=jdbc:postgres://user:pass@host:5432/db # JDBC with variant
# With explicit async driver
DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/db
# With supported parameters (see list below)
DATABASE_URL=postgres://user:pass@host:5432/db?application_name=myapp&connect_timeout=10
Supported PostgreSQL Parameters:
application_name - Identifies your app in pg_stat_activity (useful for monitoring)connect_timeout - Connection timeout in secondscommand_timeout - Default timeout for operationsssl / sslmode - SSL connection requirements (automatically converted for asyncpg compatibility)server_settings - Server settings dictionaryoptions - Command-line options to send to serverprepared_statement_cache_size, max_cached_statement_lifetime, etc.MySQL/MariaDB:
# Simple URL (driver automatically added)
DATABASE_URL=mysql://root:password@localhost:3306/mydb
# MariaDB URLs (normalized to mysql+aiomysql)
DATABASE_URL=mariadb://user:pass@host:3306/db # MariaDB style
DATABASE_URL=maria://user:pass@host:3306/db # Short form
# JDBC URLs (automatically converted)
DATABASE_URL=jdbc:mysql://user:pass@host:3306/db # From Java apps
DATABASE_URL=jdbc:mariadb://user:pass@host:3306/db # JDBC MariaDB
# With explicit async driver
DATABASE_URL=mysql+aiomysql://user:pass@host:3306/db
# With charset (critical for proper Unicode support)
DATABASE_URL=mariadb://user:pass@remote.host:3306/db?charset=utf8mb4
Supported MySQL Parameters:
charset - Character encoding (e.g., utf8mb4) - critical for data integrityuse_unicode - Enable Unicode supportconnect_timeout, read_timeout, write_timeout - Various timeoutsautocommit - Transaction autocommit modeinit_command - Initial SQL command to runsql_mode - SQL mode settingstime_zone - Time zone settingClickHouse:
# Simple URL (driver automatically added)
DATABASE_URL=clickhouse://default:@localhost:9000/default
# Short forms (normalized to clickhouse+asynch)
DATABASE_URL=ch://user:pass@host:9000/db # Short form
DATABASE_URL=click://user:pass@host:9000/db # Alternative
# JDBC URLs (automatically converted)
DATABASE_URL=jdbc:clickhouse://user:pass@host:9000/db # From Java apps
DATABASE_URL=jdbc:ch://user:pass@host:9000/db # JDBC with short form
# With explicit async driver
DATABASE_URL=clickhouse+asynch://user:pass@host:9000/db
# With performance settings
DATABASE_URL=ch://user:pass@host:9000/db?timeout=60&max_threads=4
Supported ClickHouse Parameters:
database - Default database selectiontimeout, connect_timeout, send_receive_timeout - Various timeoutscompress, compression - Enable compressionmax_block_size, max_threads - Performance tuningNote:
ssl, sslmode) are automatically converted to the correct format for asyncpgsslcert, sslkey, sslrootcert) are filtered out as they can cause compatibility issues# Run the server (works everywhere, no PATH configuration needed)
python -m db_connect_mcp
# With environment variable
DATABASE_URL="postgresql://user:pass@host:5432/db" python -m db_connect_mcp
Note: Using
python -m db_connect_mcpworks regardless of whether Python's Scripts directory is in your PATH.
Add the MCP server to your project's .mcp.json:
claude mcp add --transport stdio db-connect --scope project \
--env DATABASE_URL=postgresql://user:pass@host:5432/db \
-- python -m db_connect_mcp
Or manually create .mcp.json in your project root. Below are examples for each supported database:
PostgreSQL:
{
"mcpServers": {
"db-connect-mcp": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "postgresql+asyncpg://user:pass@host:5432/mydb"
}
}
}
}
MySQL:
{
"mcpServers": {
"db-connect-mcp": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "mysql+aiomysql://user:pass@host:3306/mydb"
}
}
}
}
ClickHouse:
{
"mcpServers": {
"db-connect-mcp": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "clickhouse+asynch://default:@host:9000/default"
}
}
}
}
PostgreSQL via SSH tunnel (database behind a firewall, reachable only through a bastion host):
{
"mcpServers": {
"db-connect-mcp": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "postgresql+asyncpg://user:pass@db-internal:5432/mydb",
"SSH_HOST": "bastion.example.com",
"SSH_PORT": "22",
"SSH_USERNAME": "deployer",
"SSH_PRIVATE_KEY_PATH": "/home/user/.ssh/id_rsa"
}
}
}
}
MySQL via SSH tunnel:
{
"mcpServers": {
"db-connect-mcp": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "mysql+aiomysql://user:pass@db-internal:3306/mydb",
"SSH_HOST": "bastion.example.com",
"SSH_PORT": "22",
"SSH_USERNAME": "deployer",
"SSH_PASSWORD": "secret"
}
}
}
}
Multiple databases (each MCP server instance connects to one database):
{
"mcpServers": {
"postgres-prod": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "postgresql+asyncpg://user:pass@pg-host:5432/prod"
}
},
"mysql-analytics": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "mysql+aiomysql://user:pass@mysql-host:3306/analytics"
}
}
}
}
After creating .mcp.json, restart Claude Code and verify with /mcp. You should see db-connect-mcp listed with all available tools.
Tip: Instead of
SSH_PRIVATE_KEY_PATH, you can useSSH_PRIVATE_KEYto pass the private key content directly as a string (raw PEM or base64-encoded PEM). This is useful in CI/CD or cloud environments where mounting key files is impractical.
See the SSH Tunnel Guide for full tunnel configuration reference.
Add the server to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"db-connect": {
"command": "python",
"args": ["-m", "db_connect_mcp"],
"env": {
"DATABASE_URL": "postgresql+asyncpg://user:pass@host:5432/db"
}
}
}
}
The same database URL formats and SSH tunnel environment variables shown in the Claude Code examples above work identically with Claude Desktop.
For development: See Development Guide for running from source with uv.
| Feature | PostgreSQL | MySQL | ClickHouse |
|---|---|---|---|
| Schemas | โ Full | โ Full | โ Full |
| Tables | โ Full | โ Full | โ Full |
| Views | โ Full | โ Full | โ Full |
| Indexes | โ Full | โ Full | โ ๏ธ Limited |
| Foreign Keys | โ Full | โ Full | โ No |
| Constraints | โ Full | โ Full | โ ๏ธ Limited |
| Table Size | โ Exact | โ Exact | โ Exact |
| Row Count | โ Exact | โ Exact | โ Exact |
| Column Stats | โ Full | โ Full | โ Full |
| Sampling | โ Full | โ Full | โ Full |
List all schemas in the database.
List all tables in a schema with metadata.
schema (optional): Schema name (default: "public")Get detailed information about a table.
table_name: Name of the tableschema (optional): Schema name (default: "public")Analyze a column with statistics and distribution.
table_name: Name of the tablecolumn_name: Name of the columnschema (optional): Schema name (default: "public")Get a sample of data from a table.
table_name: Name of the tableschema (optional): Schema name (default: "public")limit (optional): Number of rows (default: 100, max: 1000)Execute a read-only SQL query.
query: SQL query (must be SELECT or WITH)limit (optional): Maximum rows (default: 1000, max: 10000)Get foreign key relationships in a schema.
schema (optional): Schema name (default: "public")Once configured, you can use the server in Claude:
"Can you analyze my database and tell me about the table structure?"
"Show me the relationships between tables in the public schema"
"What's the distribution of values in the users.created_at column?"
"Give me a sample of data from the orders table"
"Run this query: SELECT COUNT(*) FROM users WHERE created_at > '2024-01-01'"
Working with PostgreSQL:
"List all schemas except system ones"
"Show me the foreign key relationships in the sales schema"
"Analyze the performance of indexes on the products table"
Working with MySQL:
"What storage engines are being used in my database?"
"Show me all tables in the information_schema"
"Analyze the customer_orders table structure"
Working with ClickHouse:
"Show me the partitions for the events table"
"What's the compression ratio for the analytics.clicks table?"
"Sample 1000 rows from the metrics table"
Read-only by design: The server enforces read-only access at multiple levels:
No data modification: INSERT, UPDATE, DELETE, CREATE, DROP, and other modification statements are blocked
Query limits: All queries are automatically limited to prevent excessive resource usage
No sensitive operations: No access to system catalogs or administrative functions
For detailed development setup, testing, and contribution guidelines, see the Development Guide.
db-connect-mcp/
โโโ src/
โ โโโ db_connect_mcp/
โ โโโ adapters/ # Database-specific adapters
โ โ โโโ __init__.py
โ โ โโโ base.py # Base adapter interface
โ โ โโโ postgresql.py # PostgreSQL adapter
โ โ โโโ mysql.py # MySQL adapter
โ โ โโโ clickhouse.py # ClickHouse adapter
โ โโโ core/ # Core functionality
โ โ โโโ __init__.py
โ โ โโโ connection.py # Database connection management
โ โ โโโ executor.py # Query execution
โ โ โโโ inspector.py # Metadata inspection
โ โ โโโ analyzer.py # Statistical analysis
โ โ โโโ tunnel.py # SSH tunnel management
โ โโโ models/ # Data models
โ โ โโโ __init__.py
โ โ โโโ capabilities.py # Database capabilities
โ โ โโโ config.py # Configuration models
โ โ โโโ database.py # Database models
โ โ โโโ query.py # Query models
โ โ โโโ statistics.py # Statistics models
โ โ โโโ table.py # Table metadata models
โ โโโ __init__.py
โ โโโ __main__.py # Module entry point
โ โโโ server.py # Main MCP server implementation
โโโ tests/
โ โโโ unit/ # Unit tests (mocked)
โ โโโ module/ # Module tests (single component + DB)
โ โโโ integration/ # Integration tests (full stack)
โ โโโ conftest.py # Shared fixtures
โโโ .env.example # Example environment configuration
โโโ pyproject.toml # Project dependencies and console scripts
โโโ README.md # This file
The server uses an adapter pattern to support multiple database systems:
# Start local test database (PostgreSQL 17 with sample data)
cd tests/docker && docker-compose up -d && cd ../..
# Run all tests in parallel (preferred - 6 workers)
uv run pytest -n 6
# Run specific test modules
uv run pytest tests/module/test_inspector.py -v -n 6
uv run pytest tests/integration/ -v -n 6
# Stop test database
cd tests/docker && docker-compose down && cd ../..
# Reset database (clean slate with fresh data)
cd tests/docker && docker-compose down -v && docker-compose up -d && cd ../..
Local Test Database:
See the Development Guide and Testing Guide for detailed testing instructions.
?ssl=require)?charset=utf8mb4)PostgreSQL:
asyncpg driver is specified for async operationsMySQL/MariaDB:
aiomysql driver for async supportClickHouse:
asynch driver for async operationslimit parameter to control result sizeCreated by Yuri Gui.
Contributions are welcome! The server is designed to be read-only and safe by default. Any new features should maintain these safety guarantees.
MIT License - See LICENSE file for details
Be the first to review this server!
by Modelcontextprotocol ยท Developer Tools
Read, search, and manipulate Git repositories programmatically
by Toleno ยท Developer Tools
Toleno Network MCP Server โ Manage your Toleno mining account with Claude AI using natural language.
by mcp-marketplace ยท Developer Tools
Create, build, and publish Python MCP servers to PyPI โ conversationally.
by Microsoft ยท Content & Media
Convert files (PDF, Word, Excel, images, audio) to Markdown for LLM consumption
by mcp-marketplace ยท Developer Tools
Scaffold, build, and publish TypeScript MCP servers to npm โ conversationally
by mcp-marketplace ยท Finance
Free stock data and market news for any MCP-compatible AI assistant.