#7475·mem0

Claude Code plugin: MCP server ignores the user_id option, so searches use the OS account name

Author: leftosCreated Sep 27, 2026Updated Sep 28, 2026
Labelsintegrationsplugin

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:

json
"env": { "MEM0_CODE_DATA_DIR": "${CLAUDE_PLUGIN_DATA}" }

So mcp_server.py falls through to USERNAME.

Reproduction (Windows 11)

  1. Windows account lefto; set the plugin option user_id to leftos (pluginConfigs["mem0@mem0-plugins"].user_id in ~/.claude/settings.json).
  2. Start a session and let a few flushes run.
  3. 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.py process: no CLAUDE_PLUGIN_OPTION_USER_ID, USERNAME=lefto
  4. The dashboard shows ~1.4k memories under leftos (writes) and a handful under lefto; search_memories with scope: "mine" returns only the lefto ones.

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/mem0 at 94c3fe9 (integrations/claude-code-plugin/.mcp.json is unchanged on current main)
  • Windows 11 Pro 10.0.26200