MongoDB storage provides flexible schema-less document storage for Mastra with native support for nested data structures.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mastra-ai/mastra/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Configuration
Configuration Options
Unique identifier for the storage instance
MongoDB connection URI (e.g.,
mongodb://localhost:27017 or mongodb+srv://...)Name of the MongoDB database to use
Disable automatic collection and index creation
Usage Examples
Basic Configuration
Access Storage Domains
MongoDB Atlas
Local Development
Storage Domains
MongoDB storage supports all Mastra domains:memory- Thread-based conversation persistenceworkflows- Workflow execution snapshotsobservability- Telemetry and loggingagents- Agent configurationsmcpClients- MCP client configurationsmcpServers- MCP server configurationsblobs- Binary large object storage
Vector Store Support
MongoDB also provides vector search capabilities:Best Practices
Connection String Security
Store MongoDB credentials in environment variables:
Database Naming
Use descriptive database names per environment:
Atlas Deployment
Use MongoDB Atlas for production deployments with automatic backups and scaling.
Indexes
MongoDB automatically creates indexes for common query patterns.
Performance Considerations
Connection Pooling
MongoDB driver automatically manages connection pooling. For high-traffic applications:Write Concerns
Adjust write concerns in connection string for durability vs performance:Related Resources
MongoDB Vector
MongoDB Atlas Vector Search
PostgreSQL Storage
Alternative SQL storage option
MongoDB Docs
Official MongoDB documentation
MongoDB Atlas
Fully managed MongoDB service