How to Add Persistent Memory to CrewAI Agents with AI Memory MCP Server (2026)
Last updated: June 9, 2026 ยท 15 min read
CrewAI is a powerful framework for orchestrating multi-agent workflows where specialized agents collaborate on complex tasks. While CrewAI offers a basic memory system, it has significant limitations for production use. In this guide, we'll show you how to add persistent, cross-session memory to your CrewAI agents using the AI Memory MCP server.
Why CrewAI Agents Need Better Memory
CrewAI's multi-agent architecture is ideal for complex workflows โ research, writing, coding, and analysis tasks where specialized agents hand off work to each other. But even with large context windows, there are fundamental problems with CrewAI's built-in memory:
- Crew-scoped memory: Each crew has isolated memory โ agents in different crews cannot share knowledge
- Fixed embedding model: CrewAI's memory uses a default embedder you cannot customize
- No semantic search: Finding relevant past conversations requires scanning all history
- No cross-framework sharing: A CrewAI agent cannot access memories from a LangChain or LlamaIndex agent
- Limited introspection: No web UI or API to browse, export, or manage stored memories
Persistent memory solves all of these problems. Your crew can remember relevant context from past executions without loading everything into the context window, and share knowledge across crews and frameworks.
CrewAI's Built-In Memory System (And Its Limits)
CrewAI offers a memory system enabled via enable_memory=True:
| Memory Type | How It Works | Limitation |
|---|---|---|
| Short-term Memory | Stores recent task outputs for context within a crew run | Lost when crew finishes execution |
| Long-term Memory | Persists to disk using embeddings for retrieval | Crew-scoped, fixed embedder, no search API |
| Entity Memory | Tracks entities (people, orgs, concepts) mentioned in tasks | Crew-scoped, entity-only, limited retrieval |
| User Memory | Stores user-specific preferences and context | Basic storage, no cross-crew access |
| AI Memory MCP Server | Full-text search + semantic retrieval via MCP | โ Persistent, cross-crew, cross-framework |
The key insight: CrewAI's memory system is tightly coupled to a single crew. It doesn't provide a portable, searchable memory service that works across crews, agents, or frameworks. The AI Memory MCP server provides exactly that โ a persistent, searchable memory backend accessible via the Model Context Protocol.
What is the AI Memory MCP Server?
The aimemory-mcp-server is an open-source MCP (Model Context Protocol) server that provides persistent memory tools for any MCP-compatible client โ including CrewAI, Claude Desktop, Cursor, Windsurf, and 113+ other tools.
- 12 memory tools: save, search, list, update, delete, get, stats, export, import, batch_save, get_all_tags, inject_memory
- SQLite + FTS5: Full-text search with no external dependencies
- Cross-platform: Same memory accessible from ChatGPT, Claude, Gemini, DeepSeek, and CrewAI agents
- Free and open-source: pip install aimemory-mcp-server
Step-by-Step Setup Guide
Step 1: Install the MCP Server
pip install aimemory-mcp-serverThis installs the MCP server with all dependencies. The server uses SQLite for storage โ no database setup required.
Step 2: Configure MCP in Your Project
Create or update your MCP configuration file. For CrewAI projects using MCP tools, add the server to your mcp.json:
{
"mcpServers": {
"ai-memory": {
"command": "aimemory-mcp-server",
"args": [],
"env": {}
}
}
}Step 3: Create CrewAI Agents with Memory Tools
Load the MCP tools and assign them to your CrewAI agents:
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerTool
# Connect to the AI Memory MCP server
memory_tool = MCPServerTool(
command="aimemory-mcp-server",
args=[],
transport="stdio",
)
# Create a researcher agent with memory capabilities
researcher = Agent(
role="Research Analyst",
goal="Research topics and save key findings to memory",
backstory="You are an expert researcher who builds knowledge over time.",
tools=[memory_tool],
verbose=True,
)
# Create a writer agent with memory capabilities
writer = Agent(
role="Content Writer",
goal="Write content using research findings from memory",
backstory="You write compelling content informed by past research.",
tools=[memory_tool],
verbose=True,
)Step 4: Define Tasks That Use Memory
Create tasks that instruct agents to save and retrieve from memory:
research_task = Task(
description="""Research the latest AI agent frameworks and save findings to memory.
Steps:
1. Research current AI agent frameworks
2. Save key findings to memory with tags: ["ai-agents", "frameworks", "research"]
3. Include source references and key comparisons""",
expected_output="A summary of findings saved to memory",
agent=researcher,
)
writing_task = Task(
description="""Write a blog post about AI agent frameworks.
Steps:
1. Search memory for recent research on "AI agent frameworks"
2. Use those findings to inform your writing
3. Save the final draft to memory with tags: ["blog", "ai-agents", "draft"]""",
expected_output="A well-researched blog post draft",
agent=writer,
)Step 5: Run the Crew and Build Memory Over Time
Execute the crew and watch as agents build persistent memory across runs:
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
verbose=True,
)
# First run โ agents research and save to memory
result = crew.kickoff()
# Second run โ agents can access memories from the first run
# The researcher will find past research, the writer can build on past drafts
result = crew.kickoff(inputs={"topic": "MCP server adoption trends"})Cross-Crew Memory Sharing
One of the most powerful patterns is sharing memory across multiple CrewAI crews. Imagine you have:
- Research Crew: Finds and summarizes information on a schedule
- Content Crew: Creates content using the latest research
- Review Crew: Reviews and publishes final content
All three crews can share the same AI Memory MCP server instance. When the Research Crew discovers new information, the Content Crew can immediately access that knowledge:
# Research Crew saves findings
research_crew.kickoff(inputs={"topic": "Q2 2026 AI trends"})
# Content Crew retrieves and uses those findings
content_crew.kickoff(inputs={
"instruction": """Search memory for "Q2 2026 AI trends" research
findings and use them to write a comprehensive blog post."""
})
# Review Crew checks against past research for consistency
review_crew.kickoff(inputs={
"instruction": """Search memory for all Q2 2026 research and verify
the blog post's claims are consistent with the source material."""
})Comparison: CrewAI Memory vs AI Memory MCP Server
| Feature | CrewAI Built-in | AI Memory MCP |
|---|---|---|
| Persistent storage | โก Disk-based (limited) | โ SQLite + FTS5 |
| Cross-crew sharing | โ Per-crew isolation | โ Shared store |
| Full-text search | โ Embeddings only | โ FTS5 powered |
| Cross-platform access | โ CrewAI only | โ 113+ MCP clients |
| Tag organization | โ No | โ Tags + categories |
| Web UI for browsing | โ No | โ aimemory.pro web app |
| Custom embedding model | โก Limited options | โ Full-text first, no lock-in |
| Setup complexity | โ enable_memory=True | โก pip install + config |
| Cost | โ Free (in-process) | โ Free (local server) |
Real-World Use Cases
1. Automated Research Pipeline
A research crew that runs daily, saving key findings to memory. Each run builds on previous research โ the crew avoids re-researching topics it already covered and can reference past findings to identify trends over time.
2. Content Production Pipeline
A content crew where researchers, writers, and editors collaborate. The researcher saves source material to memory, the writer retrieves it for drafting, and the editor checks consistency against the original sources โ all using shared persistent memory.
3. Customer Support with Multi-Agent Handoff
A support crew where a triage agent classifies issues, a specialist agent resolves them, and a follow-up agent checks satisfaction. All agents share memory of the customer's history and current issue, enabling seamless handoffs.
Troubleshooting
MCP server not found
Make sure aimemory-mcp-server is installed in your Python environment. Run which aimemory-mcp-server to verify.
Tools not loading in CrewAI
Check your mcp.json configuration. The server should be listed under mcpServers with the correct command. Also ensure you have crewai-tools with MCP support installed.
Memories not persisting
By default, the MCP server stores data in a local SQLite file. Make sure the server process has write permissions to the working directory.
CrewAI memory conflicts
If you have CrewAI's built-in memory enabled alongside MCP tools, agents may get confused about which memory system to use. We recommend disabling CrewAI's built-in memory (enable_memory=False) when using AI Memory MCP server to avoid conflicts.
Next Steps
- AI Memory MCP Server Setup Guide
- LangChain Memory Integration Guide
- LlamaIndex Memory Integration Guide
- MCP Memory Server: Complete Guide
Start Building with Persistent Memory
AI Memory MCP server is free and open-source. Give your CrewAI agents the memory they deserve.