Skip to main content
Add persistent memory to Claude Code (CLI) and Claude Cowork (desktop app) with the Mem0 plugin. Your agent forgets everything between sessions. This plugin fixes that by connecting to Mem0’s cloud memory layer via MCP, automatically capturing learnings at key lifecycle points, and retrieving relevant context before every response.

Prerequisites

Before setting up Mem0 with Claude Code, ensure you have:
  1. A Mem0 Platform account and API key:
  2. Claude Code CLI or Claude Cowork desktop app installed
  3. Your API key added to your shell profile (persists across sessions):
Confirm it’s set:

Installation

Install the full plugin including MCP server, lifecycle hooks, and SDK skill.
  1. Add the Mem0 marketplace:
  2. Install the plugin:
Claude Cowork desktop app: Open the Cowork tab, click Customize in the sidebar, click Browse plugins, and install Mem0.

Option B: MCP Only

Add the Mem0 MCP server directly with a single command:
This gives you the MCP tools but not the lifecycle hooks or SDK skill.

Option C: Manual MCP Configuration

Add to your Claude Code MCP config (.mcp.json):

Managing the Plugin

Start a new session and ask: “List my mem0 entities” or “Search my memories for hello”. If the mem0 tools appear and respond, you’re all set.

Post-Installation: Run /mem0:onboard

After installing the plugin, start a new Claude Code session and run:
This runs the setup wizard which:
  1. Verifies your API key and MCP connection
  2. Detects and imports project files (CLAUDE.md, AGENTS.md, .cursorrules)
  3. Installs coding-optimized memory categories
  4. Shows your identity (user ID, project scope, branch)
The onboarding is idempotent and safe to re-run anytime. It auto-triggers on first session in a new project, but you can always invoke it manually.

What’s Included

Available MCP Tools

Once installed, the following tools are available in every Claude Code session:

Lifecycle Hooks

When installed via the plugin marketplace, Mem0 hooks into Claude Code’s lifecycle to automatically manage memory: What you type is stored as yours. What Claude produces (session summaries and compaction summaries) is stored as the assistant’s, so its suggestions never become your stated preferences.

Example Workflow

Troubleshooting

  • “Connection failed”: Verify MEM0_API_KEY is set in your shell: echo $MEM0_API_KEY. If empty, add it to your shell profile (see Prerequisites)
  • No tools appearing: Restart your Claude Code session after installation
  • Memories not being captured: Ensure you installed via the plugin marketplace (Option A) for lifecycle hooks. MCP-only installs require manual memory operations
  • “Mem0 Inactive” banner every session: Your API key isn’t persisting. Add export MEM0_API_KEY="m0-..." to your ~/.zshrc (or ~/.bashrc) and run source ~/.zshrc

Mem0 MCP Setup

Detailed MCP configuration for all clients

Codex Integration

Add Mem0 memory to OpenAI Codex workflows
Using Mem0? Star us on GitHub to help more developers discover memory for AI apps.