MongoDB MCP Server

get_distinct_values

Get distinct values for a field in a collection.

Useful for:

  • Understanding data distribution
  • Finding unique categories
  • Data quality checks
  • Identifying outliers

Example: use_mcp_tool with server_name: "mongodb", tool_name: "get_distinct_values", arguments: { "collection": "users", "field": "role", "filter": { "active": true } }

Input Schema

NameRequiredDescriptionDefault
collectionYesCollection name
databaseNoDatabase name (optional if default database is configured)
fieldYesField name to get distinct values for
filterNoMongoDB query filter to apply before getting distinct values (optional)

Input Schema (JSON Schema)

{ "properties": { "collection": { "description": "Collection name", "type": "string" }, "database": { "description": "Database name (optional if default database is configured)", "type": "string" }, "field": { "description": "Field name to get distinct values for", "type": "string" }, "filter": { "description": "MongoDB query filter to apply before getting distinct values (optional)", "type": "object" } }, "required": [ "collection", "field" ], "type": "object" }