Server Categories
Pillar Guide

Database & Vector DB MCP Servers (MongoDB, Postgres, Pinecone & More)

Complete guide to database MCP servers — SQL databases, NoSQL, vector databases for RAG, and how to give AI secure, structured access to your data.

22 min read
Updated February 25, 2026
By MCP Server Spot

Database MCP servers give AI applications direct, structured access to your data stores -- from traditional SQL databases like PostgreSQL and MySQL, to NoSQL databases like MongoDB and Redis, to vector databases that power RAG (Retrieval-Augmented Generation) applications. They are among the most impactful MCP servers available, enabling AI assistants to query data, analyze schemas, generate reports, and even build data pipelines.

This guide covers every major database MCP server category: SQL, NoSQL, and vector databases. You will learn how to set each up, what tools they expose, how to secure them, and how to combine them for sophisticated AI-powered data workflows.

SQL Database MCP Servers

SQL databases remain the backbone of most applications. MCP servers for SQL databases expose query execution, schema inspection, and data management tools to AI applications.

PostgreSQL MCP Server

The official Postgres MCP server is maintained as part of the reference implementations:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:password@localhost:5432/mydb"
      ]
    }
  }
}

Available Tools:

ToolDescription
queryExecute a SQL query and return results
list_tablesList all tables in the database
describe_tableGet column names, types, and constraints
list_schemasList available database schemas

Resources Exposed:

The Postgres server also exposes database schemas as MCP resources, allowing AI applications to browse table structures without executing queries:

  • postgres://schemas -- List of all schemas
  • postgres://schemas/{schema}/tables -- Tables within a schema
  • postgres://schemas/{schema}/tables/{table} -- Column details for a table

Production Configuration:

For production use, always use read-only credentials and connect to a replica:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://readonly_user:password@replica.db.example.com:5432/production?sslmode=require"
      ]
    }
  }
}

MySQL MCP Server

MySQL MCP servers provide similar capabilities for MySQL and MariaDB databases:

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "mcp-server-mysql"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "readonly_user",
        "MYSQL_PASSWORD": "password",
        "MYSQL_DATABASE": "myapp"
      }
    }
  }
}

Key Features:

  • SQL query execution with parameterized queries
  • Schema introspection (tables, columns, indexes)
  • Support for MySQL 5.7+ and MariaDB 10.3+
  • Connection pooling for performance
  • SSL/TLS support for encrypted connections

SQLite MCP Server

The official SQLite MCP server is ideal for local development, embedded databases, and prototyping:

{
  "mcpServers": {
    "sqlite": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sqlite",
        "/path/to/database.db"
      ]
    }
  }
}

Available Tools:

ToolDescription
read_queryExecute SELECT queries
write_queryExecute INSERT, UPDATE, DELETE
create_tableCreate a new table
list_tablesList all tables
describe_tableGet table schema
append_insightStore analytical insights as memos

The SQLite server is particularly useful for:

  • Analyzing data files (many tools export to SQLite)
  • Prototyping database schemas before deploying to production databases
  • Working with local application databases
  • Teaching SQL through interactive AI sessions

SQL Server Comparison

FeaturePostgres MCPMySQL MCPSQLite MCP
Official ServerYesCommunityYes
Read-Only ModeBuilt-in flagVia DB userVia connection mode
Schema ResourcesYesYesYes
Write OperationsConfigurableConfigurableConfigurable
Connection PoolingYesYesN/A (local file)
SSL/TLSYesYesN/A
Max Result RowsConfigurableConfigurableConfigurable
Parameterized QueriesYesYesYes
Best ForProduction appsLegacy systems, WordPressLocal development, analysis

NoSQL Database MCP Servers

NoSQL databases offer different data models -- document stores, key-value stores, and graph databases. MCP servers bring these capabilities to AI applications.

MongoDB MCP Server

The MongoDB MCP server exposes MongoDB's document database operations:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": ["-y", "mcp-server-mongodb"],
      "env": {
        "MONGODB_URI": "mongodb://user:password@localhost:27017/mydb"
      }
    }
  }
}

Available Tools:

