MemNexus
GuidesIntegrations

Claude Code

Set up MemNexus memory in Claude Code (CLI) via MCP.

Claude Code supports MCP servers, letting it access MemNexus memory during coding sessions. This means Claude Code can remember your project context, coding preferences, and past debugging sessions.

Prerequisites

You must have Claude Code installed and a MemNexus API key before proceeding. If you do not have an API key, get started free to create one.

Setup

1. Install the CLI and log in

npm install -g @memnexus-ai/cli
mx auth login

mx auth login stores your API key in ~/.memnexus/config.json, so it never appears in any config file you might share with your team.

2. Add the MCP server

mx setup claude-code

This writes .mcp.json in your project root (a file you can share with your team) and installs the MemNexus slash commands (/mx-save, /mx-checkpoint, /mx-buildcontext). The MCP entry launches the bridge with mx mcp serve, which forwards requests to the hosted MemNexus MCP server using your stored key. For reference, the entry it writes looks like this:

{
  "mcpServers": {
    "memnexus": {
      "type": "stdio",
      "command": "mx",
      "args": ["mcp", "serve"]
    }
  }
}

Because the API key lives in ~/.memnexus/config.json and not in .mcp.json, the config is safe to commit. Teammates run mx auth login with their own key and share the same file.

3. Verify

Start a Claude Code session and ask Claude to call initialize_session. It should return a working memory brief with your recent activity. If this is your first session, it will return a fresh start message — that is expected.

What Claude Code remembers

With MemNexus, Claude Code can recall:

  • Project structure — Tech stack, architecture, conventions
  • Coding patterns — Error handling, API patterns, component structure
  • Past decisions — Why you chose a particular approach
  • Bug fixes — Root causes and solutions from past debugging
  • Preferences — Formatting, libraries, naming conventions

Usage patterns

Automatic context loading

Add to your project's CLAUDE.md file:

Working memory is automatically loaded at session start — you do not need
to call initialize_session manually. Call it only when switching tasks
mid-session or when you want a fresher context briefing.

Auto-injection via the MCP handshake requires MCP server v1.4+. On older versions, call initialize_session explicitly at session start or use search_memories as a fallback.

Saving debugging sessions

When you fix a tricky bug, Claude Code can save the resolution:

"Save a memory about this fix — the CORS issue was caused by the API gateway stripping the credentials header"

Building project knowledge

Over time, Claude Code builds a knowledge base about your project:

Session 1: Learns project structure and tech stack
Session 2: Learns error handling patterns
Session 3: Learns deployment process
Session 4: Applies all accumulated knowledge

Tips

  • Use with CLAUDE.md — Combine MemNexus memory with project-level CLAUDE.md for both persistent and per-project context
  • Save before switching — When switching between projects, save your current context
  • Topic by project — Use project names as topics to keep memories organized

Troubleshooting

If tools aren't working:

  1. Re-run mx setup claude-code and confirm it reported success
  2. Ensure mx is in your PATH (mx --version)
  3. Verify you are logged in — run mx auth status. Keys use the format cmk_live_<id>.<secret> (find yours at memnexus.ai)
  4. Check the bridge logs (mx mcp logs), then restart Claude Code

Next steps