← All procedures
mongo.documents.aggregate
Run an aggregation pipeline
MCPCLI- Package
- @procedures/mongo · README
- Path
["mongo","documents","aggregate"]- CLI
mark mongo documents aggregate --pipeline <object[]>- MCP tool
mongo.documents.aggregate on the dev-tools server- As data
{"$proc":["mongo","documents","aggregate"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/mongo"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["mongo","documents","aggregate"], { pipeline: [] });
console.log(JSON.stringify(result));From the command line
$ mark mongo documents aggregate --pipeline <object[]>
As data, in a program
{
"$proc": ["mongo", "documents", "aggregate"],
"input": { "pipeline": [] }
}Input
| Field | Type | Required | Default | Description |
|---|
collection | string | no | | The collection name. It takes the place of metadata.collection. |
database | string | no | | The database name (default: the database of the connection) |
pipeline | object[] | yes | | The aggregation stages, in order (for example [{ $match: {...} }, { $group: {...} }]) |
options | object | no | | The options of the aggregation |
Output
| Field | Type | Required | Default | Description |
|---|
results | object[] | yes | | The documents that the pipeline gave |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"collection": {
"description": "The collection name. It takes the place of metadata.collection.",
"type": "string",
"minLength": 1
},
"database": {
"description": "The database name (default: the database of the connection)",
"type": "string",
"minLength": 1
},
"pipeline": {
"type": "array",
"items": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {}
},
"description": "The aggregation stages, in order (for example [{ $match: {...} }, { $group: {...} }])"
},
"options": {
"description": "The options of the aggregation",
"type": "object",
"properties": {
"allowDiskUse": {
"description": "Allow the use of disk for large stages",
"type": "boolean"
},
"maxTimeMS": {
"description": "The longest run time in milliseconds",
"type": "number"
}
},
"additionalProperties": {}
}
},
"required": [
"pipeline"
]
},
"output": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {}
},
"description": "The documents that the pipeline gave"
}
},
"required": [
"results"
],
"additionalProperties": {}
}
}