ToolDescription
findQuery documents with MongoDB query syntax
aggregateRun aggregation pipelines
insert_oneInsert a single document
insert_manyInsert multiple documents
update_oneUpdate a single document
delete_oneDelete a single document
list_collectionsList all collections
collection_statsGet collection statistics
create_indexCreate an index on a collection

Use Cases:

  • Exploring document structures in unfamiliar MongoDB databases
  • Building aggregation pipelines with AI assistance
  • Migrating data between collections or formats
  • Analyzing unstructured data stored in MongoDB

Example Workflow -- Data Analysis:

User: "Analyze the customer orders collection and find the top 10
       customers by total spend in the last quarter"

Claude's workflow:
1. list_collections() — discover available collections
2. collection_stats("orders") — understand collection size and indexes
3. find("orders", {limit: 1}) — examine document structure
4. aggregate("orders", [
     {$match: {date: {$gte: "2025-10-01"}}},
     {$group: {_id: "$customerId", total: {$sum: "$amount"}}},
     {$sort: {total: -1}},
     {$limit: 10}
   ]) — execute the analysis

Redis MCP Server

The Redis MCP server provides access to Redis key-value operations:

{
  "mcpServers": {
    "redis": {
      "command": "npx",
      "args": ["-y", "mcp-server-redis"],
      "env": {
        "REDIS_URL": "redis://localhost:6379"
      }
    }
  }
}

Key Capabilities:

  • Get/set key-value pairs
  • List and search keys by pattern
  • Work with Redis data structures (lists, sets, hashes, sorted sets)
  • Monitor cache hit rates and memory usage
  • Pub/sub message inspection

Common Use Cases:

  • Inspecting and debugging cached data
  • Analyzing session stores
  • Managing feature flags stored in Redis
  • Monitoring queue depths (when using Redis as a message broker)

Vector Database MCP Servers

Vector databases are essential for RAG applications. They store embeddings -- numerical representations of text, images, or other data -- and enable similarity search. MCP servers for vector databases let AI applications build and query knowledge bases dynamically.

Pinecone MCP Server

Pinecone is one of the most popular managed vector databases. Its MCP server provides:

{
  "mcpServers": {
    "pinecone": {
      "command": "npx",
      "args": ["-y", "mcp-server-pinecone"],
      "env": {
        "PINECONE_API_KEY": "your_api_key",
        "PINECONE_ENVIRONMENT": "us-east-1-aws"
      }
    }
  }
}

Available Tools:

ToolDescription
querySimilarity search with vector or text input
upsertInsert or update vectors
deleteDelete vectors by ID or filter
fetchRetrieve vectors by ID
list_indexesList available Pinecone indexes
describe_indexGet index statistics
list_namespacesList namespaces within an index

Chroma MCP Server

Chroma is an open-source embedding database optimized for AI applications:

{
  "mcpServers": {
    "chroma": {
      "command": "npx",
      "args": ["-y", "mcp-server-chroma"],
      "env": {
        "CHROMA_HOST": "localhost",
        "CHROMA_PORT": "8000"
      }
    }
  }
}

Key Features:

  • Collection management (create, list, delete)
  • Document ingestion with automatic embedding
  • Similarity search with metadata filtering
  • Support for multiple embedding models
  • Runs locally without cloud dependencies

Qdrant MCP Server

Qdrant is a high-performance open-source vector database:

{
  "mcpServers": {
    "qdrant": {
      "command": "npx",
      "args": ["-y", "mcp-server-qdrant"],
      "env": {
        "QDRANT_URL": "http://localhost:6333",
        "QDRANT_API_KEY": "optional_api_key"
      }
    }
  }
}

Qdrant Advantages:

  • Rich filtering with payload-based conditions
  • Hybrid search combining vector similarity and keyword matching
  • Multi-vector support (store multiple embeddings per point)
  • Quantization for reduced memory usage
  • Written in Rust for exceptional performance

Weaviate MCP Server

Weaviate provides a GraphQL-based interface for vector and semantic search:

