Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

count

Read-only

Count documents in a MongoDB collection, using an optional query filter to count specific documents.

Instructions

Gets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoA filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().
databaseYesDatabase name
collectionYesCollection name
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate readOnlyHint=true and destructiveHint=false, so the description does not need to restate safety. However, it adds that it uses db.collection.count() with an optional filter, but it does not disclose performance characteristics, indexing requirements, or behavior with empty collections. Given annotation coverage, this is adequate but not outstanding.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that front-loads the purpose and includes key technical detail. Every word is necessary, and there is no redundancy. It is appropriately concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (counting documents) and the presence of annotations and a full schema, the description is largely complete. It lacks explicit mention of the return value (a number), but that is implied by the operation. For a non-mutating query tool, it provides sufficient context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, meaning all parameters have descriptions in the schema. The description adds that 'query' is optional and matches MongoDB syntax, which is already implied. It does not provide additional semantic details beyond what the schema offers, so it meets the baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool counts documents in a MongoDB collection using db.collection.count() with an optional filter. It uses a specific verb ('gets'), identifies the resource ('documents in a MongoDB collection'), and distinguishes itself from sibling tools like 'find' or 'aggregate' by focusing on count.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions the optional query filter but provides no guidance on when to use this tool versus alternatives like 'aggregate' or 'find'. It does not specify limitations, such as performance with large collections, or when to avoid it. The context is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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

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