Overview
Integrating MemMachine with CrewAI empowers your agents with a persistent memory layer. Unlike standard session memory, this integration allows your crews to remember past interactions, learn user preferences, and maintain deep context across multiple tasks and sessions.Configuration
The integration is primarily managed through environment variables. You can set these in your.env file or export them directly in your shell:
| Variable | Description | Default |
|---|---|---|
MEMORY_BACKEND_URL | The URL of your MemMachine backend service | http://localhost:8080 |
CREWAI_ORG_ID | Your organization identifier | crewai_org |
CREWAI_PROJECT_ID | Your project identifier | crewai_project |
CREWAI_USER_ID | (Optional) Scopes memory to a specific user | None |
CREWAI_SESSION_ID | (Optional) Scopes memory to a specific session | None |
Initialize Memory Tools
The
create_memmachine_tools helper simplifies the setup. This will return a list of tools that agents can use to add and search their memory.Assign Tools to Agents
Pass the
memmachine_tools list to your CrewAI agents. Agents will use these tools automatically when they need to store a new finding or recall a past preference.Advanced Usage
Shared Team Memory
If you want multiple agents to share the same knowledge pool, initialize the tools with agroup_id. This is ideal for collaborative agents where a “Writer” needs to recall information stored by a “Researcher.”
Manual Memory Management
For more granular control, you can use theMemMachineTools class directly without the CrewAI agent wrapper.
Pro Tip: Use clear
user_id or session_id identifiers to prevent “memory bleed” between different users or unrelated tasks. Requirements
- MemMachine Server: Must be reachable at the
MEMORY_BACKEND_URL. - Python: 3.10 or higher.
- Framework: CrewAI and
crewai-tools.

