MongoDB MCP Server

get_schema

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 }

Input Schema

NameRequiredDescriptionDefault
collectionYesCollection name
databaseNoDatabase name (optional if default database is configured)
sampleSizeNoNumber of documents to sample (default: 100)

Input Schema (JSON Schema)

{ "properties": { "collection": { "description": "Collection name", "type": "string" }, "database": { "description": "Database name (optional if default database is configured)", "type": "string" }, "sampleSize": { "description": "Number of documents to sample (default: 100)", "maximum": 1000, "minimum": 1, "type": "number" } }, "required": [ "collection" ], "type": "object" }