{
  "mcpServers": {
    "weaviate": {
      "command": "npx",
      "args": ["-y", "mcp-server-weaviate"],
      "env": {
        "WEAVIATE_URL": "http://localhost:8080",
        "WEAVIATE_API_KEY": "optional_api_key"
      }
    }
  }
}

Unique Features:

  • Schema-based data modeling (classes and properties)
  • Built-in vectorization modules
  • GraphQL query interface
  • Multi-modal search (text, images, cross-references)
  • Hybrid search combining BM25 and vector search

Vector Database Comparison

FeaturePineconeChromaQdrantWeaviate
HostingManaged onlySelf-hosted / localSelf-hosted + cloudSelf-hosted + cloud
Max Dimensions20,000Unlimited65,535Unlimited
Metadata FilteringYesYesAdvancedGraphQL-based
Hybrid SearchSparse + DenseBasicDense + keywordsBM25 + Dense
Built-in EmbeddingsNoYesNoYes (modules)
Multi-tenancyNamespacesCollectionsNamespacesMulti-tenant classes
Free TierYes (starter)Open sourceOpen sourceOpen source
Best ForProduction SaaSPrototyping, local devHigh-performance RAGSchema-rich applications

RAG Architecture with Database MCP Servers

Combining database MCP servers enables powerful RAG workflows:

Architecture Overview

User Question
     │
     ▼
┌─────────────┐     ┌──────────────────┐
│  AI Client  │────▶│ Vector DB Server │──── Similarity Search
│  (Claude)   │     │  (Pinecone MCP)  │
│             │     └──────────────────┘
│             │
│             │     ┌──────────────────┐
│             │────▶│  SQL DB Server   │──── Structured Data
│             │     │  (Postgres MCP)  │
│             │     └──────────────────┘
│             │
│             │     ┌──────────────────┐
│             │────▶│ Document Server  │──── Source Documents
│  AI Answer  │     │ (Filesystem MCP) │
└─────────────┘     └──────────────────┘

RAG Workflow Example

User: "What were our Q4 revenue figures by product line,
       and how do they compare to analyst expectations?"

Claude's workflow:
1. Vector DB query: Search for "Q4 revenue product line"
   in the earnings reports collection
2. SQL query: SELECT product_line, revenue, quarter
   FROM financials WHERE quarter = 'Q4'
3. Vector DB query: Search for "analyst expectations revenue"
   in the research notes collection
4. Synthesize all results into a comprehensive answer
   with citations to source documents

Security and Access Control

Database Credential Security

PracticeImplementation
Use read-only credentialsCreate DB users with SELECT-only permissions
Connect to replicasPoint MCP servers to read replicas, not primary
Encrypt connectionsAlways use SSL/TLS (?sslmode=require)
Rotate credentialsUse short-lived tokens or rotate passwords regularly
Restrict IP accessAllowlist the MCP server's IP in database firewall rules
Limit query scopeRestrict users to specific schemas, tables, or views

Query Safety

Database MCP servers should implement safeguards:

-- Good: Server adds automatic limits
SELECT * FROM users LIMIT 100;

-- Bad: Unrestricted query could return millions of rows
SELECT * FROM users;

-- Good: Server uses parameterized queries
SELECT * FROM users WHERE email = $1;

-- Bad: SQL injection vulnerability
SELECT * FROM users WHERE email = '${user_input}';

Most well-built database MCP servers:

  • Automatically add LIMIT clauses to queries
  • Use parameterized queries to prevent SQL injection
  • Set statement timeouts to prevent long-running queries
  • Block DDL statements (DROP, ALTER) in read-only mode
  • Log all executed queries for audit purposes

Schema-Level Access Control

For enterprise deployments, restrict AI access at the schema level:

-- Create a restricted user for the MCP server
CREATE USER mcp_readonly WITH PASSWORD 'secure_password';

-- Grant access only to specific schemas
GRANT USAGE ON SCHEMA public TO mcp_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_readonly;

-- Restrict access to sensitive tables
REVOKE SELECT ON users_pii FROM mcp_readonly;
REVOKE SELECT ON payment_details FROM mcp_readonly;

-- Create a view that masks sensitive columns
CREATE VIEW safe_users AS
  SELECT id, first_name, created_at
  FROM users_pii;
