mcp_db
Allows running SQL queries (DQL, DDL, DML, DCL, TCL) against ClickHouse databases (HTTP interface) with per-connection policy modes (readonly, restricted, unrestricted).
Allows running SQL queries (DQL, DDL, DML, DCL, TCL) against PostgreSQL databases with per-connection policy modes (readonly, restricted, unrestricted).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp_dbquery the users table for active accounts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp_db
MCP server for running SQL against PostgreSQL and ClickHouse (HTTP interface) connections, with per-connection allow/deny policy by statement group (DDL/DML/DQL/DCL/TCL).
Built on mcp_core.
Install
poetry installRelated MCP server: Multi-DB MCP Server
Configure
Copy db_connections.example.yaml to db_connections.yaml, edit connections. Secrets are env-var references only (user_env/password_env) — export the actual values before starting the server.
Run
export MCP_DB_CONFIG=/path/to/db_connections.yaml
export PG_USER=... PG_PASSWORD=...
export CH_USER=... CH_PASSWORD=...
poetry run mcp-dbTools
db_query(connection, sql)— DQL only, rows truncated atmax_rows.db_execute(connection, sql)— DDL/DML/DCL/TCL, returnsrowcount.db_list_connections()— lists configured connection names, drivers, and policy modes.
Policy modes (per connection, mode field)
readonly(default) — only DQL allowed.restricted— only groups listed inallow_groupsallowed; emptyallow_groupsdenies everything.unrestricted— everything allowed except groups listed indeny_groups.
Tests
poetry run pytest -m "not integration" # fast unit tests
docker compose -f docker-compose-test.yml up -d # postgres + clickhouse test containers
poetry run pytest # full suite
docker compose -f docker-compose-test.yml downThis server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted MCP server for PostgreSQL diagnostics: slow queries, missing indexes, connection pressure.
- SupabaseOAuthcom.supabase
MCP server for interacting with the Supabase platform
Related MCP Servers
- AlicenseBqualityFmaintenanceA minimal MCP server that allows executing SQL queries on PostgreSQL databases with configurable read-only or write permissions.1913MIT
- FlicenseNot gradedqualityDmaintenanceA multi-database MCP server supporting PostgreSQL, ClickHouse, and MySQL that enables database exploration and SQL execution through MCP stdio or HTTP API.-
- AlicenseNot gradedqualityFmaintenanceRead-only MCP server for SQL databases (SQL Server, Postgres, SQLite) with multi-server support and three-layer safety using AST validation and linting.MIT
- AlicenseAqualityCmaintenanceA self-hostable PostgreSQL MCP server for exploring database schemas and running guarded read/write queries with selectable access modes (readonly, readwrite, admin), plus a dry-run confirm workflow for safety.141MIT