Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

explain

Read-only

Get execution statistics for MongoDB find, aggregate, and count queries to analyze the query optimizer's chosen plan and troubleshoot performance issues.

Instructions

Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodYesThe method and its arguments to run
databaseYesDatabase name
verbosityNoThe verbosity of the explain plan, defaults to queryPlanner. If the user wants to know how fast is a query in execution time, use executionStats. It supports all verbosities as defined in the MongoDB Driver.queryPlanner
collectionYesCollection name
connectionIdYesThe connection to run the operation against. Use the id returned by one of the connect tools, or "preconfigured" to use the connection string the server was configured with.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodYes
verbosityYes
explainResultYes

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed4 schema fields changedv2.0.0
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / connectionId
      Added value: +{
      +  "description": "The connection to run the operation against. Use the id returned by one of the connect tools, or \"preconfigured\" to use the connection string the server was configured with.",
      +  "type": "string"
      +}
    • changedInput schema / properties / method / items / oneOf
      Previous value: -[
      -  {
      -    "properties": {
      -      "arguments": {
      -        "properties": {
      -          "pipeline": {
      -            "description": "An array of aggregation stages to execute.\nIf the user has asked for a vector search, `$vectorSearch` **MUST** be the first stage of the pipeline, or the first stage of a `$unionWith` subpipeline.\nIf the user has asked for lexical/Atlas search, use `$search` instead of `$text`.\n### Usage Rules for `$vectorSearch`\n- **Index Type Detection:**\n  Use the collection-indexes tool to determine if the target field has a classic vector index (type: 'vector') or an auto-embed index (type: 'autoEmbed').\n- **Classic Vector Search (type: 'vector'):**\n  Use 'queryVector' with embeddings as an array of numbers.\n- **Auto-Embed Vector Search (type: 'autoEmbed'):**\n  Use 'query' - MongoDB automatically generates embeddings at query time. Do NOT use 'queryVector' or 'embeddingParameters' for auto-embed indexes.\n- **Unset embeddings:**\n  Unless the user explicitly requests the embeddings, add an `$unset` stage **at the end of the pipeline** to remove the embedding field and avoid context limits. **The $unset stage in this situation is mandatory**.\n- **Pre-filtering:**\n  If the user requests additional filtering, include filters in `$vectorSearch.filter` only for pre-filter fields in the vector index.\n  NEVER include fields in $vectorSearch.filter that are not part of the vector index.\n- **Post-filtering:**\n  For all remaining filters, add a $match stage after $vectorSearch.\n- If unsure which fields are filterable, use the collection-indexes tool to determine valid prefilter fields.\n- If no requested filters are valid prefilters, omit the filter key from $vectorSearch.\n\n### Usage Rules for `$search`\n- Include the index name, unless you know for a fact there's a default index. If unsure, use the collection-indexes tool to determine the index name.\n- The `$search` stage supports multiple operators, such as 'autocomplete', 'text', 'geoWithin', and others. Choose the approprate operator based on the user's query. If unsure of the exact syntax, consult the MongoDB Atlas Search documentation, which can be found here: https://www.mongodb.com/docs/atlas/atlas-search/operators-and-collectors/\n",
      -            "items": {
      -              "anyOf": [
      -                {
      -                  "properties": {
      -                    "$vectorSearch": {
      -                      "anyOf": [
      -                        {
      -                          "description": "Classic vector search using 'queryVector'. Use this when the indexed field has a classic vector index (type: 'vector'). Note to LLM: Use the collection-indexes tool to verify the target field has a classic vector index before using 'queryVector'.",
      -                          "properties": {
      -                            "exact": {
      -                              "default": false,
      -                              "description": "When true, uses an ENN algorithm, otherwise uses ANN. Using ENN is not compatible with numCandidates, in that case, numCandidates must be left empty.",
      -                              "type": "boolean"
      -                            },
      -                            "filter": {
      -                              "additionalProperties": {},
      -                              "description": "MQL filter that can only use filter fields from the index definition. Note to LLM: If unsure, use the `collection-indexes` tool to learn which fields can be used for filtering.",
      -                              "properties": {},
      -                              "type": "object"
      -                            },
      -                            "index": {
      -                              "description": "Name of the index, as retrieved from the `collection-indexes` tool.",
      -                              "type": "string"
      -                            },
      -                            "limit": {
      -                              "default": 10,
      -                              "exclusiveMinimum": 0,
      -                              "maximum": 9007199254740991,
      -                              "type": "integer"
      -                            },
      -                            "numCandidates": {
      -                              "description": "Number of candidates for the ANN algorithm. Mandatory when exact is false.",
      -                              "exclusiveMinimum": 0,
      -                              "maximum": 9007199254740991,
      -                              "type": "integer"
      -                            },
      -                            "path": {
      -                              "description": "Field, in dot notation, where to search. There must be a vector search index for that field.",
      -                              "type": "string"
      -                            },
      -                            "queryVector": {
      -                              "description": "The vector embeddings to search for when using classic vector search indexes (type: 'vector'). Provide embeddings as an array of numbers. Use this for classic vector indexes. For auto-embed indexes (type: 'autoEmbed'), use 'query' instead.",
      -                              "items": {
      -                                "type": "number"
      -                              },
      -                              "type": "array"
      -                            }
      -                          },
      -                          "required": [
      -                            "index",
      -                            "path",
      -                            "queryVector"
      -                          ],
      -                          "type": "object"
      -                        },
      -                        {
      -                          "description": "Auto-embed vector search using 'query'. Use this when the indexed field has an auto-embed index (type: 'autoEmbed'). Note to LLM: Use the collection-indexes tool to verify the target field has an auto-embed index before using 'query'.",
      -                          "properties": {
      -                            "exact": {
      -                              "default": false,
      -                              "description": "When true, uses an ENN algorithm, otherwise uses ANN. Using ENN is not compatible with numCandidates, in that case, numCandidates must be left empty.",
      -                              "type": "boolean"
      -                            },
      -                            "filter": {
      -                              "additionalProperties": {},
      -                              "description": "MQL filter that can only use filter fields from the index definition. Note to LLM: If unsure, use the `collection-indexes` tool to learn which fields can be used for filtering.",
      -                              "properties": {},
      -                              "type": "object"
      -                            },
      -                            "index": {
      -                              "description": "Name of the index, as retrieved from the `collection-indexes` tool.",
      -                              "type": "string"
      -                            },
      -                            "limit": {
      -                              "default": 10,
      -                              "exclusiveMinimum": 0,
      -                              "maximum": 9007199254740991,
      -                              "type": "integer"
      -                            },
      -                            "model": {
      -                              "description": "The embedding model to use for generating embeddings from the query text. If not specified, defaults to the model configured in the auto-embed index definition.",
      -                              "enum": [
      -                                "voyage-4",
      -                                "voyage-4-large",
      -                                "voyage-4-lite",
      -                                "voyage-code-3"
      -                              ],
      -                              "type": "string"
      -                            },
      -                            "numCandidates": {
      -                              "description": "Number of candidates for the ANN algorithm. Mandatory when exact is false.",
      -                              "exclusiveMinimum": 0,
      -                              "maximum": 9007199254740991,
      -                              "type": "integer"
      -                            },
      -                            "path": {
      -                              "description": "Field, in dot notation, where to search. There must be a vector search index for that field.",
      -                              "type": "string"
      -                            },
      -                            "query": {
      -                              "description": "The query to search for when using auto-embed indexes (type: 'autoEmbed'). MongoDB will automatically generate embeddings for the text at query time. Use this for auto-embed indexes, not 'queryVector'.",
      -                              "properties": {
      -                                "text": {
      -                                  "description": "The text query to search for.",
      -                                  "type": "string"
      -                                }
      -                              },
      -                              "required": [
      -                                "text"
      -                              ],
      -                              "type": "object"
      -                            }
      -                          },
      -                          "required": [
      -                            "index",
      -                            "path",
      -                            "query"
      -                          ],
      -                          "type": "object"
      -                        }
      -                      ]
      -                    }
      -                  },
      -                  "required": [
      -                    "$vectorSearch"
      -                  ],
      -                  "type": "object"
      -                },
      -                {
      -                  "additionalProperties": {},
      -                  "properties": {},
      -                  "type": "object"
      -                }
      -              ]
      -            },
      -            "type": "array"
      -          }
      -        },
      -        "required": [
      -          "pipeline"
      -        ],
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "aggregate",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "properties": {
      -      "arguments": {
      -        "properties": {
      -          "filter": {
      -            "additionalProperties": {},
      -            "description": "The query filter, matching the syntax of the query argument of db.collection.find()",
      -            "properties": {},
      -            "type": "object"
      -          },
      -          "limit": {
      -            "default": 10,
      -            "description": "The maximum number of documents to return",
      -            "type": "number"
      -          },
      -          "projection": {
      -            "additionalProperties": {},
      -            "description": "The projection, matching the syntax of the projection argument of db.collection.find()",
      -            "properties": {},
      -            "type": "object"
      -          },
      -          "sort": {
      -            "additionalProperties": {
      -              "anyOf": [
      -                {
      -                  "const": 1,
      -                  "type": "number"
      -                },
      -                {
      -                  "const": -1,
      -                  "type": "number"
      -                },
      -                {
      -                  "const": "asc",
      -                  "type": "string"
      -                },
      -                {
      -                  "const": "desc",
      -                  "type": "string"
      -                },
      -                {
      -                  "const": "ascending",
      -                  "type": "string"
      -                },
      -                {
      -                  "const": "descending",
      -                  "type": "string"
      -                },
      -                {
      -                  "properties": {
      -                    "$meta": {
      -                      "type": "string"
      -                    }
      -                  },
      -                  "required": [
      -                    "$meta"
      -                  ],
      -                  "type": "object"
      -                }
      -              ],
      -              "description": "The sort key and its direction"
      -            },
      -            "description": "A document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for ascending, -1 for descending).",
      -            "propertyNames": {
      -              "type": "string"
      -            },
      -            "type": "object"
      -          }
      -        },
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "find",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "properties": {
      -      "arguments": {
      -        "properties": {
      -          "query": {
      -            "additionalProperties": {},
      -            "description": "A filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().",
      -            "properties": {},
      -            "type": "object"
      -          }
      -        },
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "count",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "properties": {
      +      "arguments": {
      +        "properties": {
      +          "pipeline": {
      +            "description": "An array of aggregation stages to execute.\n\nIf the user has asked for a vector search, `$vectorSearch` **MUST** be the first stage\nof the pipeline (or the first stage of a `$unionWith` sub-pipeline only when explicitly\ncombining unrelated result sets — for hybrid full-text + vector search, use `$rankFusion`\nor `$scoreFusion` instead, see below).\n\nIf the user has asked for lexical/Atlas search, use `$search` instead of `$text`.\n### Usage Rules for `$vectorSearch`\n- **Index Type Detection:**\n  Use the collection-indexes tool to determine if the target field has a classic vector index (type: 'vector') or an auto-embed index (type: 'autoEmbed').\n- **Classic Vector Search (type: 'vector'):**\n  Use 'queryVector' with embeddings as an array of numbers.\n- **Auto-Embed Vector Search (type: 'autoEmbed'):**\n  Use 'query' - MongoDB automatically generates embeddings at query time. Do NOT use 'queryVector' or 'embeddingParameters' for auto-embed indexes.\n- **Unset embeddings:**\n  Unless the user explicitly requests the embeddings, add an `$unset` stage **at the end of the pipeline** to remove the embedding field and avoid context limits. **The $unset stage in this situation is mandatory**.\n- **Pre-filtering:**\n  If the user requests additional filtering, include filters in `$vectorSearch.filter` only for pre-filter fields in the vector index.\n  NEVER include fields in $vectorSearch.filter that are not part of the vector index.\n- **Post-filtering:**\n  For all remaining filters, add a $match stage after $vectorSearch.\n- If unsure which fields are filterable, use the collection-indexes tool to determine valid prefilter fields.\n- If no requested filters are valid prefilters, omit the filter key from $vectorSearch.\n\n### Usage Rules for `$search`\n- Include the index name, unless you know for a fact there's a default index. If unsure, use the collection-indexes tool to determine the index name.\n- The `$search` stage supports multiple operators, such as 'autocomplete', 'text', 'geoWithin', and others. Choose the appropriate operator based on the user's query. If unsure of the exact syntax, consult the MongoDB Atlas Search documentation, which can be found here: https://www.mongodb.com/docs/atlas/atlas-search/operators-and-collectors/\n\n### Usage Rules for `$rankFusion` and `$scoreFusion` (Hybrid Search)\nUse these stages when the user wants to combine full-text (`$search`) and vector\n(`$vectorSearch`) retrieval into a single fused result set. **Prefer native\nfusion over a `$unionWith` + `$group` workaround** — the workaround averages\nincompatible score scales and produces wrong rankings.\n\n**Which stage to use:**\n- `$rankFusion` (MongoDB 8.0+) — Reciprocal Rank Fusion. The recommended default.\n  Normalizes scores across incompatible scales automatically. No score tuning needed.\n- `$scoreFusion` (MongoDB 8.2+) — Score-based fusion. Use when the user needs explicit\n  per-pipeline weights, score normalisation (sigmoid / minMaxScaler), or a custom\n  combination expression.\n\n**Construction rules:**\n- `$rankFusion` / `$scoreFusion` MUST be the first stage of the top-level pipeline.\n- Sub-pipelines go inside `input.pipelines` as a named map (not an array). Each name\n  must be non-empty, must not start with `$`, and must not contain `.` or null bytes.\n- Allowed stages inside sub-pipelines: `$search`, `$vectorSearch`, `$match`, `$sort`,\n  `$geoNear`, `$skip`, `$limit`. `$project` and `$unset` are NOT allowed inside sub-pipelines.\n- Do field shaping (`$project` / `$unset`) only AFTER the fusion stage, at the root.\n- Both a vectorSearch (or autoEmbed) index AND a search (lexical) index must exist on\n  the collection. Use the collection-indexes tool to confirm both before running a hybrid query.\n- Add a `$limit` stage after the fusion stage to cap the final result set.\n- Add `$unset` at the end to remove embedding fields and avoid context bloat.\n\n### Usage Rules for `$rerank` (Native Reranking)\nUse this stage when the user wants to reorder a set of candidate documents using a cross-encoder reranker model.\n\n**Construction rules:**\n- `$rerank` can be any stage in the pipeline on an Atlas cluster running MongoDB 8.3 or higher.\n- It is recommended to use `$rerank` after a sorted pipeline, e.g. `$search`, `$vectorSearch`, `$rankFusion`, `$scoreFusion`, or [`$match`, `$sort`].\n- $rerank must be enabled via the Native Reranking Project Setting\n- Set `numDocsToRerank` as the number of documents passed into `$rerank`. This will also limit the number of documents returned by `$rerank`\n- Set `path` as a field name or an array of field names that exist in all documents. Use `$match` or `$set` before `$rerank` to validate no fields are missing.\n- Add `$addFields` after `$rerank` to retrieve the reranker score.\n\n**`$rerank` example (recommended default):**\n```javascript\n[\n  {\n    $match: {\n      description: { $exists: true },\n      name: { $exists: true }\n    }\n  },\n  {\n    $sort: {\n      lastUpdated: -1\n    }\n  },\n  {\n    $rerank: {\n      query: {\n        text: \"query text including instructions\"\n      },\n      model: \"rerank-2.5\",\n      numDocsToRerank: 100,\n      path: [\"description\", \"name\"]\n    }\n  },\n  {\n    $addFields: {\n      rerankScore: { $meta: \"score\" }\n    }\n  }\n]\n```\n",
      +            "items": {
      +              "anyOf": [
      +                {
      +                  "properties": {
      +                    "$vectorSearch": {
      +                      "anyOf": [
      +                        {
      +                          "description": "Classic vector search using 'queryVector'. Use this when the indexed field has a classic vector index (type: 'vector'). Note to LLM: Use the collection-indexes tool to verify the target field has a classic vector index before using 'queryVector'.",
      +                          "properties": {
      +                            "exact": {
      +                              "default": false,
      +                              "description": "When true, uses an ENN algorithm, otherwise uses ANN. Using ENN is not compatible with numCandidates, in that case, numCandidates must be left empty.",
      +                              "type": "boolean"
      +                            },
      +                            "filter": {
      +                              "additionalProperties": {},
      +                              "description": "MQL filter that can only use filter fields from the index definition. Note to LLM: If unsure, use the `collection-indexes` tool to learn which fields can be used for filtering.",
      +                              "properties": {},
      +                              "type": "object"
      +                            },
      +                            "index": {
      +                              "description": "Name of the index, as retrieved from the `collection-indexes` tool.",
      +                              "type": "string"
      +                            },
      +                            "limit": {
      +                              "default": 10,
      +                              "exclusiveMinimum": 0,
      +                              "maximum": 9007199254740991,
      +                              "type": "integer"
      +                            },
      +                            "numCandidates": {
      +                              "description": "Number of candidates for the ANN algorithm. Mandatory when exact is false.",
      +                              "exclusiveMinimum": 0,
      +                              "maximum": 9007199254740991,
      +                              "type": "integer"
      +                            },
      +                            "path": {
      +                              "description": "Field, in dot notation, where to search. There must be a vector search index for that field.",
      +                              "type": "string"
      +                            },
      +                            "queryVector": {
      +                              "description": "The vector embeddings to search for when using classic vector search indexes (type: 'vector'). Provide embeddings as an array of numbers. Use this for classic vector indexes. For auto-embed indexes (type: 'autoEmbed'), use 'query' instead.",
      +                              "items": {
      +                                "type": "number"
      +                              },
      +                              "type": "array"
      +                            }
      +                          },
      +                          "required": [
      +                            "index",
      +                            "path",
      +                            "queryVector"
      +                          ],
      +                          "type": "object"
      +                        },
      +                        {
      +                          "description": "Auto-embed vector search using 'query'. Use this when the indexed field has an auto-embed index (type: 'autoEmbed'). Note to LLM: Use the collection-indexes tool to verify the target field has an auto-embed index before using 'query'.",
      +                          "properties": {
      +                            "exact": {
      +                              "default": false,
      +                              "description": "When true, uses an ENN algorithm, otherwise uses ANN. Using ENN is not compatible with numCandidates, in that case, numCandidates must be left empty.",
      +                              "type": "boolean"
      +                            },
      +                            "filter": {
      +                              "additionalProperties": {},
      +                              "description": "MQL filter that can only use filter fields from the index definition. Note to LLM: If unsure, use the `collection-indexes` tool to learn which fields can be used for filtering.",
      +                              "properties": {},
      +                              "type": "object"
      +                            },
      +                            "index": {
      +                              "description": "Name of the index, as retrieved from the `collection-indexes` tool.",
      +                              "type": "string"
      +                            },
      +                            "limit": {
      +                              "default": 10,
      +                              "exclusiveMinimum": 0,
      +                              "maximum": 9007199254740991,
      +                              "type": "integer"
      +                            },
      +                            "model": {
      +                              "description": "The embedding model to use for generating embeddings from the query text. If not specified, defaults to the model configured in the auto-embed index definition.",
      +                              "enum": [
      +                                "voyage-4",
      +                                "voyage-4-large",
      +                                "voyage-4-lite",
      +                                "voyage-code-3"
      +                              ],
      +                              "type": "string"
      +                            },
      +                            "numCandidates": {
      +                              "description": "Number of candidates for the ANN algorithm. Mandatory when exact is false.",
      +                              "exclusiveMinimum": 0,
      +                              "maximum": 9007199254740991,
      +                              "type": "integer"
      +                            },
      +                            "path": {
      +                              "description": "Field, in dot notation, where to search. There must be a vector search index for that field.",
      +                              "type": "string"
      +                            },
      +                            "query": {
      +                              "description": "The query to search for when using auto-embed indexes (type: 'autoEmbed'). MongoDB will automatically generate embeddings for the text at query time. Use this for auto-embed indexes, not 'queryVector'.",
      +                              "properties": {
      +                                "text": {
      +                                  "description": "The text query to search for.",
      +                                  "type": "string"
      +                                }
      +                              },
      +                              "required": [
      +                                "text"
      +                              ],
      +                              "type": "object"
      +                            }
      +                          },
      +                          "required": [
      +                            "index",
      +                            "path",
      +                            "query"
      +                          ],
      +                          "type": "object"
      +                        }
      +                      ]
      +                    }
      +                  },
      +                  "required": [
      +                    "$vectorSearch"
      +                  ],
      +                  "type": "object"
      +                },
      +                {
      +                  "additionalProperties": {},
      +                  "properties": {},
      +                  "type": "object"
      +                }
      +              ]
      +            },
      +            "type": "array"
      +          }
      +        },
      +        "required": [
      +          "pipeline"
      +        ],
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "aggregate",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "properties": {
      +      "arguments": {
      +        "properties": {
      +          "filter": {
      +            "additionalProperties": {},
      +            "description": "The query filter, matching the syntax of the query argument of db.collection.find()",
      +            "properties": {},
      +            "type": "object"
      +          },
      +          "limit": {
      +            "default": 10,
      +            "description": "The maximum number of documents to return",
      +            "type": "number"
      +          },
      +          "projection": {
      +            "additionalProperties": {},
      +            "description": "The projection, matching the syntax of the projection argument of db.collection.find()",
      +            "properties": {},
      +            "type": "object"
      +          },
      +          "sort": {
      +            "additionalProperties": {
      +              "anyOf": [
      +                {
      +                  "const": 1,
      +                  "type": "number"
      +                },
      +                {
      +                  "const": -1,
      +                  "type": "number"
      +                },
      +                {
      +                  "const": "asc",
      +                  "type": "string"
      +                },
      +                {
      +                  "const": "desc",
      +                  "type": "string"
      +                },
      +                {
      +                  "const": "ascending",
      +                  "type": "string"
      +                },
      +                {
      +                  "const": "descending",
      +                  "type": "string"
      +                },
      +                {
      +                  "properties": {
      +                    "$meta": {
      +                      "type": "string"
      +                    }
      +                  },
      +                  "required": [
      +                    "$meta"
      +                  ],
      +                  "type": "object"
      +                }
      +              ],
      +              "description": "The sort key and its direction"
      +            },
      +            "description": "A document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for ascending, -1 for descending).",
      +            "propertyNames": {
      +              "type": "string"
      +            },
      +            "type": "object"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "find",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "properties": {
      +      "arguments": {
      +        "properties": {
      +          "query": {
      +            "additionalProperties": {},
      +            "description": "A filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().",
      +            "properties": {},
      +            "type": "object"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "count",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  }
      +]
    • changedInput schema / required
      Previous value: -[
      -  "database",
      -  "collection",
      -  "method"
      -]New value: +[
      +  "connectionId",
      +  "database",
      +  "collection",
      +  "method"
      +]
  2. Changed2 schema fields changedv1.12.0
    • addedOutput schema / properties / method / enum
      Added value: +[
      +  "aggregate",
      +  "find",
      +  "count"
      +]
    • addedOutput schema / properties / verbosity / enum
      Added value: +[
      +  "queryPlanner",
      +  "queryPlannerExtended",
      +  "executionStats",
      +  "allPlansExecution"
      +]
  3. Changed4 schema fields changedv1.11.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • removedInput schema / properties / method / items / anyOf
      Removed value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "arguments": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "pipeline": {
      -            "description": "An array of aggregation stages to execute.",
      -            "items": {
      -              "additionalProperties": true,
      -              "properties": {},
      -              "type": "object"
      -            },
      -            "type": "array"
      -          },
      -          "responseBytesLimit": {
      -            "default": 1048576,
      -            "description": "The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded. Note to LLM: If the entire aggregation result is required, use the \"export\" tool instead of increasing this limit.",
      -            "type": "number"
      -          }
      -        },
      -        "required": [
      -          "pipeline"
      -        ],
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "aggregate",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "arguments": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "filter": {
      -            "additionalProperties": true,
      -            "description": "The query filter, matching the syntax of the query argument of db.collection.find()",
      -            "properties": {},
      -            "type": "object"
      -          },
      -          "limit": {
      -            "default": 10,
      -            "description": "The maximum number of documents to return",
      -            "type": "number"
      -          },
      -          "projection": {
      -            "additionalProperties": true,
      -            "description": "The projection, matching the syntax of the projection argument of db.collection.find()",
      -            "properties": {},
      -            "type": "object"
      -          },
      -          "responseBytesLimit": {
      -            "default": 1048576,
      -            "description": "The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded. Note to LLM: If the entire query result is required, use the \"export\" tool instead of increasing this limit.",
      -            "type": "number"
      -          },
      -          "sort": {
      -            "additionalProperties": {},
      -            "description": "A document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for ascending, -1 for descending).",
      -            "properties": {},
      -            "type": "object"
      -          }
      -        },
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "find",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "arguments": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "query": {
      -            "additionalProperties": true,
      -            "description": "A filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().",
      -            "properties": {},
      -            "type": "object"
      -          }
      -        },
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "count",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  }
      -]
    • addedInput schema / properties / method / items / oneOf
      Added value: +[
      +  {
      +    "properties": {
      +      "arguments": {
      +        "properties": {
      +          "pipeline": {
      +            "description": "An array of aggregation stages to execute.\nIf the user has asked for a vector search, `$vectorSearch` **MUST** be the first stage of the pipeline, or the first stage of a `$unionWith` subpipeline.\nIf the user has asked for lexical/Atlas search, use `$search` instead of `$text`.\n### Usage Rules for `$vectorSearch`\n- **Index Type Detection:**\n  Use the collection-indexes tool to determine if the target field has a classic vector index (type: 'vector') or an auto-embed index (type: 'autoEmbed').\n- **Classic Vector Search (type: 'vector'):**\n  Use 'queryVector' with embeddings as an array of numbers.\n- **Auto-Embed Vector Search (type: 'autoEmbed'):**\n  Use 'query' - MongoDB automatically generates embeddings at query time. Do NOT use 'queryVector' or 'embeddingParameters' for auto-embed indexes.\n- **Unset embeddings:**\n  Unless the user explicitly requests the embeddings, add an `$unset` stage **at the end of the pipeline** to remove the embedding field and avoid context limits. **The $unset stage in this situation is mandatory**.\n- **Pre-filtering:**\n  If the user requests additional filtering, include filters in `$vectorSearch.filter` only for pre-filter fields in the vector index.\n  NEVER include fields in $vectorSearch.filter that are not part of the vector index.\n- **Post-filtering:**\n  For all remaining filters, add a $match stage after $vectorSearch.\n- If unsure which fields are filterable, use the collection-indexes tool to determine valid prefilter fields.\n- If no requested filters are valid prefilters, omit the filter key from $vectorSearch.\n\n### Usage Rules for `$search`\n- Include the index name, unless you know for a fact there's a default index. If unsure, use the collection-indexes tool to determine the index name.\n- The `$search` stage supports multiple operators, such as 'autocomplete', 'text', 'geoWithin', and others. Choose the approprate operator based on the user's query. If unsure of the exact syntax, consult the MongoDB Atlas Search documentation, which can be found here: https://www.mongodb.com/docs/atlas/atlas-search/operators-and-collectors/\n",
      +            "items": {
      +              "anyOf": [
      +                {
      +                  "properties": {
      +                    "$vectorSearch": {
      +                      "anyOf": [
      +                        {
      +                          "description": "Classic vector search using 'queryVector'. Use this when the indexed field has a classic vector index (type: 'vector'). Note to LLM: Use the collection-indexes tool to verify the target field has a classic vector index before using 'queryVector'.",
      +                          "properties": {
      +                            "exact": {
      +                              "default": false,
      +                              "description": "When true, uses an ENN algorithm, otherwise uses ANN. Using ENN is not compatible with numCandidates, in that case, numCandidates must be left empty.",
      +                              "type": "boolean"
      +                            },
      +                            "filter": {
      +                              "additionalProperties": {},
      +                              "description": "MQL filter that can only use filter fields from the index definition. Note to LLM: If unsure, use the `collection-indexes` tool to learn which fields can be used for filtering.",
      +                              "properties": {},
      +                              "type": "object"
      +                            },
      +                            "index": {
      +                              "description": "Name of the index, as retrieved from the `collection-indexes` tool.",
      +                              "type": "string"
      +                            },
      +                            "limit": {
      +                              "default": 10,
      +                              "exclusiveMinimum": 0,
      +                              "maximum": 9007199254740991,
      +                              "type": "integer"
      +                            },
      +                            "numCandidates": {
      +                              "description": "Number of candidates for the ANN algorithm. Mandatory when exact is false.",
      +                              "exclusiveMinimum": 0,
      +                              "maximum": 9007199254740991,
      +                              "type": "integer"
      +                            },
      +                            "path": {
      +                              "description": "Field, in dot notation, where to search. There must be a vector search index for that field.",
      +                              "type": "string"
      +                            },
      +                            "queryVector": {
      +                              "description": "The vector embeddings to search for when using classic vector search indexes (type: 'vector'). Provide embeddings as an array of numbers. Use this for classic vector indexes. For auto-embed indexes (type: 'autoEmbed'), use 'query' instead.",
      +                              "items": {
      +                                "type": "number"
      +                              },
      +                              "type": "array"
      +                            }
      +                          },
      +                          "required": [
      +                            "index",
      +                            "path",
      +                            "queryVector"
      +                          ],
      +                          "type": "object"
      +                        },
      +                        {
      +                          "description": "Auto-embed vector search using 'query'. Use this when the indexed field has an auto-embed index (type: 'autoEmbed'). Note to LLM: Use the collection-indexes tool to verify the target field has an auto-embed index before using 'query'.",
      +                          "properties": {
      +                            "exact": {
      +                              "default": false,
      +                              "description": "When true, uses an ENN algorithm, otherwise uses ANN. Using ENN is not compatible with numCandidates, in that case, numCandidates must be left empty.",
      +                              "type": "boolean"
      +                            },
      +                            "filter": {
      +                              "additionalProperties": {},
      +                              "description": "MQL filter that can only use filter fields from the index definition. Note to LLM: If unsure, use the `collection-indexes` tool to learn which fields can be used for filtering.",
      +                              "properties": {},
      +                              "type": "object"
      +                            },
      +                            "index": {
      +                              "description": "Name of the index, as retrieved from the `collection-indexes` tool.",
      +                              "type": "string"
      +                            },
      +                            "limit": {
      +                              "default": 10,
      +                              "exclusiveMinimum": 0,
      +                              "maximum": 9007199254740991,
      +                              "type": "integer"
      +                            },
      +                            "model": {
      +                              "description": "The embedding model to use for generating embeddings from the query text. If not specified, defaults to the model configured in the auto-embed index definition.",
      +                              "enum": [
      +                                "voyage-4",
      +                                "voyage-4-large",
      +                                "voyage-4-lite",
      +                                "voyage-code-3"
      +                              ],
      +                              "type": "string"
      +                            },
      +                            "numCandidates": {
      +                              "description": "Number of candidates for the ANN algorithm. Mandatory when exact is false.",
      +                              "exclusiveMinimum": 0,
      +                              "maximum": 9007199254740991,
      +                              "type": "integer"
      +                            },
      +                            "path": {
      +                              "description": "Field, in dot notation, where to search. There must be a vector search index for that field.",
      +                              "type": "string"
      +                            },
      +                            "query": {
      +                              "description": "The query to search for when using auto-embed indexes (type: 'autoEmbed'). MongoDB will automatically generate embeddings for the text at query time. Use this for auto-embed indexes, not 'queryVector'.",
      +                              "properties": {
      +                                "text": {
      +                                  "description": "The text query to search for.",
      +                                  "type": "string"
      +                                }
      +                              },
      +                              "required": [
      +                                "text"
      +                              ],
      +                              "type": "object"
      +                            }
      +                          },
      +                          "required": [
      +                            "index",
      +                            "path",
      +                            "query"
      +                          ],
      +                          "type": "object"
      +                        }
      +                      ]
      +                    }
      +                  },
      +                  "required": [
      +                    "$vectorSearch"
      +                  ],
      +                  "type": "object"
      +                },
      +                {
      +                  "additionalProperties": {},
      +                  "properties": {},
      +                  "type": "object"
      +                }
      +              ]
      +            },
      +            "type": "array"
      +          }
      +        },
      +        "required": [
      +          "pipeline"
      +        ],
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "aggregate",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "properties": {
      +      "arguments": {
      +        "properties": {
      +          "filter": {
      +            "additionalProperties": {},
      +            "description": "The query filter, matching the syntax of the query argument of db.collection.find()",
      +            "properties": {},
      +            "type": "object"
      +          },
      +          "limit": {
      +            "default": 10,
      +            "description": "The maximum number of documents to return",
      +            "type": "number"
      +          },
      +          "projection": {
      +            "additionalProperties": {},
      +            "description": "The projection, matching the syntax of the projection argument of db.collection.find()",
      +            "properties": {},
      +            "type": "object"
      +          },
      +          "sort": {
      +            "additionalProperties": {
      +              "anyOf": [
      +                {
      +                  "const": 1,
      +                  "type": "number"
      +                },
      +                {
      +                  "const": -1,
      +                  "type": "number"
      +                },
      +                {
      +                  "const": "asc",
      +                  "type": "string"
      +                },
      +                {
      +                  "const": "desc",
      +                  "type": "string"
      +                },
      +                {
      +                  "const": "ascending",
      +                  "type": "string"
      +                },
      +                {
      +                  "const": "descending",
      +                  "type": "string"
      +                },
      +                {
      +                  "properties": {
      +                    "$meta": {
      +                      "type": "string"
      +                    }
      +                  },
      +                  "required": [
      +                    "$meta"
      +                  ],
      +                  "type": "object"
      +                }
      +              ],
      +              "description": "The sort key and its direction"
      +            },
      +            "description": "A document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for ascending, -1 for descending).",
      +            "propertyNames": {
      +              "type": "string"
      +            },
      +            "type": "object"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "find",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "properties": {
      +      "arguments": {
      +        "properties": {
      +          "query": {
      +            "additionalProperties": {},
      +            "description": "A filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().",
      +            "properties": {},
      +            "type": "object"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "count",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  }
      +]
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "explainResult": {
      +      "additionalProperties": {},
      +      "propertyNames": {
      +        "type": "string"
      +      },
      +      "type": "object"
      +    },
      +    "method": {
      +      "type": "string"
      +    },
      +    "verbosity": {
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "explainResult",
      +    "method",
      +    "verbosity"
      +  ],
      +  "type": "object"
      +}
  4. Changed2 schema fields changedv1.0.0
    • changedInput schema / properties / method / items / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "arguments": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "pipeline": {
      -            "description": "An array of aggregation stages to execute",
      -            "items": {
      -              "additionalProperties": true,
      -              "properties": {},
      -              "type": "object"
      -            },
      -            "type": "array"
      -          }
      -        },
      -        "required": [
      -          "pipeline"
      -        ],
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "aggregate",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "arguments": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "filter": {
      -            "additionalProperties": true,
      -            "description": "The query filter, matching the syntax of the query argument of db.collection.find()",
      -            "properties": {},
      -            "type": "object"
      -          },
      -          "limit": {
      -            "default": 10,
      -            "description": "The maximum number of documents to return",
      -            "type": "number"
      -          },
      -          "projection": {
      -            "additionalProperties": true,
      -            "description": "The projection, matching the syntax of the projection argument of db.collection.find()",
      -            "properties": {},
      -            "type": "object"
      -          },
      -          "sort": {
      -            "additionalProperties": {},
      -            "description": "A document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for ascending, -1 for descending).",
      -            "properties": {},
      -            "type": "object"
      -          }
      -        },
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "find",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "arguments": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "query": {
      -            "additionalProperties": true,
      -            "description": "A filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().",
      -            "properties": {},
      -            "type": "object"
      -          }
      -        },
      -        "type": "object"
      -      },
      -      "name": {
      -        "const": "count",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "name",
      -      "arguments"
      -    ],
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "arguments": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "pipeline": {
      +            "description": "An array of aggregation stages to execute.",
      +            "items": {
      +              "additionalProperties": true,
      +              "properties": {},
      +              "type": "object"
      +            },
      +            "type": "array"
      +          },
      +          "responseBytesLimit": {
      +            "default": 1048576,
      +            "description": "The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded. Note to LLM: If the entire aggregation result is required, use the \"export\" tool instead of increasing this limit.",
      +            "type": "number"
      +          }
      +        },
      +        "required": [
      +          "pipeline"
      +        ],
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "aggregate",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "arguments": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "filter": {
      +            "additionalProperties": true,
      +            "description": "The query filter, matching the syntax of the query argument of db.collection.find()",
      +            "properties": {},
      +            "type": "object"
      +          },
      +          "limit": {
      +            "default": 10,
      +            "description": "The maximum number of documents to return",
      +            "type": "number"
      +          },
      +          "projection": {
      +            "additionalProperties": true,
      +            "description": "The projection, matching the syntax of the projection argument of db.collection.find()",
      +            "properties": {},
      +            "type": "object"
      +          },
      +          "responseBytesLimit": {
      +            "default": 1048576,
      +            "description": "The maximum number of bytes to return in the response. This value is capped by the server's configured maxBytesPerQuery and cannot be exceeded. Note to LLM: If the entire query result is required, use the \"export\" tool instead of increasing this limit.",
      +            "type": "number"
      +          },
      +          "sort": {
      +            "additionalProperties": {},
      +            "description": "A document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for ascending, -1 for descending).",
      +            "properties": {},
      +            "type": "object"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "find",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "arguments": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "query": {
      +            "additionalProperties": true,
      +            "description": "A filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().",
      +            "properties": {},
      +            "type": "object"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "name": {
      +        "const": "count",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "arguments"
      +    ],
      +    "type": "object"
      +  }
      +]
    • addedInput schema / properties / verbosity
      Added value: +{
      +  "default": "queryPlanner",
      +  "description": "The verbosity of the explain plan, defaults to queryPlanner. If the user wants to know how fast is a query in execution time, use executionStats. It supports all verbosities as defined in the MongoDB Driver.",
      +  "enum": [
      +    "queryPlanner",
      +    "queryPlannerExtended",
      +    "executionStats",
      +    "allPlansExecution"
      +  ],
      +  "type": "string"
      +}
  5. First observed

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds context beyond the annotations by clarifying that the tool returns optimizer plan statistics rather than the actual query results. Annotations already declare readOnlyHint=true and destructiveHint=false, so the safety profile is known. No contradiction exists, but the description does not disclose additional behavioral traits such as whether the query is actually executed or any cost implications.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence of 15 words, front-loaded with the action 'Returns statistics,' and contains zero redundant or filler content. It is appropriately sized for a tool whose parameters are fully documented in the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the high complexity of the input schema (nested method alternatives, vector search rules) and the presence of an output schema and safety annotations, the description is largely sufficient. It clearly states the tool's purpose, and the schema covers all method and parameter details. However, the lack of usage guidance is a notable gap, preventing a perfect score.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with detailed descriptions for all five parameters, including the complex 'method' parameter and verbosity enum. The description itself adds no parameter-level detail, so it earns the baseline score of 3 for relying on the rich schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb and resource: 'Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method.' It clearly indicates this is an EXPLAIN-style tool for a given method. However, it does not explicitly distinguish itself from sibling tools like find or aggregate, though the nature of the output implies it is not the actual query execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention that it should be used instead of find/aggregate/count for analyzing query performance, nor does it state any exclusions or prerequisites. The only hint is the tool name and the phrase 'for the evaluated method,' which is insufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

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/mongodb-js/mongodb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server