MongoDB announced on November 24, 2026 a new version of its integration for Mastra, the open-source TypeScript framework for building AI agents. The update lets a Mastra agent run semantic search, keyword search, filtering and reranking against an existing MongoDB collection through a single call, while MongoDB creates and refreshes the embeddings on its own.
The change matters because retrieval code is often the messiest part of an agent project. Teams usually copy operational data into a separate vector store, call an embedding API, merge two result lists and then look up the full records. MongoDB says the new release removes most of that glue code and the sync jobs that come with it.
What changed in the MongoDB integration for Mastra
The release brings five pieces together in the @mastra/mongodb package. Each one handles a step that application code previously had to manage by hand:
- Hybrid Search: semantic matching and keyword matching run as one query, so the app no longer coordinates two searches and merges the output.
- Automated Embedding: MongoDB generates vectors for a chosen text field and for the incoming query text, and keeps them current when documents change.
- Bring Your Own Collection (BYOC): Mastra searches the original collection and returns whole documents, so there is no second retrieval copy and no ID lookups afterwards.
- Pre-filtering: fields declared in
filterFieldsnarrow vector candidates inside$vectorSearch, and the same filter is applied to the keyword side. - Native Reranking: a reranking model reorders the candidate set so the strongest matches come first.
MongoDB recommends BYOC for new Mastra applications, so agents work directly on live operational data instead of a duplicated search copy.
How retrieval worked before this release
According to MongoDB, a Mastra app that wanted to search something like a product catalog by meaning had to set up a dedicated vector collection first. The app then sent text to an embedding service, stored the vectors with metadata, and kept track of source IDs so it could fetch the complete records later.
On top of that, developers were responsible for watching the source data and re-embedding changed fields, using change streams, scheduled jobs or something similar. Every one of those steps was extra code to test and another point where the search copy could fall out of step with the real data.
How the new pieces fit together
Setup now takes two index calls. A vector search index points at the original collection, names a Voyage AI model such as voyage-4 and the field to embed, and lists the fields used for pre-filtering. A second text search index covers the fields used for keyword matching.
At query time, the hybridQuery method accepts the user's plain question as the vector query, since MongoDB now produces the query embedding itself. The same call carries the keyword paths, a reranking model such as rerank-2.5, the number of documents to rerank, hard filters and the final result count.
MongoDB's example is a shopper asking an agent for a good laptop for video editing under a price limit. One request finds descriptions that fit the intent, keeps only in-stock items below the price, reranks the shortlist and returns the top five full product documents.
What it means for developers
For teams already storing application data in MongoDB Atlas, this is a real cut in moving parts. Dropping the separate vector collection also removes the sync pipeline, which is where stale or missing results usually come from in retrieval-augmented agents.
There are trade-offs to weigh. Automated Embedding ties you to Voyage AI models; if you prefer another embedding provider, BYOC still works, but you go back to creating and storing vectors yourself. Reranking also adds a model call per query, so test latency and cost with realistic candidate counts before raising numDocsToRerank.
Pre-filtering deserves early planning. Fields must be declared in filterFields when the index is built, so list price, status, tenant or permission fields up front rather than filtering results in application code later.
The pattern is similar to what MongoDB shipped recently for other agent frameworks, such as its strands-mongodb package for AWS Strands agents. MongoDB is clearly positioning Atlas as the single data layer for agent memory and retrieval across popular toolkits.
How to get started
Install or upgrade the integration with npm install @mastra/mongodb. Check the requirements in MongoDB's Automated Embedding documentation before switching existing indexes over.
Native Reranking needs a MongoDB Atlas cluster on version 9.0 with reranking turned on. If you have not moved yet, see the changes in MongoDB 9.0 and its faster Atlas Search and Vector Search.
A sensible path is to build a BYOC index on a copy of one collection, compare hybrid results against your current pipeline, and then retire the old vector copy.
Conclusion
The updated MongoDB integration for Mastra folds embedding, hybrid search, filtering and reranking into one query over the data an app already has. For TypeScript agent builders on Atlas, it means less retrieval code, no duplicate search collection and fewer chances for agent answers to drift from the real records.
Sources
See my articles more often when you search Google.