GRANT SELECT ON safe_users TO mcp_readonly;

For comprehensive security strategies, see our MCP Security & Compliance guide.

Performance Optimization

Connection Pooling

Database MCP servers should use connection pooling to handle concurrent requests efficiently:

# Example: Python MCP server with connection pooling
import asyncpg

pool = await asyncpg.create_pool(
    dsn="postgresql://user:pass@host/db",
    min_size=2,
    max_size=10,
    command_timeout=30
)

@app.call_tool()
async def execute_query(name: str, arguments: dict):
    async with pool.acquire() as conn:
        rows = await conn.fetch(arguments["query"])
        return format_results(rows)

Query Optimization Tips

When working with AI-generated queries:

  1. Index awareness: Expose index information so the AI can write index-friendly queries
  2. EXPLAIN integration: Let the AI run EXPLAIN ANALYZE on queries to understand performance
  3. Materialized views: Create views for common complex queries the AI might need
  4. Result caching: Cache frequently accessed results to reduce database load
  5. Batch operations: Group multiple reads into single queries when possible

Handling Large Datasets

StrategyDescriptionWhen to Use
PaginationUse LIMIT/OFFSET for sequential accessBrowsing large tables
AggregationSummarize data in the queryAnalytics and reporting
SamplingQuery a random subsetExploratory data analysis
StreamingProcess results in chunksETL workflows
Materialized viewsPre-compute expensive queriesRepeated analytical queries

Common Use Cases

Data Analysis and Reporting

AI assistants with database access can perform sophisticated data analysis:

  • Query sales data and generate trend reports
  • Compare metrics across time periods
  • Identify anomalies in operational data
  • Create executive summaries from raw data

Schema Design and Optimization

Use database MCP servers for schema work:

  • Analyze existing schemas and suggest improvements
  • Generate migration scripts for schema changes
  • Review index usage and suggest new indexes
  • Document database schemas automatically

Data Quality and Governance

AI can help maintain data quality:

  • Identify duplicate records across tables
  • Validate data against business rules
  • Generate data quality reports
  • Suggest data cleanup procedures

Application Development

Developers use database MCP servers to:

  • Prototype queries before writing application code
  • Generate ORM models from database schemas
  • Write and test stored procedures
  • Debug data issues in development environments

Building a Custom Database MCP Server

If existing servers do not meet your needs, here is a starting point for a custom database MCP server:

from mcp.server import Server
from mcp.types import Tool, TextContent
import asyncpg
import json

app = Server("custom-database")

QUERY_TIMEOUT = 30  # seconds
MAX_ROWS = 1000

@app.list_tools()
async def list_tools():
    return [
        Tool(
            name="query",
            description="Execute a read-only SQL query",
            inputSchema={
                "type": "object",
                "properties": {
                    "sql": {
                        "type": "string",
                        "description": "SQL SELECT query to execute"
                    }
                },
                "required": ["sql"]
            }
        ),
        Tool(
            name="list_tables",
            description="List all tables in the database",
            inputSchema={"type": "object", "properties": {}}
        )
    ]

@app.call_tool()
async def call_tool(name: str, arguments: dict):
    if name == "query":
        sql = arguments["sql"].strip()

        # Safety checks
        if not sql.upper().startswith("SELECT"):
            return [TextContent(
                type="text",
                text="Error: Only SELECT queries are allowed"
            )]

        # Add limit if not present
        if "LIMIT" not in sql.upper():
            sql += f" LIMIT {MAX_ROWS}"

        conn = await asyncpg.connect(DATABASE_URL)
        try:
            rows = await asyncio.wait_for(
                conn.fetch(sql),
                timeout=QUERY_TIMEOUT
            )
            result = [dict(row) for row in rows]
            return [TextContent(
                type="text",
                text=json.dumps(result, default=str, indent=2)
            )]
        finally:
            await conn.close()

For complete server building guides, see Build MCP Server in Python or Build MCP Server in Node.js.

Real-World Implementation Patterns

Pattern: AI-Powered Data Exploration

One of the most common use cases is letting AI explore unfamiliar databases:

