Skip to main content
The mongodb MCP adapter connects with a MongoDB URI (mongodb:// or mongodb+srv://) and a default database name. It provides document reads, writes, counts, and aggregation pipelines using Extended JSON filters. Use it for operational data sync, event enrichment, analytics pipelines, webhook ingestion, and document-backed agents — complementary to Firestore on Google Cloud or Postgres for relational reporting.

Prerequisites

  • A MongoDB deployment (self-hosted, Atlas, or compatible) reachable from AgentRuntime
  • A connection URI with credentials (mongodb:// or mongodb+srv://)
  • A default database name for collection operations
  • Database user with read for reporting; readWrite only on collections workflows must modify
  • Atlas IP allowlist or VPC peering configured if the cluster is network-restricted
  • project_contributor access

Connect in AgentRuntime

1

Create a connection

Go to Connections and click New custom connection to create a database connection with your MongoDB URI and default database:
mongodb+srv://user:password@cluster.example.mongodb.net/?retryWrites=true&w=majority
Set URI to the connection string and Database to the default database name (e.g. production). Include authSource in the URI when credentials live in the admin database.
2

Add mongodb MCP instance

Go to MCP, click Add instance for mongodb, wire your connection on Instance config, set the profile active, and save.
3

Test with a document count

Add a workflow with mcp_callmongodb_count_documents on a known collection. Run it to confirm connectivity before production reads or writes.
4

Inspect a sample document (optional)

Run mcp_callmongodb_find_one with an empty filter_json on a test collection to verify collection access and field shapes.
See Authentication for binding connections to MCP instances.

What you can build

  • Lead enrichment — Webhook payload → mongodb_find_one existing contact → merge external API data → mongodb_update_one.
  • Usage analyticsmongodb_aggregate pipeline on events → LLM narrative → scheduled Resend digest.
  • Ticket triagemongodb_find open tickets → LLM priority scoring → mongodb_update_many to set status.
  • Approval-gated deleteshuman_task before mongodb_delete_many on production collections.

Tools

ToolDescription
mongodb_update_manyUpdate many documents in a MongoDB collection
mongodb_count_documentsCount documents in a MongoDB collection with an optional filter
mongodb_aggregateRun an aggregation pipeline on a MongoDB collection
mongodb_delete_oneDelete one document from a MongoDB collection
mongodb_delete_manyDelete many documents from a MongoDB collection
mongodb_findFind documents in a MongoDB collection with an optional filter and limit
mongodb_find_oneFind one document in a MongoDB collection with an optional filter
mongodb_insert_oneInsert one document into a MongoDB collection
mongodb_update_oneUpdate one document in a MongoDB collection

Example

Find recent signups for a welcome workflow:
{
  "id": "recent-signups",
  "type": "mcp_call",
  "name": "Fetch recent signups",
  "tool_name": "mongodb_find",
  "tool_args": {
    "collection": "users",
    "filter_json": "{\"created_at\": {\"$gte\": {\"$date\": \"2026-06-01T00:00:00Z\"}}}",
    "limit": 50
  },
  "timeout_s": 30
}
Reference documents in a downstream step:
{{steps.recent-signups.result.documents}}

Configuration

KeyRequiredDefaultDescription
mongodb_uriYesMongoDB connection URI (mongodb:// or mongodb+srv://)
mongodb_databaseYesDefault database name for collection operations
mongodb_request_timeout_secondsNo30Per-operation timeout in seconds for queries and writes

Troubleshooting

IssueFix
Connection refused / timeoutCheck URI host, Atlas IP allowlist, and VPC peering or network path
Authentication failedVerify username, password, and authSource in the URI
filter_json parse errorsUse Extended JSON syntax; escape quotes in workflow templates
Write rejectedConfirm the DB user has readWrite on the target collection
Aggregation limit exceededDefault pipeline limit is 200 (max 1000); add $limit stages in pipeline_json