Claude Code plugin: MCP server ignores the user_id option, so searches use the OS account name
Posted by Claude Code on behalf of @leftos.
Summary
In the Claude Code plugin (0.3.3), the user_id plugin option reaches the hook and flush-worker processes but not the MCP server. Memories are therefore written under the configured user_id but searched (search_memories, and scope: mine in particular) under the OS account name.
Details
core/memory_core.py user_id() resolves PLUGIN_OPTION_USER_ID → CLAUDE_PLUGIN_OPTION_USER_ID → MEM0_CODE_USER_ID → MEM0_USER_ID → MEM0_RESOLVED_USER_ID → USER → USERNAME.
Claude Code exports CLAUDE_PLUGIN_OPTION_USER_ID to hook processes, but the MCP server is launched from .mcp.json, which forwards only MEM0_CODE_DATA_DIR:
"env": { "MEM0_CODE_DATA_DIR": "${CLAUDE_PLUGIN_DATA}" }So mcp_server.py falls through to USERNAME.
Reproduction (Windows 11)
- Windows account
lefto; set the plugin optionuser_idtoleftos(pluginConfigs["mem0@mem0-plugins"].user_idin~/.claude/settings.json). - Start a session and let a few flushes run.
- Read the environments of the running mem0 processes (psutil
Process.environ()):- flush workers /
pending/*.running:CLAUDE_PLUGIN_OPTION_USER_ID=leftos - every
core/mcp_server.pyprocess: noCLAUDE_PLUGIN_OPTION_USER_ID,USERNAME=lefto
- flush workers /
- The dashboard shows ~1.4k memories under
leftos(writes) and a handful underlefto;search_memorieswithscope: "mine"returns only theleftoones.
Expected
The MCP server resolves the same user_id as the hooks, for example by forwarding the option through the .mcp.json env block.
Workaround
Set MEM0_CODE_USER_ID in the user's environment (setx MEM0_CODE_USER_ID leftos on Windows) and restart Claude Code.
Versions
- Plugin 0.3.3, installed from a local clone of
mem0ai/mem0at94c3fe9(integrations/claude-code-plugin/.mcp.jsonis unchanged on currentmain) - Windows 11 Pro 10.0.26200
Source: mem0ai/mem0