Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

count

Read-only

Get the total number of documents in a MongoDB collection, using an optional query filter to narrow results.

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
connectionIdYesThe connection to run the operation against. Use the id returned by one of the connect tools, or "preconfigured" to use the connection string the server was configured with.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesThe number of documents in the collection
Behavior3/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, establishing this as a safe read operation. The description adds the underlying method db.collection.count() and clarifies the query parameter, but does not disclose additional behavioral traits like performance implications or consistency guarantees. Given the annotations, the extra context is marginal.

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 concise sentence, front-loading the core functionality ('Gets the number of documents') and providing relevant detail about the method and filter. There is no unnecessary repetition or wasted words.

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

Completeness5/5

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

Given the tool's simplicity, the annotations covering safety, and the presence of an output schema, the description is complete. It explains the primary purpose and the optional filter, and does not leave critical gaps for a count operation.

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?

All four parameters have descriptions in the schema (100% coverage), so the baseline is 3. The description mentions query is an optional filter, which aligns with the schema but adds no new semantic information beyond what's already documented.

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 a specific verb and resource. It differentiates from siblings like find and aggregate by focusing on count, and mentions the optional query filter. This fully clarifies what the tool does.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool (when you need a document count, optionally filtered), but does not explicitly mention alternatives or when not to use it. It lacks exclusion scenarios, so it falls short of a perfect score but is still clear.

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