Best MCP Servers for Databases: PostgreSQL, MySQL, MongoDB & More
Table of Contents
- Why Database MCP Servers Matter
- PostgreSQL MCP Servers
- Official PostgreSQL MCP Server (by Anthropic)
- Supabase MCP Server
- MySQL MCP Servers
- MySQL MCP Server (Community)
- DBHub (Multi-Database)
- MongoDB MCP Server
- Official MongoDB MCP Server
- SQLite MCP Server
- Official SQLite MCP Server (by Anthropic)
- Redis MCP Server
- Enterprise & Cloud Database Servers
- MindsDB MCP Server
- Google Cloud Toolbox for Databases
- ClickHouse MCP Server
- Example Queries You Can Run
- Security Best Practices
- 1. Use Read-Only Credentials
- 2. Never Use Production Credentials Directly
- 3. Restrict Table Access
- 4. Review Every Query
- 5. Use Connection Limits
- Choosing the Right Database MCP Server
- What's Next
Best MCP Servers for Databases: PostgreSQL, MySQL, MongoDB & More
Connecting your AI to a database is one of the most powerful things you can do with MCP. Instead of copying SQL results into a chat window, your AI reads the schema, writes queries, and analyzes results directly.
This guide covers every major database MCP server — how to install each one, example queries, and the security practices you need to follow.
Why Database MCP Servers Matter
Without MCP, interacting with your database through AI looks like this:
- Run a query in your database client
- Copy the results
- Paste into Claude/ChatGPT
- Ask your question
- Get a suggested query back
- Copy it, run it, repeat
With a database MCP server:
- Ask your AI "What were our top 10 products by revenue last month?"
- The AI reads your schema, writes the query, runs it (with your approval), and gives you the answer
That workflow change saves hours per week for anyone who works with data.
PostgreSQL MCP Servers
Official PostgreSQL MCP Server (by Anthropic)
The reference implementation. Simple, reliable, read-only by default.
Install:json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost:5432/mydb"
]
}
}
}
What it exposes:
query— Run read-only SQL queries- Schema information as resources (tables, columns, types)
See our full PostgreSQL MCP Server review for more details.
Supabase MCP Server
Full Supabase integration — not just the database, but auth, storage, and edge functions too.
Install:json
{
"mcpServers": {
"supabase": {
"command": "npx",
"args": ["-y", "supabase-mcp-server"],
"env": {
"SUPABASE_URL": "https://your-project.supabase.co",
"SUPABASESERVICEKEY": "your-service-key"
}
}
}
}
What it exposes: Database queries, table management, auth user management, storage operations, edge function management
Pricing: Free server (Supabase has its own pricing tiers)
Best for: Supabase users who want AI-assisted full-stack development
MySQL MCP Servers
MySQL MCP Server (Community)
Install:json
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "mysql-mcp-server"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "mydb"
}
}
}
}
What it exposes: Schema inspection, query execution, table management
Pricing: Free, open source
Best for: MySQL/MariaDB users who need basic database AI integration
DBHub (Multi-Database)
DBHub is a universal MCP server that supports MySQL, MariaDB, PostgreSQL, and SQL Server through a single interface.
Install:json
{
"mcpServers": {
"dbhub": {
"command": "npx",
"args": [
"-y",
"dbhub",
"--dsn",
"mysql://user:pass@localhost:3306/mydb"
]
}
}
}
Supported DSN formats:
- PostgreSQL:
postgresql://user:pass@host:5432/db - MySQL:
mysql://user:pass@host:3306/db - SQL Server:
sqlserver://user:pass@host:1433/db - MariaDB:
mariadb://user:pass@host:3306/db
MongoDB MCP Server
Official MongoDB MCP Server
Built and maintained by the MongoDB team. Works with both local MongoDB and Atlas clusters.
Install:json
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--connectionString",
"mongodb://localhost:27017"
]
}
}
}
For MongoDB Atlas:
json
{
"mcpServers": {
"mongodb-atlas": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--connectionString",
"mongodb+srv://user:pass@cluster.mongodb.net/mydb"
]
}
}
}
What it exposes: Collection browsing, document queries, aggregation pipelines, index management
Pricing: Free, open source
Best for: MongoDB users at any scale. Atlas support means it works with production cloud databases too.
SQLite MCP Server
Official SQLite MCP Server (by Anthropic)
Lightweight and perfect for local databases, prototyping, or embedded data.
Install:json
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sqlite",
"/path/to/your/database.db"
]
}
}
}
What it exposes: Query execution, schema inspection, table creation, data analysis
Pricing: Free, open source
Best for: Local development, prototyping, analyzing data in SQLite files
Redis MCP Server
Install:json
{
"mcpServers": {
"redis": {
"command": "npx",
"args": ["-y", "redis-mcp-server"],
"env": {
"REDIS_URL": "redis://localhost:6379"
}
}
}
}
What it exposes: Key-value operations, hash operations, list operations, key scanning
Pricing: Free, open source
Best for: Debugging Redis caches, exploring key structures, managing session data
Enterprise & Cloud Database Servers
MindsDB MCP Server
MindsDB acts as a unified MCP gateway to multiple enterprise databases — Oracle, PostgreSQL, MongoDB, Snowflake, and more.
What it does: Connects AI models directly to your database ecosystem, whether cloud-based, on-premises, or hybrid. Pricing: Free tier available; enterprise plans for production use (check mindsdb.com for current pricing) Best for: Enterprise teams with complex, multi-database environmentsGoogle Cloud Toolbox for Databases
A secure, configurable MCP interface for executing pre-defined queries against PostgreSQL, MySQL, SQL Server, Neo4j, and Spanner.
Key feature: YAML-based configuration lets you define approved queries, so the AI can only run operations you've pre-authorized. Pricing: Free server (standard Google Cloud charges apply) Best for: Teams that need strict control over what queries AI can runClickHouse MCP Server
Analytics-focused MCP server for ClickHouse columnar databases.
Best for: Data teams running analytical queries on large datasetsExample Queries You Can Run
Once your database MCP server is connected, here are practical things to ask:
Data analysis: > "What's the average order value by customer segment for the last 90 days?" Schema understanding: > "Show me how the users, orders, and products tables are related" Query debugging: > "This query is slow — can you look at the schema and suggest indexes?" Data quality: > "Are there any users with duplicate email addresses?" Report generation: > "Generate a summary of our monthly revenue trend for the last 12 months"The AI reads your actual schema, so it writes accurate queries for your specific tables and columns — not generic examples.
Security Best Practices
Connecting AI to your database is powerful, but it comes with risks. Follow these rules:
1. Use Read-Only Credentials
Create a dedicated database user with SELECT-only permissions:
sql
-- PostgreSQL
CREATE USER mcpreadonly WITH PASSWORD 'securepassword';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO mcp_readonly;
sql
-- MySQL
CREATE USER 'mcpreadonly'@'localhost' IDENTIFIED BY 'securepassword';
GRANT SELECT ON mydb.* TO 'mcp_readonly'@'localhost';
2. Never Use Production Credentials Directly
Connect to a read replica or a separate analytics database. Never point MCP at your primary production database with write access.
3. Restrict Table Access
Only grant access to tables the AI actually needs. Don't expose user passwords, payment info, or PII tables:
sql
-- Only grant access to specific tables
GRANT SELECT ON orders, products, categories TO mcp_readonly;
-- NOT: GRANT SELECT ON ALL TABLES
4. Review Every Query
MCP clients show you each query before it runs. Always review the SQL — especially check for:
- Queries against sensitive tables
- Large table scans without WHERE clauses
- Unexpected JOINs that might expose data
5. Use Connection Limits
Set connection limits on your MCP database user to prevent runaway queries:
sql
-- PostgreSQL
ALTER USER mcp_readonly CONNECTION LIMIT 3;
ALTER USER mcpreadonly SET statementtimeout = '30s';
For a deeper dive, read our MCP security best practices guide.
Choosing the Right Database MCP Server
| Database | Best Server | Write Support | Maintained By |
|---|---|---|---|
| PostgreSQL | Official Postgres MCP | Read-only | Anthropic |
| MySQL/MariaDB | DBHub | Read + Write | Community |
| MongoDB | Official MongoDB MCP | Read + Write | MongoDB |
| SQLite | Official SQLite MCP | Read + Write | Anthropic |
| SQL Server | DBHub | Read + Write | Community |
| Redis | Redis MCP Server | Read + Write | Community |
| Multi-DB | MindsDB | Configurable | MindsDB |
| Supabase | Supabase MCP | Full access | Community |
What's Next
- See our complete MCP servers guide for servers beyond databases
- Set up MCP in your editor: Cursor guide | VS Code guide
- Read the MCP security guide before connecting production databases
We track MCP support across 500+ AI tools in our directory — browse MCP-compatible tools to find the right fit for your database stack.
Master AI Agent Building
Get our comprehensive guide to building, deploying, and scaling AI agents for your business.
What you'll get:
- 📖Step-by-step setup instructions for 10+ agent platforms
- 📖Pre-built templates for sales, support, and research agents
- 📖Cost optimization strategies to reduce API spend by 50%
Get Instant Access
Join our newsletter and get this guide delivered to your inbox immediately.
We'll send you the download link instantly. Unsubscribe anytime.
📖 Related Reading
Best AI Tools for Lawyers in 2026: Complete Guide to Legal AI Software (Ranked by Practice Area)
What Is A2A Protocol? Complete Guide for 2026
Top MCP Clients Compared: Claude vs Cursor vs VS Code vs Windsurf
MCP vs API: Which Should You Use for AI Agent Integration?
Enjoyed this article?
Get weekly deep dives on AI agent tools, frameworks, and strategies delivered to your inbox.