MongoDB Atlas Data API MCP Server for Cloudflare Workers
12 tools available in the MongoDB MCP server. Each tool can be called by AI assistants to perform specific actions.
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:
Common pipeline stages:
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" } ]
{
"type": "object",
"required": [
"database",
"collection",
"pipeline"
],
"properties": {
"database": {
"type": "string",
"description": "Database name"
},
"pipeline": {
"type": "string",
"description": "Aggregation pipeline as JSON array string"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}mongodb_countCount documents in a MongoDB collection matching a filter.
This is a convenience wrapper around the aggregation pipeline.
Args:
Returns: The count of matching documents.
Example filter: { "status": "active", "type": "premium" }
{
"type": "object",
"required": [
"database",
"collection"
],
"properties": {
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}mongodb_distinctGet distinct values for a field in a MongoDB collection.
This is a convenience wrapper around the aggregation pipeline.
Args:
Returns: Array of distinct values for the specified field.
Example: Get all unique statuses: field="status"
{
"type": "object",
"required": [
"database",
"collection",
"field"
],
"properties": {
"field": {
"type": "string",
"description": "Field name to get distinct values for"
},
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}mongodb_group_byGroup documents by a field and compute aggregates.
This is a convenience wrapper around the $group aggregation stage.
Args:
Returns: Grouped results with computed aggregates.
Example: Group orders by status with total amount groupBy: "status" aggregations: { "count": true, "sum": "amount" }
{
"type": "object",
"required": [
"database",
"collection",
"groupBy"
],
"properties": {
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"groupBy": {
"type": "string",
"description": "Field name to group by"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
},
"aggregations": {
"type": "string",
"description": "Aggregation operations as JSON object"
}
}
}mongodb_find_oneFind a single document in a MongoDB collection.
Args:
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 }
{
"type": "object",
"required": [
"database",
"collection"
],
"properties": {
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
},
"projection": {
"type": "string",
"description": "Projection as JSON string"
}
}
}mongodb_findFind documents in a MongoDB collection.
Args:
Returns: Array of documents matching the filter.
Example filter: { "status": "active" } Example sort: { "createdAt": -1, "name": 1 }
{
"type": "object",
"required": [
"database",
"collection"
],
"properties": {
"skip": {
"type": "integer",
"minimum": 0,
"description": "Documents to skip"
},
"sort": {
"type": "string",
"description": "Sort order as JSON string"
},
"limit": {
"type": "integer",
"default": 20,
"maximum": 1000,
"minimum": 1,
"description": "Maximum documents to return"
},
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
},
"projection": {
"type": "string",
"description": "Projection as JSON string"
}
}
}mongodb_insert_oneInsert a single document into a MongoDB collection.
Args:
Returns: The inserted document ID.
Example document: { "name": "John", "email": "john@example.com", "age": 30 }
{
"type": "object",
"required": [
"database",
"collection",
"document"
],
"properties": {
"database": {
"type": "string",
"description": "Database name"
},
"document": {
"type": "string",
"description": "Document to insert as JSON string"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}mongodb_insert_manyInsert multiple documents into a MongoDB collection.
Args:
Returns: Array of inserted document IDs.
Example documents: [{ "name": "John" }, { "name": "Jane" }]
{
"type": "object",
"required": [
"database",
"collection",
"documents"
],
"properties": {
"database": {
"type": "string",
"description": "Database name"
},
"documents": {
"type": "string",
"description": "Documents to insert as JSON array string"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}mongodb_update_oneUpdate a single document in a MongoDB collection.
Args:
Returns: Update result with matchedCount and modifiedCount.
Example filter: { "_id": "123" } Example update: { "$set": { "status": "active" }, "$inc": { "views": 1 } }
{
"type": "object",
"required": [
"database",
"collection",
"filter",
"update"
],
"properties": {
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"update": {
"type": "string",
"description": "Update operations as JSON string"
},
"upsert": {
"type": "boolean",
"default": false,
"description": "Create if not found"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}mongodb_update_manyUpdate multiple documents in a MongoDB collection.
Args:
Returns: Update result with matchedCount and modifiedCount.
Example filter: { "status": "pending" } Example update: { "$set": { "status": "processed", "processedAt": "2024-01-01" } }
{
"type": "object",
"required": [
"database",
"collection",
"filter",
"update"
],
"properties": {
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"update": {
"type": "string",
"description": "Update operations as JSON string"
},
"upsert": {
"type": "boolean",
"default": false,
"description": "Create if not found"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}mongodb_delete_oneDelete a single document from a MongoDB collection.
Args:
Returns: Delete result with deletedCount.
Example filter: { "_id": "123" }
{
"type": "object",
"required": [
"database",
"collection",
"filter"
],
"properties": {
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}mongodb_delete_manyDelete multiple documents from a MongoDB collection.
Args:
Returns: Delete result with deletedCount.
Example filter: { "status": "archived", "createdAt": { "$lt": "2023-01-01" } }
{
"type": "object",
"required": [
"database",
"collection",
"filter"
],
"properties": {
"filter": {
"type": "string",
"description": "Query filter as JSON string"
},
"database": {
"type": "string",
"description": "Database name"
},
"collection": {
"type": "string",
"description": "Collection name"
}
}
}