run_aggregation_to_file
Run MongoDB aggregation pipelines and store results in a JSON file, returning only metadata (count, path, size) to avoid loading large datasets into the context.
Instructions
Run an aggregation pipeline on a collection and write results to a JSON file on disk. Returns only metadata (document count, file path, file size) instead of the actual documents, which avoids loading large result sets into the context window. Use CLI tools like jq, head, or the Read tool to selectively inspect the output file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | The database name | |
| pipeline | Yes | The aggregation pipeline stages | |
| collection | Yes | The collection name | |
| output_path | Yes | Absolute file path where JSON results will be written |