Overview
- MCP Server — Connect to Mem0’s remote MCP server for memory tools (add, search, update, delete)
- Memory Protocol Skill — Instructs the agent to retrieve memories at task start, store learnings on completion, and capture session state before context loss
- Plugin Marketplace — Install via Codex’s repo-level or personal plugin marketplace
- Zero local dependencies — Cloud-hosted MCP server, no local setup required
Prerequisites
Before setting up Mem0 with Codex, ensure you have:-
A Mem0 Platform account and API key:
- Sign up at app.mem0.ai
- Get your API key (starts with
m0-)
- OpenAI Codex access
- Your API key exported in your shell:
Installation
Option A — Repo Marketplace (Recommended for Teams)
Add a.agents/plugins/marketplace.json to your repository root:
Option B — Personal Marketplace
Add to~/.agents/plugins/marketplace.json:
Option C — Manual MCP Configuration
Add to your Codex MCP config:Start a new Codex task and ask: “List my mem0 entities” or “Search my memories for hello”. If the
mem0 tools appear and respond, you’re all set.What’s Included
| Component | Plugin Install | MCP Only |
|---|---|---|
| MCP Server (9 memory tools) | Yes | Yes |
| Memory Protocol Skill | Yes | No |
| Mem0 SDK Skill | Yes | No |
Available MCP Tools
Once installed, the following tools are available in every Codex session:| Tool | Description |
|---|---|
add_memory | Save text or conversation history for a user/agent |
search_memories | Semantic search across memories with filters |
get_memories | List memories with filters and pagination |
get_memory | Retrieve a specific memory by ID |
update_memory | Overwrite a memory’s text by ID |
delete_memory | Delete a single memory by ID |
delete_all_memories | Bulk delete all memories in scope |
delete_entities | Delete a user/agent/app/run entity and its memories |
list_entities | List users/agents/apps/runs stored in Mem0 |
Memory Protocol Skill
Codex uses a skill-based approach instead of lifecycle hooks. When installed via the plugin marketplace, the memory protocol skill instructs the agent to:On Every New Task
- Call
search_memorieswith a query related to the current task to load relevant context - Review returned memories to understand what was learned in prior sessions
- Optionally call
get_memoriesto browse all stored memories
After Completing Significant Work
Store key learnings usingadd_memory with structured metadata:
| What to store | Metadata type |
|---|---|
| Architectural decisions | {"type": "decision"} |
| Strategies that worked | {"type": "task_learning"} |
| Failed approaches | {"type": "anti_pattern"} |
| User preferences observed | {"type": "user_preference"} |
| Environment discoveries | {"type": "environmental"} |
| Conventions established | {"type": "convention"} |
Before Losing Context
Store a comprehensive session summary including goals, accomplishments, decisions, files modified, and current state with metadata{"type": "session_state"}.
Plugin Manifest
The Codex plugin manifest (.codex-plugin/plugin.json) follows the Codex plugin specification:
Example Workflow
Troubleshooting
- “Connection failed” — Verify
MEM0_API_KEYis set in your shell:echo $MEM0_API_KEY - No tools appearing — Restart your Codex session after plugin installation
- Plugin not found — Ensure
.agents/plugins/marketplace.jsonis at the repository root andsource.pathpoints to the correct plugin directory - Skills not loading — Verify the
skillsfield inplugin.jsonpoints to a valid directory containingSKILL.mdfiles
Mem0 MCP Setup
Detailed MCP configuration for all clients
Claude Code Integration
Add Mem0 memory to Claude Code workflows