MongoDB MCP Server

sample_data

Get a random sample of documents from a collection.

Supports both JSON and CSV output formats:

  • Use outputFormat="json" for standard JSON (default)
  • Use outputFormat="csv" for comma-separated values export

Useful for:

  • Exploratory data analysis
  • Testing with representative data
  • Understanding data distribution
  • Performance testing with realistic data subsets

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": "," } }

Input Schema

NameRequiredDescriptionDefault
collectionYesCollection name
databaseNoDatabase name (optional if default database is configured)
formatOptionsNoFormat-specific options
outputFormatNoOutput format for results (json or csv)
sizeNoNumber of random documents to sample (default: 10)

Input Schema (JSON Schema)

{ "properties": { "collection": { "description": "Collection name", "type": "string" }, "database": { "description": "Database name (optional if default database is configured)", "type": "string" }, "formatOptions": { "description": "Format-specific options", "properties": { "delimiter": { "description": "CSV delimiter character (default: comma)", "type": "string" }, "includeHeaders": { "description": "Whether to include header row in CSV (default: true)", "type": "boolean" } }, "type": "object" }, "outputFormat": { "description": "Output format for results (json or csv)", "enum": [ "json", "csv" ], "type": "string" }, "size": { "description": "Number of random documents to sample (default: 10)", "maximum": 1000, "minimum": 1, "type": "number" } }, "required": [ "collection" ], "type": "object" }