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, request access at memnexus.ai or use your invite code to get started.
- Claude Code installed
- A MemNexus API key (request access)
- Node.js 18+ installed
Setup
1. Add the MCP server
Add MemNexus to .mcp.json in your project root (this file is shareable with your team):
{
"mcpServers": {
"memnexus": {
"type": "stdio",
"command": "npx",
"args": ["@memnexus-ai/mcp-server"],
"env": {
"MEMNEXUS_API_KEY": "cmk_live_xxx.yyy"
}
}
}
}
Replace cmk_live_xxx.yyy with your actual API key.
For personal (non-shared) setup, you can also run claude mcp add memnexus and follow the prompts.
2. 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:
- Check that the MCP server configuration is valid JSON
- Ensure
npxis in your PATH - Verify your API key is valid — keys use the format
cmk_live_<id>.<secret>(find yours at memnexus.ai) - Restart Claude Code
Next steps
- Cursor — Set up memory in Cursor
- Agent Patterns — Design patterns for coding assistants
- MCP Integration — Full tool reference