count
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
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": {
"connectionId": "<connectionId>",
"database": "<database>",
"collection": "<collection>"
},
"name": "count"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | A filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count(). | |
| database | Yes | Database name | |
| collection | Yes | Collection name | |
| connectionId | Yes | The 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
| Name | Required | Description | Default |
|---|---|---|---|
| count | Yes | The number of documents in the collection |