MongoDB MCP Server

find_by_ids

Find multiple documents by their IDs in a single request.

Advantages:

  • More efficient than multiple single document lookups
  • Preserves ID order in results when possible
  • Can filter specific fields with projection
  • Handles both string and ObjectId identifiers

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 } }

Input Schema

NameRequiredDescriptionDefault
collectionYesCollection name
databaseNoDatabase name (optional if default database is configured)
idFieldNoField containing the IDs (default: "_id")
idsYesArray of document IDs to look up
projectionNoMongoDB projection to specify fields to return (optional)

Input Schema (JSON Schema)

{ "properties": { "collection": { "description": "Collection name", "type": "string" }, "database": { "description": "Database name (optional if default database is configured)", "type": "string" }, "idField": { "description": "Field containing the IDs (default: \"_id\")", "type": "string" }, "ids": { "description": "Array of document IDs to look up", "items": { "type": [ "string", "number" ] }, "type": "array" }, "projection": { "description": "MongoDB projection to specify fields to return (optional)", "type": "object" } }, "required": [ "collection", "ids" ], "type": "object" }