MongoDB as a Vector Database for AI Agents A developer built Chez Robot, a recipe assistant agent that uses MongoDB's native Vector Search to handle both semantic retrieval and persistent agent memory, avoiding a separate vector store. The tutorial wires TheMealDB recipe data through VoyageAI embeddings into a MongoDB Atlas vector index, then connects a LangChain retriever to Claude for natural-language question answering. It argues that knowledge retrieval, memory and conversation history can all live in one MongoDB connection string and query language. This article was written by Néstor Daza https://www.linkedin.com/in/nestordaza/ . MongoDB is a general-purpose document database with several modules embedded in its core that turn it into a complete data platform for modern application development. One of them is native Vector Search , allowing MongoDB to manage your data while also powering semantic retrieval and agent memory for your application. You don't need a separate vector store. In this tutorial, you will build a Recipe Assistant Agent called Chez Robot using MongoDB , VoyageAI, Claude, and LangChain. The agent will answer natural language questions like "what can I make with rice and saffron?" by performing a semantic search over a collection of recipes fetched from TheMealDB https://www.themealdb.com/api.php , a free, public recipe API that requires no key. It will also remember your personal preferences across sessions, storing and retrieving that memory from MongoDB using the same vector index. By the end, you will understand how MongoDB handles embeddings and Vector Search, how LangChain wires together retrieval and memory, and how Voyage AI https://www.voyageai.com/ models fit into the pipeline. Before you begin, make sure you have the following: python --version . If you need to install it, follow the Before writing any code, let's cover some basic concepts about Vector Search, the role MongoDB plays, and why it makes sense to use MongoDB as the data backbone of your AI Agentic applications. A MongoDB document stores your application data: fields, arrays, nested objects, etc. A vector-enabled document stores all of that, plus an additional field containing a high-dimensional float array: the embedding. When you run a Vector Search query, MongoDB compares your query embedding against the stored embeddings of all your documents in a collection; the result is a ranked list of documents ordered by semantic similarity, effectively finding elements that have a meaningful relationship with the original query. Vector Search is the backbone of two capabilities that make AI agents genuinely useful in production: knowledge retrieval and persistent memory. Putting everything together, we can build out the Chez Robot app with a full stack that looks like this: php TheMealDB - VoyageAI embeddings - MongoDB Atlas vector index | LangChain retriever | Claude via LangChain | Your app All data concerns in an AI agent, knowledge retrieval, persistent memory, and conversation history, can be stored in MongoDB . One connection string, one query language, one place to manage your data. That is what makes MongoDB a natural fit for agentic applications: it handles both structured and semantic workloads without splitting your infrastructure or adding complexity to your software. Create a project directory and a virtual environment to keep dependencies isolated: mkdir chez-robot-agent cd chez-robot-agent python -m venv .venv source .venv/bin/activate On Windows: .venv\Scripts\activate Install the required packages: pip install langchain langchain-anthropic langchain-mongodb \ langchain-voyageai pymongo requests python-dotenv Here is what each package does: langchain provides the agent framework and the retrieval abstractions. langchain-anthropic is the LangChain integration for Claude. langchain-mongodb provides MongoDBAtlasVectorSearch , which stores and queries embeddings in MongoDB directly from LangChain. langchain-voyageai wraps the Voyage AI embedding API in a LangChain-compatible interface. pymongo is the underlying MongoDB driver. requests is used to fetch recipes from TheMealDB. python-dotenv loads your secrets from a .env file. Add a .gitignore so you never accidentally commit secrets: .env .venv/ pycache / Head to MongoDB Atlas https://www.mongodb.com/cloud/atlas/register/?utm campaign=devrel&utm source=third-party-content&utm medium=cta&utm content=devrel-tutorial-vectorsearch-agents&utm term=nestor.daza and log in to your account. To create your cluster, go to Clusters , click Create , and select the M0 free tier . Choose your preferred cloud provider and region, in Cluster Details , name your cluster chez-robot , and click Create Cluster. It'll take a couple of minutes to get everything up and running. Now you need a database user. In the Security section of the left menu, go to Database & Network Access and click Add New Database User . Choose Password as the authentication method, set a username and a strong password, and assign the Read and Write to any database built-in role. Click Add User . Finally, whitelist your IP address to allow secure access to your cluster. In Network Access , select IP Access List and click Add IP Address . Click Add Current IP Address to whitelist your machine, then click Confirm . You might already have 0.0.0.0/0 configured, which allows access from anywhere; this is useful if you are working from a dynamic IP or want to keep things simple for a local tutorial, but not recommended for production deployments. Create a .env file in the project root: MONGODB URI=