For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Integrate MongoDB with Langflow

You can integrate MongoDB with Langflow, an open-source visual framework for building AI pipelines and agents. Langflow provides a MongoDB Atlas component that uses MongoDB Vector Search as a vector store, so you can add MongoDB-backed retrieval to your flows without writing code.

The MongoDB Atlas component allows you to perform the following actions:

  • Ingest Data: Write documents and their embeddings to your collection.

  • Similarity Search: Run a similarity search and return matching documents.

  • Configure Agent Tools: Provide agents access to your MongoDB data.

To complete a tutorial that configures Langflow to use MongoDB, see Get Started with the Langflow Integration.

The lfx-bundles package provides optional third-party integrations, including the MongoDB Atlas component. To install the MongoDB dependencies, run the following command:

uv pip install "lfx-bundles[mongodb]"

Alternatively, to install every bundled provider along with Langflow, run the following command:

uv pip install "langflow[bundles]"

Important

Docker Images

To use the MongoDB Atlas component with Docker, use the langflowai/langflow-all image instead of the the default langflowai/langflow image. The langflow-all image includes langflow[bundles], which provides the MongoDB Atlas component. To learn more, see Choose a Langflow Docker image.

To use MongoDB as a vector store in a flow, add the MongoDB Atlas component to your canvas from the MongoDB category, then configure its connection and index parameters in the component inspection panel.

The following tabs describe different ways to use the component in your flows:

To write documents and their embeddings to your collection, connect a data loader and a Split Text component to the Ingest Data input:

File or URL loader → Split Text → MongoDB Atlas

If you use the MongoDB Atlas component to query your collection, the component returns results that you can pass to other components in your flow as a list of JSON objects or as a tabular result. If both formats are available, you can set the format near the component's output port in the visual editor.

The first time you run a search, the component checks whether the MongoDB Vector Search index named in the Index Name parameter exists. If it doesn't, the component creates the index from the Index Field, Number of Dimensions, Similarity, and Quantization parameters, then waits 20 seconds before continuing. Because that wait doesn't confirm the index finished building, a query that runs immediately after index creation can still return empty results.

Tip

To check whether your index has finished building, view its Status in the Atlas UI.

Some parameters are hidden by default in the visual editor. You can view and modify every parameter through the component inspection panel that appears when you select the component.

The MongoDB Atlas component creates a MongoDB Vector Search index on your collection the first time you run a search, if a matching index doesn't already exist. You can also create or inspect this index manually. To learn more, see Create a MongoDB Vector Search Index.

The index uses the following definition, where the path field specifies your Index Field value, the numDimensions field specifies your Number of Dimensions value, and the similarity field specifies your Similarity value:

{
"fields": [
{
"numDimensions": 1536,
"path": "embedding",
"quantization": "scalar",
"similarity": "cosine",
"type": "vector"
}
]
}

If you set a Filter Field value, the component adds a filter type field for that path to the index definition.

Important

Required Values

Select a value for Quantization before you run a search. If you leave the field unset, index creation fails because the component sets the quantization field to null instead of omitting the field.

If your embedding model produces a different number of dimensions than the default 1536, ensure that you set the Number of Dimensions parameter accordingly.

To learn more about using Langflow with MongoDB, see the following resources: