MongoDB Atlas Data API MCP Server for Cloudflare Workers
Test MongoDB tools directly in your browser. Select a tool and provide inputs to see the results.
Create a free account to test MongoDB tools interactively. No credit card required.
mongodb_aggregateRun an aggregation pipeline on a MongoDB collection. The aggregation pipeline is MongoDB's powerful data processing framework. Each stage transforms the documents as they pass through the pipeline. Args: - database: Database name (required) - collection: Collection name (required) - pipeline: Aggregation pipeline as JSON array of stage objects (required) Common pipeline stages: - $match: Filter documents (like find) - $group: Group documents and compute aggregates - $sort: Sort documents - $limit: Limit number of documents - $skip: Skip documents - $project: Reshape documents (include/exclude/compute fields) - $unwind: Deconstruct array fields - $lookup: Join with another collection - $count: Count documents - $addFields: Add computed fields Example pipeline (count by status): [ { "$match": { "active": true } }, { "$group": { "_id": "$status", "count": { "$sum": 1 } } }, { "$sort": { "count": -1 } } ] Example pipeline (join with lookup): [ { "$match": { "orderId": "123" } }, { "$lookup": { "from": "customers", "localField": "customerId", "foreignField": "_id", "as": "customer" }}, { "$unwind": "$customer" } ]
mongodb_countCount documents in a MongoDB collection matching a filter. This is a convenience wrapper around the aggregation pipeline. Args: - database: Database name (required) - collection: Collection name (required) - filter: Query filter as JSON object (optional, defaults to {} for all documents) Returns: The count of matching documents. Example filter: { "status": "active", "type": "premium" }
mongodb_distinctGet distinct values for a field in a MongoDB collection. This is a convenience wrapper around the aggregation pipeline. Args: - database: Database name (required) - collection: Collection name (required) - field: Field name to get distinct values for (required) - filter: Query filter as JSON object (optional) Returns: Array of distinct values for the specified field. Example: Get all unique statuses: field="status"
mongodb_group_byGroup documents by a field and compute aggregates. This is a convenience wrapper around the $group aggregation stage. Args: - database: Database name (required) - collection: Collection name (required) - groupBy: Field name to group by (required) - filter: Query filter as JSON object (optional) - aggregations: JSON object with aggregation operations (optional) - count: true to include count - sum: field name to sum - avg: field name to average - min: field name to get minimum - max: field name to get maximum Returns: Grouped results with computed aggregates. Example: Group orders by status with total amount groupBy: "status" aggregations: { "count": true, "sum": "amount" }
mongodb_find_oneFind a single document in a MongoDB collection. Args: - database: Database name (required) - collection: Collection name (required) - filter: Query filter as JSON object (optional, defaults to {}) - projection: Fields to include/exclude as JSON object (optional) Returns: The first document matching the filter, or null if not found. Example filter: { "status": "active", "age": { "$gte": 18 } } Example projection: { "name": 1, "email": 1, "_id": 0 }
mongodb_findFind documents in a MongoDB collection. Args: - database: Database name (required) - collection: Collection name (required) - filter: Query filter as JSON object (optional, defaults to {}) - projection: Fields to include/exclude as JSON object (optional) - sort: Sort order as JSON object (optional, e.g., { "createdAt": -1 }) - limit: Maximum number of documents to return (optional, default: 20) - skip: Number of documents to skip (optional) Returns: Array of documents matching the filter. Example filter: { "status": "active" } Example sort: { "createdAt": -1, "name": 1 }
mongodb_insert_oneInsert a single document into a MongoDB collection. Args: - database: Database name (required) - collection: Collection name (required) - document: Document to insert as JSON object (required) Returns: The inserted document ID. Example document: { "name": "John", "email": "john@example.com", "age": 30 }
mongodb_insert_manyInsert multiple documents into a MongoDB collection. Args: - database: Database name (required) - collection: Collection name (required) - documents: Array of documents to insert as JSON array (required) Returns: Array of inserted document IDs. Example documents: [{ "name": "John" }, { "name": "Jane" }]
mongodb_update_oneUpdate a single document in a MongoDB collection. Args: - database: Database name (required) - collection: Collection name (required) - filter: Query filter to find the document (required) - update: Update operations (required, use $set, $unset, etc.) - upsert: Create document if not found (optional, default: false) Returns: Update result with matchedCount and modifiedCount. Example filter: { "_id": "123" } Example update: { "$set": { "status": "active" }, "$inc": { "views": 1 } }
mongodb_update_manyUpdate multiple documents in a MongoDB collection. Args: - database: Database name (required) - collection: Collection name (required) - filter: Query filter to find documents (required) - update: Update operations (required, use $set, $unset, etc.) - upsert: Create document if not found (optional, default: false) Returns: Update result with matchedCount and modifiedCount. Example filter: { "status": "pending" } Example update: { "$set": { "status": "processed", "processedAt": "2024-01-01" } }
mongodb_delete_oneDelete a single document from a MongoDB collection. Args: - database: Database name (required) - collection: Collection name (required) - filter: Query filter to find the document (required) Returns: Delete result with deletedCount. Example filter: { "_id": "123" }
mongodb_delete_manyDelete multiple documents from a MongoDB collection. Args: - database: Database name (required) - collection: Collection name (required) - filter: Query filter to find documents (required) Returns: Delete result with deletedCount. Example filter: { "status": "archived", "createdAt": { "$lt": "2023-01-01" } }
mongodb_aggregate{
"database": "example_database",
"pipeline": "example_pipeline",
"collection": "example_collection"
}mongodb_count{
"filter": "example_filter",
"database": "example_database",
"collection": "example_collection"
}mongodb_distinct{
"field": "example_field",
"filter": "example_filter",
"database": "example_database",
"collection": "example_collection"
}