Skip to main content
Glama

MongoDB MCP Server

by jonfreeland

count_documents

Quickly count documents in a MongoDB collection based on a specified filter. Use this tool to assess data volume, optimize query strategies, and plan pagination efficiently without retrieving full documents.

Instructions

Count documents in a collection that match a filter.

Benefits:

  • More efficient than retrieving full documents
  • Good for understanding data volume
  • Can help planning query strategies
  • Optimize pagination implementation

Example: use_mcp_tool with server_name: "mongodb", tool_name: "count_documents", arguments: { "collection": "users", "filter": { "active": true, "age": { "$gte": 21 } } }

Input Schema

NameRequiredDescriptionDefault
collectionYesCollection name
databaseNoDatabase name (optional if default database is configured)
filterNoMongoDB query filter (optional, defaults to count all documents)

Input Schema (JSON Schema)

{ "properties": { "collection": { "description": "Collection name", "type": "string" }, "database": { "description": "Database name (optional if default database is configured)", "type": "string" }, "filter": { "description": "MongoDB query filter (optional, defaults to count all documents)", "type": "object" } }, "required": [ "collection" ], "type": "object" }

You must be authenticated.

Other Tools from MongoDB MCP Server

Related Tools

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

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