mcp-database
Allows executing read/write queries, schema inspection, performance diagnostics, and management for MariaDB (follows MySQL tool set with engine-specific differences).
Allows executing read operations (find, aggregate, countDocuments, distinct) and write operations (insertMany, updateMany, deleteMany, createIndex), schema inspection, Atlas $search / $vectorSearch, and performance diagnostics for MongoDB.
Allows executing read/write queries, schema inspection, performance diagnostics (including column stats, histograms, performance_schema), full-text search, and database management for MySQL.
Allows executing read and write queries, schema inspection, performance diagnostics (including active ops, blocking, top queries, EXPLAIN), vector search with pgvector, full-text search, and cluster management (replication, failover) for PostgreSQL databases.
Allows executing safe read and limited write commands (via allowlist, blocking FLUSH*, EVAL, KEYS), SCAN-based key inspection, SLOWLOG/INFO/ACL diagnostics for Redis.
Allows executing read/write queries, schema inspection, FTS5 text search, EXPLAIN QUERY PLAN, and performance diagnostics for SQLite file databases.
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., "@mcp-databaseshow me the users table schema"
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-database
MCP database server for PostgreSQL, MySQL, MariaDB, SQLite, MongoDB, and Redis. One connection per instance, per-connection access modes, and a full performance-diagnosis toolkit for dev, SRE, and DBA workflows.
Contents
Related MCP server: mcp-database-server
Supported databases
One connection per instance; the engine is inferred from the URI scheme (override with ENGINE_TYPE).
Database | URI scheme |
| Driver | Highlights |
PostgreSQL |
|
| psycopg 3 | pgvector KNN, native full-text search, HypoPG hypothetical indexes, transactional DDL dry-run, planner column stats |
MySQL |
|
| aiomysql | FULLTEXT search, planner column stats + histograms, |
MariaDB |
|
| aiomysql | Follows the MySQL surface with the engine differences absorbed ( |
SQLite |
|
| aiosqlite | File databases with structurally read-only reads ( |
MongoDB |
|
| PyMongo (async) | Atlas |
Redis |
|
| redis-py (async) | Allowlisted command envelope ( |
Engine support per tool (some features are engine-specific — e.g. HypoPG is PostgreSQL-only) is in docs/tools.md. CI verifies every tool against real PostgreSQL 16/17, MySQL 8.0/8.4, MariaDB 10.11/11.4, SQLite, MongoDB 7/8, and Redis 7/8 (plus pgvector and Atlas-local images) on every push.
Features
39 tools, risk-encoded names.
db_schema_*/db_read_*/db_perf_*never write (safe to always-allow);db_write_*/db_admin_*need approval.Vector + full-text search. pgvector KNN and FTS (PostgreSQL), FULLTEXT (MySQL), Atlas
$search/$vectorSearch(MongoDB), plus index inspection and quality diagnostics.Cluster tooling. Replication-lag and topology triage (
db_perf_cluster) with audited actions: promote, start/stop replica, step down, freeze.Access modes per connection.
read_write,read_only,monitor(perf analysis with no data access, for production with PII).Fail-closed read validation. sqlglot rejects writes, DDL, multi-statement and dangerous functions; MongoDB is limited to a read-only op allowlist.
Fine-grained write control.
write_opslimits which operations run;database_modessets a different mode per database.Write safety belts.
dry_run(execute, roll back, report impact) andexpected_max_rows(auto-abort oversized writes).PII masking.
redact_fieldsmasks values with***;["*"]shows type placeholders only, never values.Audit log. Every write, admin and export call is logged as JSONL (mode 600); literals become
?, so PII never touches disk.Result limits. 500 rows / 1 MiB per response with source-side
LIMITinjection;db_read_exportstreams big results to JSON/CSV.
Tools
Full reference with parameters and per-database support indicators: docs/tools.md.
Class | Tools | Safe to always-allow |
| connections, databases, objects, describe, ddl, search, relationships, users, grants, search_indexes | ✅ |
| query, sample, export, vector_search, text_search | ✅ |
| explain, column_stats, diagnose, top_queries, active_ops, blocking, index_stats, table_stats, health, replication, settings, logs, vector_stats, cluster | ✅ |
| query (with | case by case |
| kill, analyze, maintain, cluster | case by case |
Access-mode matrix:
Class |
|
|
|
| ✅ | ✅ | ✅ (no data sampling) |
| ✅ | ✅ | ❌ |
| ✅ | ✅ | ✅ |
| ✅ | ❌ | ❌ |
Quick start
Requirements: Docker (runs both the playground databases and the published server image). uv is only needed for local development.
# 1. Clone (for the playground compose file and seed data)
git clone https://github.com/DiegoBulhoes/mcp-database.git && cd mcp-database
# 2. Start and seed the playground databases (PostgreSQL + MySQL + MongoDB)
make up && make mongo-rs && make seed
# 3. Register with Claude Code — runs the published image, one connection per server entry.
# All configuration lives in --env; the docker -e flags are a fixed forwarding template.
claude mcp add db-postgres \
--env URI="postgresql://dev:dev@localhost:5432/app" \
--env ENGINE_TYPE=postgres \
--env MODE=read_write \
-- docker run -i --rm --network host -e URI -e ENGINE_TYPE -e MODE -e NAME \
ghcr.io/diegobulhoes/mcp-database:latest
--network hostlets the container reachlocalhostdatabases (Linux). On macOS/Windows Docker Desktop, drop it and usehost.docker.internalin the URI instead.
Then ask Claude things like "why is pg_app slow?" and it will chain db_perf_active_ops → db_perf_blocking → db_perf_top_queries → db_perf_explain without a single permission prompt (see below).
Querying
You don't call the tools yourself; your AI assistant does, picking the connection by name (it discovers what exists via db_schema_connections). You just ask in natural language:
You ask | The assistant calls |
"how many orders over 100 in pg_app?" |
|
"top pages by clicks in mongo_app" |
|
"why is pg_app slow?" |
|
"upgrade user 42 to the pro plan" |
|
The query argument depends on the connection type:
PostgreSQL / MySQL: a SQL string.
db_read_queryaccepts only SELECT/UNION/VALUES (parser-validated, fail-closed); everything else goes throughdb_write_query.MongoDB: a JSON object
{"collection", "operation", ...}. Reads:find,aggregate,countDocuments,distinct,listIndexes; writes (viadb_write_query):insertMany,updateMany,deleteMany,createIndex.
Example query values:
SELECT id, total FROM orders WHERE total > 100 ORDER BY total DESC LIMIT 20{"collection": "events", "operation": "aggregate",
"pipeline": [{"$group": {"_id": "$page", "n": {"$sum": 1}}}, {"$sort": {"n": -1}}]}Write safety belts on db_write_query:
Unbounded-mutation guard: an
UPDATE/DELETEwith noWHERE(or a MongoDBupdateMany/deleteManywith an empty filter) is rejected outright unless the caller declares intent — either adry_runor anexpected_max_rows. This stops a careless model from wiping a whole table without saying so. (DROP/TRUNCATEare explicit by nature and stay allowed.)dry_run: trueexecutes inside a transaction and rolls back, reporting how many rows would be affected.expected_max_rows: Naborts with rollback if the write would affect more than N rows (catches a missing WHERE before it hurts).
References
Projects and resources that shaped this server's design:
Model Context Protocol: protocol specification and the Python SDK (FastMCP) this server is built on.
anthropics/skills (Anthropic): two skills from this repo are bundled in
.claude/skills/: mcp-builder, whose best practices this server was audited against (tool naming with thedb_service prefix, parameter descriptions, annotations, actionable errors, and the agent evaluations format), and algorithmic-art for generative-art sessions.postgres-mcp (Crystal DBA): inspiration for access modes, safe SQL execution, and the performance/health tool set.
mongodb-mcp-server (MongoDB): inspiration for the export tool, byte-based response limits, and server log access.
mcp-server-mysql (Ben Borla): inspiration for per-operation write permissions (
write_ops) and per-database modes (database_modes).
License
This 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
- AlicenseAqualityAmaintenanceA multi-database MCP server with OAuth 2.0 authentication and granular access control, enabling secure connections to multiple database types (SQLite, MySQL, PostgreSQL, MongoDB, Redis) with configurable read/write permissions and tool filtering.36210MIT
- Alicense-qualityDmaintenanceA modular MCP server that enables interaction with multiple database types including PostgreSQL, MySQL, SQLite, Redis, MongoDB, and LDAP. It provides tools for executing queries, managing SQL commands, and exploring database schemas with configurable read-only security.8MIT
- Flicense-qualityDmaintenanceA secure multi-database MCP server supporting MySQL, PostgreSQL, and SQLite with read-only enforcement, SQL injection prevention, and tools for schema analysis, performance optimization, and visualization.4
- Alicense-qualityDmaintenanceMCP server for connecting to databases (PostgreSQL, MySQL, SQL Server, Redis) enabling SQL queries, table exploration, and Redis key-value operations.1MIT
Related MCP Connectors
MCP server for managing Prisma Postgres.
GibsonAI MCP server: manage your databases with natural language
Butterbase MCP server — manage your backend: schemas, auth, functions, storage, RAG, deploys.
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/DiegoBulhoes/mcp-database'
If you have feedback or need assistance with the MCP directory API, please join our Discord server