Skip to main content
Glama
shibbirweb

mcp-db-read-only

by shibbirweb

Count Documents

count_documents
Read-onlyIdempotent

Count documents in a MongoDB collection matching a specified filter, returning the total number of records that meet the query criteria.

Instructions

Count documents in a MongoDB collection that match a filter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoQuery filter as MongoDB Extended JSON, e.g. {"status": "active", "_id": {"$oid": "..."}}
databaseNoOptional database to read from for this call only, without changing the active connection
collectionYesCollection name

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint false, so the safety profile is covered. The description adds the filtering behavior, but it does not mention what the call returns, that an omitted filter counts the whole collection, or any cost/performance caveats. No contradiction with annotations.

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?

A single, front-loaded sentence with no filler. Every word contributes to the meaning: what is counted, where, and under what condition.

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?

For a simple read-only counting operation, the schema covers all parameters and annotations cover side effects. The main gap is that the description does not explicitly state that the result is a numeric count or what happens when filter is omitted, but with no output schema and an obvious count return this is a minor omission.

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 description coverage is 100%, with each parameter (filter, database, collection) already documented, including a MongoDB Extended JSON example for filter. The description adds no semantic information about parameters that is not already in the schema, so the baseline of 3 applies.

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 uses a specific verb ('Count'), names the exact resource (documents in a MongoDB collection), and adds a filtering condition. This distinguishes it from siblings like find_documents or aggregate, which retrieve or process documents rather than return a 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 implies the use case: use this tool when only the number of matching documents is needed. However, it does not explicitly tell the agent when to prefer count_documents over find_documents or aggregate, and it mentions no exclusions or alternatives.

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