Skip to main content
Glama
MongoDB MCP somente leitura

MongoDB MCP somente leitura

countDocuments

Read-only

Returns the exact number of documents in a MongoDB collection that match a required filter, enabling quick counts for read-only queries.

Instructions

Retorna a contagem exata dos documentos que satisfazem o filtro.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "database": "<database>",
      "collection": "<collection>",
      "filter": "<filter>"
    },
    "name": "countDocuments"
  }
}

Input Schema

NameRequiredDescriptionDefault
filterYesFiltro obrigatório. Use campos, $eq, $ne, $gt, $gte, $lt, $lte, $in, $and e $or.
databaseYes
collectionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.0

TDQS

B3/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, so the safety profile is covered. The description adds the meaningful nuance that the count is 'exata' (exact, i.e. filter-accurate rather than an estimate), but it omits cost/performance implications of exact counting and any error behavior for missing collections.

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

Conciseness4/5

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

A single short sentence with zero filler and the core outcome front-loaded. It is efficient, though its brevity borders on under-specification rather than being genuinely tight.

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

Completeness3/5

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

For a three-required-parameter tool with a nested free-form filter object and no output schema, the description does at least indicate the return value is an exact count. However, it says nothing about database/collection scoping, filter requirements, or failure modes, leaving meaningful gaps.

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

Parameters2/5

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

Schema description coverage is only 33% – just the filter field is documented, while database and collection carry no schema descriptions. The description mentions only 'o filtro' and adds no meaning for the two undocumented connection-scoping parameters, so it fails to compensate for the coverage gap.

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

Purpose4/5

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

The description names a specific verb and resource ('Retorna a contagem exata dos documentos') and the qualifier 'exata' gives it a distinguishing edge over an approximate/estimated count. It does not explicitly contrast with siblings like find or distinct, but an agent can tell what the tool produces.

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

Usage Guidelines2/5

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

There is no when-to-use / when-not-to-use guidance and no reference to alternatives such as find or distinct. The counting intent is implicit in the verb, but nothing states that documents should not be fetched and counted client-side, nor any context about when exact counting is appropriate.

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