Introduction
When writing code with Claude Code or Claude Desktop, have you ever thought, 'I wish it remembered what we talked about before'? Project design policies, naming conventions, past pitfalls—explaining these every time is subtly stressful.
claude-mem is an MCP plugin that gives Claude 'memory' across sessions. It automatically captures activities during a session, compresses and saves them using AI, and automatically injects relevant context into the next session.
In this article, in addition to the setup procedure for claude-mem, I will organize the actual decision-making criteria for operational design in multiple projects (whether data should be separated or shared).
What is MCP in the first place?
MCP (Model Context Protocol) is a protocol established by Anthropic, a mechanism for connecting Claude with external tools.
MCP has 'clients' and 'servers'. Apps like Claude Code, Claude Desktop, and Crush are clients. External tools like claude-mem are servers. By having the client call the server, Claude can access external data and services.
There are mainly two types of communication methods (transports).
stdio method — A method where the client starts the server as a child process and exchanges JSON-RPC messages via standard input/output (stdin/stdout). Setup is simple, and this is the mainstream for personal use.
SSE / HTTP method — A method where the server is started as an independent HTTP service and communicates over a network. It is suitable for simultaneous connections from multiple clients, but requires more configuration.
claude-mem Architecture
claude-mem consists of the following components:
Lifecycle hooks — Automatically captures activities during a session using five hooks: SessionStart, UserPromptSubmit, PostToolUse, etc.
SQLite database — Persistent storage that saves session information, observations, and summaries.
Chroma vector DB — Provides hybrid search that combines semantic search and keyword search.
Worker service — An HTTP API running on port 37777 that provides a web viewer UI and search endpoints.
MCP search server — Efficiently searches memory using a 3-layer workflow (search → timeline → get_observations). It is said that about 10x token savings can be achieved.
Setup Procedure
PrerequisitesNode.js 18.0.0 or higher
Claude Code (latest version with plugin support)
SQLite 3 (bundled)
Bun (JavaScript runtime) and uv (Python package manager for vector search) will be automatically installed if missing.
InstallationRun the following in the Claude Code terminal.
/plugin marketplace add thedotmack/claude-mem /plugin install claude-mem
Once restarted, the context from previous sessions will be automatically injected into new sessions.
Manual configuration as an MCP serverIf using with clients other than Claude Code (such as Crush or Claude Desktop), add the MCP configuration manually.
"mcpServers":
"claude-mem":
"type": "stdio",
"command": "node",
"args": ["/path/to/claude-mem/plugin/scripts/mcp-server.cjs"]
The location of the configuration file varies depending on the client.
Claude Code: ~/.claude/settings.json or .mcp.json in the project root
Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
Crush: crush.json (project root)
What happens when calling an MCP server via stdio
Simply writing the configuration does nothing. When the client (e.g., Claude Code) is launched, the following processes occur in the background.
1. Child process creation
The client launches node mcp-server.cjs as a child process. At the OS level, this is equivalent to child_process.spawn().
Claude Code(親プロセス) └── node mcp-server.cjs(子プロセス)
2. Initialization handshake
An MCP protocol initialize request is made via stdin/stdout, and the list of tools provided by the server is returned to the client.
3. Waiting state
The server continues to wait for input from stdin. Every time Claude uses a tool, JSON-RPC messages are exchanged.
4. Termination
When you close the client, the child process will also terminate.
To check if the process is running:
ps aux | grep mcp-server.cjs
It does not open a port like an HTTP server; it uses pipe communication, so it cannot be accessed from the outside.
Data Management in Multiple Projects — Separation or Sharing
This is the point you will first consider once you actually start using it.
Shared Pool MethodBy default, claude-mem settings and data are saved in ~/.claude-mem/. In this case, memories from all projects are accumulated in the same location.
~/.claude-mem/ ├── settings.json └── data/ ← 全プロジェクトの記憶が混在
Pros — Settings only need to be done in one place. Cross-project knowledge (such as your preferred design patterns) is always accessible.
Cons — If projects have different rules or policies, Claude's suggestions may become inconsistent.
Project Separation MethodA method of managing data separately for each project.
~/works/project-a/.claude-mem/ ← A の記憶だけ ~/works/project-b/.claude-mem/ ← B の記憶だけ
Pros — Project contexts do not get mixed. It is easier to get accurate suggestions.
Cons — It takes more effort to switch client settings. Cross-project knowledge needs to be managed separately.
Specific examples of problemsFor example, suppose you have taught Project A (internal tool) to 'return error messages in Japanese' and Project B (OSS library) to 'use English for errors'.
With a shared pool, Claude knows both, so it might generate Japanese error messages while working on Project B. You can prevent this by giving instructions every time, but that defeats the purpose of having it remember.
The more project-specific 'judgment criteria' there are—such as naming conventions, API design policies, and reasons for selecting libraries—the greater the impact when they get mixed up.
Recommendation for Personal DevelopmentFor personal development specifically, I recommend making project separation the default. The reason is simple: the value of the memory function lies in 'accurately maintaining the context of that project'.
For things you want remembered across the board (your coding style, settings for frequently used tools, etc.), it is more reliable to write them in CLAUDE.md or the system prompt. Deciding to limit the memory function to project-specific context makes operations easier.
How to set up project separation
Switch the data directory using environment variables or MCP settings.
Method 1: Specify per project in client settings
"mcpServers":
"claude-mem":
"type": "stdio",
"command": "node",
"args": ["/path/to/mcp-server.cjs"],
"env":
"CLAUDE_MEM_DIR": "/Users/yourname/works/project-a/.claude-mem"
Claude Code reads .mcp.json in the project root. If you place it in each project, they will be automatically separated.
~/works/project-a/ ├── .mcp.json ← project-a 用のMCP設定 └── .claude-mem/ ~/works/project-b/ ├── .mcp.json ← project-b 用のMCP設定 └── .claude-mem/
For clients that can only read global settings, you can also prepare a script to switch using symbolic links.
#!/bin/bash switch-mem.sh ln -sfn ~/works/$1/.claude-mem ~/.claude-mem echo "Switched to $1"
./switch-mem.sh project-a
Regarding simultaneous connections and data conflicts
In the stdio method, an independent child process is launched for each client.
Claude Code → node mcp-server.cjs(プロセス①) Crush → node mcp-server.cjs(プロセス②)
Processes do not know of each other's existence. Conflicts at the communication level do not occur.
However, if the save destination points to the same database or file, conflicts at the data level are theoretically possible. Since claude-mem uses SQLite, the SQLite file locking mechanism protects it to some extent, but there is a possibility of an SQLITE_BUSY error if simultaneous writes overlap.
In individual development, there is almost no situation where you 'save memory from two clients at the same time,' so it is unlikely to be a problem in actual operation. If you are concerned, you can limit yourself to one client at a time or separate the data for each project for peace of mind.
The option of turning it into a service
Instead of stdio, there is also a method of making the MCP server a resident independent HTTP service.
"mcpServers":
"claude-mem":
"type": "sse",
"url": "http://localhost:3100/sse"
To convert an existing stdio server to SSE without changing it, you can use a proxy tool like supergateway.
npx -y supergateway --stdio "node /path/to/mcp-server.cjs" --port 3100
However, this tends to be over-engineering for individual development. The return on investment for the effort of port management and process monitoring is limited to cases where you want to share it with a team or need simultaneous access from multiple clients at all times.
Summary
For individual development, 'project separation + managing common rules in CLAUDE.md' is the most balanced operation. Try it with one project first, and you should be able to feel the benefits of separation once the accumulation of memories increases.
Reference links
claude-mem GitHub repository
MCP (Model Context Protocol) specification