User: "I need to understand our analytics database.
       Show me what data we have and how it's organized."

Claude's workflow:
1. list_tables() → discover all tables
2. describe_table(each) → understand schemas
3. query("SELECT COUNT(*) FROM each_table") → data volumes
4. Identify relationships between tables (foreign keys, naming patterns)
5. Generate a data dictionary with descriptions and relationships
6. Suggest common queries based on the schema

Pattern: Cross-Database Joins

When data spans multiple databases, AI can correlate information:

User: "Which of our highest-value customers have open
       support tickets?"

Claude's workflow:
1. (Postgres) Query top customers by revenue
2. (MongoDB) Search support tickets for those customer IDs
3. Correlate and present combined results

Pattern: Data Quality Auditing

User: "Check our customer database for data quality issues"

Claude's workflow:
1. query("SELECT COUNT(*) FROM customers WHERE email IS NULL")
2. query("SELECT email, COUNT(*) FROM customers
   GROUP BY email HAVING COUNT(*) > 1") — duplicates
3. query("SELECT * FROM customers
   WHERE phone NOT LIKE '+%'") — invalid phone formats
4. query("SELECT COUNT(*) FROM customers
   WHERE last_activity < NOW() - INTERVAL '2 years'") — stale records
5. Generate data quality report with remediation suggestions

Migration Between Database Types

AI assistants with access to multiple database MCP servers can help with migrations:

SQL to NoSQL Migration

User: "Help me plan a migration from PostgreSQL to MongoDB
       for the user profiles system"

Claude's workflow:
1. (Postgres) describe_table("users") — current schema
2. (Postgres) describe_table("user_preferences") — related tables
3. (Postgres) Analyze query patterns from logs
4. Design MongoDB document structure:
   - Embed user_preferences within user documents
   - Denormalize frequently accessed data
5. Generate migration script
6. Identify queries that need to be rewritten
7. Create a testing plan for the migration

Vector DB Migration

When switching vector databases (e.g., Chroma to Pinecone for production):

Migration workflow:
1. (Chroma) list_collections() — discover all collections
2. (Chroma) For each collection:
   a. Get all vectors with metadata
   b. Export in batches
3. (Pinecone) create_index(matching_dimensions)
4. (Pinecone) upsert(batched_vectors)
5. Verify: Compare query results between old and new

Monitoring and Maintenance

Database Health Monitoring

AI assistants can perform regular health checks:

CheckQueryThreshold
Connection countSELECT count(*) FROM pg_stat_activity< 80% of max
Long-running queriesSELECT * FROM pg_stat_activity WHERE duration > interval '1 min'0 in production
Table bloatSELECT pg_total_relation_size(relid)Monitor growth
Index usageSELECT * FROM pg_stat_user_indexes WHERE idx_scan = 0Remove unused
Replication lagSELECT pg_last_wal_receive_lsn() - pg_last_wal_replay_lsn()< 1MB
Cache hit ratioSELECT sum(blks_hit)/sum(blks_read) FROM pg_stat_database> 99%

Automated Index Recommendations

User: "Analyze query performance and suggest index improvements"

Claude's workflow:
1. (Postgres) Query pg_stat_user_tables for sequential scan counts
2. (Postgres) Query pg_stat_statements for slow queries
3. (Postgres) Run EXPLAIN ANALYZE on the slowest queries
4. Identify columns frequently used in WHERE and JOIN clauses
5. Suggest indexes:
   - CREATE INDEX idx_orders_customer_id ON orders(customer_id)
   - CREATE INDEX idx_orders_created_at ON orders(created_at)
6. Estimate impact based on table size and query frequency

Database MCP Server Selection Guide

Choosing the right database MCP server depends on your specific requirements. Use this decision framework to narrow your options:

If You Need...Best ChoiceWhy
General-purpose SQL accessPostgreSQL MCP (official)Most mature, best security features
Local development and prototypingSQLite MCP (official)Zero setup, file-based
Document-oriented data explorationMongoDB MCPFlexible schema, aggregation pipelines
Semantic search and RAGChroma MCP (local) or Pinecone MCP (production)Purpose-built for embedding workflows
High-performance vector searchQdrant MCPRust-based, advanced filtering
Cache inspection and debuggingRedis MCPDirect access to key-value data
Schema-rich AI applicationsWeaviate MCPBuilt-in vectorization and GraphQL

For most teams getting started with database MCP servers, the combination of the official PostgreSQL server for structured data and Chroma for vector search provides a solid foundation that can be expanded as requirements grow.

What to Read Next

Frequently Asked Questions

What is a database MCP server?

A database MCP server is a Model Context Protocol server that gives AI applications structured access to databases. It exposes tools for querying, inserting, updating, and managing data in SQL databases (Postgres, MySQL, SQLite), NoSQL databases (MongoDB, Redis), or vector databases (Pinecone, Chroma, Qdrant). The AI can then read and write data using natural language, with the server translating requests into proper database queries.

Is it safe to connect an AI to my production database via MCP?

You should exercise extreme caution connecting AI to production databases. Best practices include: (1) use read-only database credentials, (2) connect to a read replica rather than the primary, (3) set query timeouts and row limits, (4) restrict access to specific schemas or tables, and (5) enable query logging for audit trails. For write operations, use a staging environment or implement an approval workflow. Never give an AI unrestricted write access to production data.

Which database MCP servers support read-only mode?

Most database MCP servers support read-only mode. The official Postgres MCP server has a --read-only flag. The SQLite server supports read-only connections. MongoDB MCP servers can be configured with read-only database users. For any database, the most reliable approach is to create a database user with only SELECT/read permissions and use those credentials in the MCP server configuration.

How do vector database MCP servers enable RAG?

Vector database MCP servers enable Retrieval-Augmented Generation (RAG) by exposing tools for similarity search. When an AI needs to answer a question, it generates an embedding for the query, uses the vector DB server to find the most similar documents, retrieves the relevant content, and includes it as context for generating an accurate response. MCP servers for Pinecone, Chroma, Qdrant, and Weaviate all support this workflow.

Can I use MCP to query multiple databases at once?

Yes. MCP clients can connect to multiple database servers simultaneously. You might run a Postgres server for your transactional data, a MongoDB server for your document store, and a Pinecone server for vector search — all in the same session. The AI can intelligently choose which database to query based on the type of information needed.

What is the Postgres MCP server and how do I set it up?

The Postgres MCP server (at @modelcontextprotocol/server-postgres) is an official reference server that connects AI applications to PostgreSQL databases. Set it up by adding it to your MCP client configuration with your database connection string: npx -y @modelcontextprotocol/server-postgres postgresql://user:password@localhost:5432/dbname. It supports schema inspection, SQL queries, and parameterized queries.

How do I handle large query results with database MCP servers?

Large query results can overwhelm the AI's context window. Strategies include: (1) always use LIMIT clauses in SQL queries, (2) configure the MCP server with a maximum row count (many servers default to 100-1000 rows), (3) use pagination with OFFSET/LIMIT, (4) aggregate data in the query rather than fetching raw rows, and (5) use the server's built-in result truncation features.

Can MCP database servers handle database migrations?

Some database MCP servers provide schema modification tools, but running migrations through AI is not recommended for production databases. Instead, use MCP to generate migration files that you review and apply through your normal migration pipeline (Flyway, Alembic, Prisma Migrate, etc.). The AI can analyze your schema, suggest migration steps, and write the migration code — but a human should review and execute it.

What is the difference between using MCP for database access vs. a traditional ORM?

MCP provides an AI-accessible interface to databases, while ORMs provide a programmatic interface for application code. They serve different purposes: MCP enables AI assistants to query and understand your data through natural language, while ORMs handle data access within your application logic. MCP database servers often use raw SQL or database drivers underneath, similar to what an ORM generates.

How do I secure database credentials in MCP server configurations?

Never hardcode credentials in configuration files. Use environment variables to pass connection strings, store credentials in your system's keychain or a secrets manager (AWS Secrets Manager, HashiCorp Vault), use .env files excluded from version control, and consider using short-lived database tokens instead of permanent passwords. For enterprise deployments, integrate with your organization's identity management system.

Related Guides