mcp-database
Serveurs MCP pour l'accès aux bases de données relationnelles et NoSQL. Supporte PostgreSQL, MySQL et MongoDB avec introspection de schéma.
Description & Examples
mcp-database
MCP server plugin providing natural-language access to relational and document databases. Supports PostgreSQL, MySQL, and MongoDB with automatic schema introspection and query generation.
What it does
This plugin exposes three MCP servers — postgres-mcp, mysql-mcp, and mongodb-mcp — that Claude can use to inspect database schemas, run read queries, and explain query execution plans. Each server authenticates with the database using credentials from the environment and presents the schema as a set of tools and resources.
When to use it
Use this plugin when working on a project that involves database-heavy features and you want to query live data, understand an unfamiliar schema, or generate and validate SQL/aggregation queries without leaving the editor. It is also useful for debugging data issues or generating test fixtures from real schema shapes.
Components
dns
postgres-mcp
MCP
postgres-mcp
MCP server for PostgreSQL databases. Provides schema introspection, read-only query execution, and explain plan analysis through the Model Context Protocol.
Connection
Credentials are read from environment variables:
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=myapp
POSTGRES_USER=readonly_user
POSTGRES_PASSWORD=secret
POSTGRES_SSL=true
Alternatively, provide a connection string:
DATABASE_URL=postgresql://readonly_user:secret@localhost:5432/myapp?sslmode=require
Exposed tools
| Tool | Description |
|---|---|
list_schemas |
List all schemas in the database |
list_tables |
List tables in a given schema with row counts |
describe_table |
Full column definitions, constraints, and indexes for a table |
run_query |
Execute a read-only SELECT query and return results as JSON |
explain_query |
Return the EXPLAIN ANALYZE output for a query |
list_functions |
List user-defined functions and stored procedures |
Usage examples
"List all tables in the public schema"
"Show me the columns and constraints on the orders table"
"How many users signed up in the last 30 days?"
"Explain why this query is slow: SELECT * FROM events WHERE user_id = 42"
Safety
- Only read-only operations are permitted (SELECT, EXPLAIN)
- Mutations (INSERT, UPDATE, DELETE, DDL) are rejected at the MCP layer
- Query results are limited to 1000 rows by default to prevent memory issues
- Queries time out after 10 seconds
Configuration
{
"postgres-mcp": {
"maxRows": 1000,
"queryTimeout": 10000,
"includeSystemSchemas": false
}
}
dns
mysql-mcp
MCP
mysql-mcp
MCP server for MySQL and MariaDB databases. Provides schema introspection and safe read-only query execution via the Model Context Protocol.
Connection
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DATABASE=myapp
MYSQL_USER=readonly_user
MYSQL_PASSWORD=secret
Or via DSN:
MYSQL_DSN=readonly_user:secret@tcp(localhost:3306)/myapp
Exposed tools
| Tool | Description |
|---|---|
list_databases |
List accessible databases on the server |
list_tables |
List tables in the current database with engine and row estimate |
describe_table |
Column types, keys, and indexes for a table |
show_create_table |
Full SHOW CREATE TABLE output |
run_query |
Execute a SELECT query and return rows as JSON |
explain_query |
Return EXPLAIN FORMAT=JSON for a query |
Usage examples
"What tables exist in the legacy database?"
"Show me the CREATE TABLE statement for the invoices table"
"Find all orders placed this week with a total above 500"
"Why is this JOIN between customers and orders using a full scan?"
Compatibility
- MySQL 5.7, 8.0, 8.4
- MariaDB 10.6+
- Amazon RDS for MySQL and Aurora MySQL (use
MYSQL_SSL_CAfor RDS certificates)
Safety
- DDL and DML statements are blocked; only SELECT and EXPLAIN are allowed
- Result sets are capped at 500 rows per query
- Connection pool limited to 5 connections
Configuration
{
"mysql-mcp": {
"maxRows": 500,
"queryTimeout": 8000,
"charset": "utf8mb4"
}
}
dns
mongodb-mcp
MCP
mongodb-mcp
MCP server for MongoDB. Enables schema discovery, collection exploration, and aggregation pipeline execution through the Model Context Protocol.
Connection
MONGODB_URI=mongodb://readonly_user:secret@localhost:27017/myapp?authSource=admin
MONGODB_DB=myapp
For Atlas:
MONGODB_URI=mongodb+srv://readonly_user:secret@cluster0.example.mongodb.net/myapp
Exposed tools
| Tool | Description |
|---|---|
list_collections |
List collections with document counts and storage size |
sample_documents |
Return a random sample of documents from a collection |
infer_schema |
Analyse a sample of documents and infer the field schema |
run_find |
Execute a find() query with optional filter, projection, and sort |
run_aggregate |
Execute an aggregation pipeline |
explain_query |
Return the query plan for a find or aggregate operation |
list_indexes |
List indexes on a collection |
Usage examples
"What collections are in the database and how many documents does each have?"
"Show me a few example documents from the events collection"
"What fields does the users collection typically contain?"
"Find all orders with status 'pending' created in the last 7 days"
"Count sign-ups per day for the past month"
Safety
- Write operations (insert, update, delete, drop) are rejected
- Aggregation pipelines with
$outor$mergestages are blocked run_findresults are limited to 200 documents- Operations time out after 15 seconds
Configuration
{
"mongodb-mcp": {
"maxDocuments": 200,
"sampleSize": 100,
"queryTimeout": 15000,
"readPreference": "secondaryPreferred"
}
}
Notes
- Schema inference uses a sample of up to 100 documents and may not capture all optional fields in large heterogeneous collections
- For Atlas Search indexes, use
list_indexesand look for indexes of typesearch