---
title: "MongoDB Integration"
description: "Connect AI agents to MongoDB and MongoDB Atlas. Agents run the full document lifecycle, aggregation pipelines, collection and index management, and Atlas vector search."
url: https://flowrunner.ai/integrations/mongodb
date_modified: 2026-08-01T02:40:32-07:00
---

# MongoDB

[Database](https://flowrunner.ai/integrations/category/databases-warehouses)

Connect AI agents to MongoDB and MongoDB Atlas. Agents run the full document lifecycle, aggregation pipelines, collection and index management, and Atlas vector search.

[Verified](https://flowrunner.ai/integrations/verified "What does verified mean?") · 22 actions · Basic auth · available

[MongoDB website](https://mongodb.com/) · [Platform Documentation](https://www.mongodb.com/docs/) · Capability data verified 2026-08-12

1.  A flow needs a daily rollup from an application collection
2.  Agent runs Aggregate with a pipeline to compute the rollup
3.  Agent reads the aggregated documents as plain JSON
4.  Agent compares the rollup against the prior period
5.  Agent runs Update Document to write the summary back into a config document
6.  The team receives the rollup via Slack
7.  Any Update Documents, Delete Documents, or Drop Collection above a threshold pauses for approval

## What This Integration Enables

Agents read, insert, update, and delete documents, run aggregation pipelines for reporting steps, and manage collections and indexes. On MongoDB Atlas (v6.0.11+ or MongoDB 8.2+ with Atlas Search), agents also run Vector Search and manage search indexes, which turns a collection into a retrieval source for AI steps. Update Document and Update Documents wrap plain field objects in `$set` automatically, so `{"status":"archived"}` updates one field instead of replacing the whole document; Replace Document is the explicit path for a full replacement. The connect-per-call model keeps each operation isolated.

### Without FlowRunner

**Aggregations run manually**: Someone runs a pipeline in a shell and pastes results into a report

**Empty-filter danger**: An update or delete with an empty filter touches every document

**ObjectId friction**: Wire-format ObjectId and Date values complicate every integration

### With FlowRunner

**Aggregations in the flow**: The agent runs the pipeline and routes the result onward automatically

**Filters are required**: Update Documents and Delete Documents refuse to run without a filter

**Plain JSON both ways**: ObjectId, Date, and Decimal128 convert transparently for the agent

## Use Case Scenarios

### Reporting rollups from a live collection

An agent runs Aggregate with a `$match` and `$group` pipeline to compute daily order totals, reads the result, and writes it back to a per-tenant config document with Update Document so the application can read the summary directly. The rollup that used to be a manual shell command now runs on schedule inside the flow.

### Retrieval for an AI step (Atlas)

On an Atlas cluster, an agent embeds an incoming question, runs Vector Search against a pre-created vector index, and passes the nearest documents to a downstream AI step as grounding context. The collection becomes a governed retrieval source without a separate vector store.

### Cleanup with a human gate

An agent identifies stale documents to remove. Before it runs Delete Documents or Drop Collection, it does not act on its own. It routes the proposed cleanup for approval and runs it only after a person confirms.

## Human-in-Loop Highlight

The safety rule that matters most in MongoDB is the empty filter: a Delete Documents or Update Documents with no filter would touch every document in the collection, and Drop Collection removes a collection outright. FlowRunner's answer is human-in-the-loop, an execution pattern where the agent pauses on its own, assembles the context and the choices, routes to a human on their preferred channel, and resumes the moment they respond. When an Update Documents or Delete Documents would affect more documents than the configured threshold, or when a flow reaches Drop Collection, the agent pauses and asks through Slack: "This Delete Documents on `sessions` matches 12,400 documents. Here is the filter and a sample. Approve, narrow the filter, or cancel?" The operation runs only after a person confirms, with the approver and timestamp captured in the run log. A connector can run any command; an orchestration layer knows which commands should stop and ask.

Agent processes routinely

Detects exception requiring judgment

Clear match Continues automatically

Ambiguous Routes to human via Slack

Human decides

Agent resumes with decision

## Agent Capabilities

22 actions

### Documents

9

-   **Find Documents** Queries with full MongoDB filter syntax, projection, sorting, and limit and skip pagination (default limit 100).
-   **Find One Document** Returns the first matching document, or \`null\`, with optional projection.
-   **Insert Document** Inserts one document and returns the generated \`\_id\` as a string.
-   **Insert Documents** Bulk-inserts an array of documents in a single call.
-   **Update Document** Updates the first matching document with update operators; plain field objects are auto-wrapped in \`$set\`, with optional upsert.
-   **Update Documents** Updates all matching documents. A non-empty filter is required.
-   **Replace Document** Replaces the entire matched document with a new one, for intentional full replacement.
-   **Delete Document** Deletes the first matching document. A non-empty filter is required.
-   **Delete Documents** Deletes all matching documents. A non-empty filter is required.

### Aggregation

3

-   **Count Documents** Counts documents matching a filter; an empty filter counts all.
-   **Distinct Values** Returns the distinct values of a field across matching documents, with dot notation supported.
-   **Aggregate** Runs an aggregation pipeline with \`allowDiskUse: true\`, for reporting and analytics steps.

### Collections

3

-   **List Collections** Lists all collections and views in the database with their types.
-   **Create Collection** Explicitly creates a collection.
-   **Drop Collection** Permanently deletes a collection with all its documents and indexes. This cannot be undone.

### Indexes

2

-   **Create Index** Creates an index from a keys spec with options such as \`unique\`, \`sparse\`, and \`expireAfterSeconds\` for TTL.
-   **List Indexes** Lists all indexes on a collection.

### Vector Search

5

-   **Vector Search** Runs an Atlas \`$vectorSearch\` query and returns the nearest documents to a query vector, each annotated with a relevance score. Requires a pre-created vector search index on Atlas.
-   **Create Search Index** Creates an Atlas Search or Vector Search index from a fields definition. Index builds are asynchronous.
-   **List Search Indexes** Lists all search and vector-search indexes on a collection with name, type, build status, and definition.
-   **Update Search Index** Replaces an existing search index's definition by name; the index is rebuilt asynchronously.
-   **Drop Search Index** Permanently deletes a search index by name. Documents are unaffected.

## Frequently Asked Questions

### What can FlowRunner do with MongoDB?

FlowRunner agents can run Find Documents, Find One Document, and Insert Document in MongoDB, plus 19 more actions.

### Does connecting MongoDB to FlowRunner require OAuth?

No. MongoDB connects to FlowRunner with basic authentication (a username and password), no OAuth flow required.

### Can MongoDB trigger a FlowRunner workflow automatically?

MongoDB doesn't currently expose triggers in FlowRunner. It connects as an action step inside workflows started by another trigger.

**Work at MongoDB?** This integration exposes MongoDB to AI agents on every FlowRunner plan, including through MCP, at no cost to you. [See what FlowRunner offers integration partners](https://flowrunner.ai/integrations/partners), including how to keep this page current.

---
Markdown version of https://flowrunner.ai/integrations/mongodb. Site index: https://flowrunner.ai/llms.txt
