db-mcp
Provides read-only query capabilities to Elasticsearch indices, supporting _search, _mapping, and _cat endpoints with index name validation.
Provides read-only query capabilities to MongoDB databases, supporting find, aggregate, count, and distinct operations with enforced restrictions.
Provides read-only SQL query capabilities to MySQL databases, with enforced statement restrictions and row limits.
Click on "Install 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., "@db-mcplist available databases"
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.
db-mcp
Read-only database access for AI agents, as a local stdio MCP server. One uniform surface over Postgres, MySQL, MongoDB, and Elasticsearch, across multiple environments (dev, staging, prod, …).
Companion to agent-workbench, which deliberately holds no credentials and makes no network calls — anything that needs either lives in a sidecar like this one.
Query-only, enforced in the server
Use whatever credentials you already have — the server itself guarantees nothing but reads go through. It never creates users, never touches grants, never runs DDL/DCL:
The statement guard: one statement per call; must start with SELECT/SHOW/DESCRIBE/EXPLAIN/WITH; every write/DDL/DCL keyword rejected after comment/string stripping; row limits enforced (default 100, cap 1000). Mongo allows only
find/aggregate/count/distinctand walks aggregate pipelines recursively to reject$out/$merge(even nested in$lookup/$facet); Elasticsearch only ever issues_search/_mapping/_catrequests with index names validated against path smuggling.The session: connections are additionally set read-only where the store supports it (
default_transaction_read_onlyon Postgres,SET SESSION TRANSACTION READ ONLYon MySQL) plus 30s server-side timeouts.
Related MCP server: safe-sql-mcp
Failures come back usable
A read-only server still wastes your time if a bad call hangs or a wrong guess tells you nothing:
Every failure comes back as an answer. Whatever a driver raises is returned as a tool error against the id of the request that caused it. A reply the caller cannot match to its request is, from its side, the same as no reply at all — the call just never returns.
Nothing runs unbounded. Server-side caps (
statement_timeout,max_execution_time,maxTimeMS) bound execution, not a stalled socket or a cursor dripping one batch at a time — eachgetMorerestarts the server's clock. Every engine also carries socket timeouts and a 35s client-side deadline, so a runaway call returns an error instead of hanging the session.A wrong column name comes back with the right ones.
Unknown column 'DATE_CREATE'tells you the guess was wrong but not what to use, so the next attempt is another guess; SQL engines append the table's real columns (or the database's tables, for an unknown table) to the error.A mongo timeout on an
{"$oid": …}filter says so. Extended JSON is not converted to anObjectIdhere, so the match scans and finds nothing; the error names the$toString/$exprrewrite that works.
Prod is a separate tool. db_query covers non-prod envs (refuses
env="prod"); db_query_prod is its own tool name so your harness can
allowlist dev queries while prod keeps prompting for manual approval.
Setup
git clone <this-repo> db-mcp && cd db-mcp
# Python >=3.11 plus the three drivers — any venv/interpreter you like.
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
mkdir -p ~/.config/db-mcp
cp config.example.toml ~/.config/db-mcp/config.toml
$EDITOR ~/.config/db-mcp/config.toml # fill in read-only creds
chmod 600 ~/.config/db-mcp/config.toml # the server refuses looser modes
# Claude Code (point it at whichever interpreter has the drivers)
claude mcp add --scope user db-mcp "$PWD/.venv/bin/python3" "$PWD/run_mcp.py"Credentials live only in ~/.config/db-mcp/config.toml — never in this repo,
never in the harness config, never in brain notes.
Tools
Tool | Use |
| configured databases (name, env, type, host — no secrets) |
| one read-only query on a non-prod env (default |
| same, prod only — separate tool so it can be permission-gated separately |
| tables/collections/indices, or columns/mappings of one target |
Query shapes: SQL string for postgres/mysql; JSON {"op": "find", "filter": …} for mongo (target = collection); JSON search body for es (target =
index).
Tests
python3 -m unittest discover -s tests -v # no network, no drivers requiredThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityBmaintenanceProvides AI assistants with read-only access to inspect database schemas, preview data, and run safe queries across PostgreSQL, MySQL, MongoDB, and SQL Server. It enables AI tools to understand database structures and relationships automatically to generate more accurate code.77MIT
- Flicense-qualityCmaintenanceEnables read-only SQL database access for AI assistants, allowing schema exploration and safe query execution without risk of data modification.
- Alicense-qualityCmaintenanceEnables AI agents to securely interact with multiple databases (MySQL, PostgreSQL) via natural language queries, with cross-database querying and enterprise-grade security.18MIT
- Alicense-qualityDmaintenanceProvides read-only MySQL database operations for AI agents, supporting multiple database servers with tools for listing tables, describing schemas, and executing SELECT queries.MIT
Related MCP Connectors
Read-only bank access for your AI agent. Connects Claude, ChatGPT, Cursor, Gemini, Codex.
Gateway between LLM agents and world data through eight tools and a bundled endpoint catalog.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/chud-lori/db-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server