MongoDB MCP Server
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Server capabilities have not been inspected yet.
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_databasesB | List all databases in the MongoDB server. |
| list_collectionsA | List all collections in a database. Start here to understand what collections are available before querying. |
| get_schemaA | Infer schema from a collection by analyzing sample documents. Best Practice: Use this before querying to understand collection structure. Example: use_mcp_tool with server_name: "mongodb", tool_name: "get_schema", arguments: { "collection": "users", "sampleSize": 100 } |
| queryA | Execute a read-only query on a collection using MongoDB query syntax. Supports both JSON and CSV output formats:
Best Practices:
Example - Standard Query: use_mcp_tool with server_name: "mongodb", tool_name: "query", arguments: { "collection": "users", "filter": { "age": { "$gte": 21 } }, "projection": { "name": 1, "email": 1 }, "sort": { "name": 1 }, "limit": 100 } Example - CSV Export: use_mcp_tool with server_name: "mongodb", tool_name: "query", arguments: { "collection": "users", "filter": { "active": true }, "outputFormat": "csv", "formatOptions": { "includeHeaders": true, "delimiter": "," } } |
| aggregateA | Execute a read-only aggregation pipeline on a collection. Supported Stages:
Unsafe/Blocked Stages:
Example - User Statistics by Role: use_mcp_tool with server_name: "mongodb", tool_name: "aggregate", arguments: { "collection": "users", "pipeline": [ { "$match": { "active": true } }, { "$group": { "_id": "$role", "count": { "$sum": 1 }, "avgAge": { "$avg": "$age" } }}, { "$sort": { "count": -1 } } ], "limit": 100 } Example - Posts with Author Details: use_mcp_tool with server_name: "mongodb", tool_name: "aggregate", arguments: { "collection": "posts", "pipeline": [ { "$match": { "published": true } }, { "$lookup": { "from": "users", "localField": "authorId", "foreignField": "_id", "as": "author" }}, { "$unwind": "$author" }, { "$project": { "title": 1, "authorName": "$author.name", "publishDate": 1 }} ] } |
| get_collection_statsC | Get detailed statistics about a collection. Returns information about:
|
| get_indexesB | Get information about indexes on a collection. Returns details about:
|
| explain_queryA | Get the execution plan for a query. Helps understand:
Use this to optimize slow queries. |
| get_distinct_valuesA | Get distinct values for a field in a collection. Useful for:
Example: use_mcp_tool with server_name: "mongodb", tool_name: "get_distinct_values", arguments: { "collection": "users", "field": "role", "filter": { "active": true } } |
| sample_dataA | Get a random sample of documents from a collection. Supports both JSON and CSV output formats:
Useful for:
Example - JSON Sample: use_mcp_tool with server_name: "mongodb", tool_name: "sample_data", arguments: { "collection": "users", "size": 50 } Example - CSV Export: use_mcp_tool with server_name: "mongodb", tool_name: "sample_data", arguments: { "collection": "users", "size": 100, "outputFormat": "csv", "formatOptions": { "includeHeaders": true, "delimiter": "," } } |
| count_documentsA | Count documents in a collection that match a filter. Benefits:
Example: use_mcp_tool with server_name: "mongodb", tool_name: "count_documents", arguments: { "collection": "users", "filter": { "active": true, "age": { "$gte": 21 } } } |
| find_by_idsA | Find multiple documents by their IDs in a single request. Advantages:
Example: use_mcp_tool with server_name: "mongodb", tool_name: "find_by_ids", arguments: { "collection": "products", "ids": ["5f8d0f3c", "5f8d0f3d", "5f8d0f3e"], "idField": "_id", "projection": { "name": 1, "price": 1 } } |
| geo_queryA | Execute geospatial queries on a MongoDB collection. Supports:
Requirements:
Examples:
|
| text_searchB | Perform a full-text search on a collection. Requirements:
Features:
Example: use_mcp_tool with server_name: "mongodb", tool_name: "text_search", arguments: { "collection": "articles", "searchText": "mongodb database", "filter": { "published": true }, "limit": 10, "includeScore": true } |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 14 tools
Most tools have distinct purposes, such as aggregate for complex pipelines, query for basic queries, and geo_query for spatial operations. However, query and sample_data both retrieve documents with overlapping functionality, and get_schema might be confused with get_collection_stats for understanding collection structure, leading to some potential confusion.
The naming follows a consistent verb_noun pattern throughout, like count_documents, explain_query, and get_indexes. There are minor deviations with list_collections and list_databases using 'list' instead of 'get', but overall the pattern is clear and predictable.
With 14 tools, this is well-scoped for a MongoDB server, covering a comprehensive range of read-only operations from basic queries to advanced analytics. Each tool serves a specific purpose, such as aggregation, indexing, geospatial queries, and schema analysis, without feeling bloated or incomplete.
The tool set provides complete coverage for read-only MongoDB operations, including querying, aggregation, indexing, geospatial queries, text search, and metadata inspection. There are no obvious gaps; it supports everything from data retrieval to performance optimization and schema exploration for the domain.