downloads
Across all versions.
Download trend unavailable.
compatibility
Runtime metadata.
Across all versions.
Download trend unavailable.
Runtime metadata.
A basic implementation of persistent memory using a local knowledge graph. This lets Claude remember information about the user across chats.
Published on npm as @modelcontextprotocol/server-memory.
Entities are the primary nodes in the knowledge graph. Each entity has:
Example:
{
"name": "John_Smith",
"entityType": "person",
"observations": ["Speaks fluent Spanish"]
}Relations define directed connections between entities. They are always stored in active voice and describe how entities interact or relate to each other.
Example:
{
"from": "John_Smith",
"to": "Anthropic",
"relationType": "works_at"
}Observations are discrete pieces of information about an entity. They are:
Example:
{
"entityName": "John_Smith",
"observations": [
"Speaks fluent Spanish",
"Graduated in 2019",
"Prefers morning meetings"
]
}create_entities
entities (array of objects)
name (string): Entity identifierentityType (string): Type classificationobservations (string[]): Associated observationsskipped, and a second text item says which were skipped (use add_observations to extend an existing entity)create_relations
relations (array of objects)
from (string): Source entity nameto (string): Target entity namerelationType (string): Relationship type in active voiceadd_observations
observations (array of objects)
memory://knowledge-graph)
application/jsonread_graph (entities and relations)create_entities, create_relations, add_observations, delete_entities, delete_observations, delete_relations) emit notifications/resources/updated for this URI, so subscribed clients see live changesresourceSubscriptions of its subscriptions/listen request and gets the updates on that stream; a 2025-era client calls resources/subscribeThe server serves both protocol eras on stdio from the same process. The client's first message picks the era of the connection: a 2026-07-28 client opens with server/discover and sends its protocol version, identity and capabilities with each request, and a 2025-era client opens with the initialize handshake. The tools and the resource are the same on both.
Node.js 24 or later, when the server runs through npx or from source.
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"memory": {
"command": "docker",
"args": ["run", "-i", "-v", "claude-memory:/app/dist", "--rm", "mcp/memory"]
}
}
}{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
]
}
}
}On Windows, use cmd /c to launch npx:
{
"mcpServers": {
"memory": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@modelcontextprotocol/server-memory"
]
}
}
}The server can be configured using the following environment variables:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
],
"env": {
"MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl"
}
}
}
}On Windows, use:
{
"mcpServers": {
"memory": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@modelcontextprotocol/server-memory"
],
"env": {
"MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl"
}
}
}
}MEMORY_FILE_PATH: Path to the memory storage JSONL file (default: memory.jsonl in the server directory). A leading ~ expands to your home directory; a relative path resolves against the server directory. Set it to an absolute path you own; see Choosing where the graph is stored.When MEMORY_FILE_PATH is not set and the server directory still holds a legacy memory.json but no memory.jsonl, the server renames memory.json to memory.jsonl at startup. If that rename fails, the server exits with an error naming both paths and the cause, rather than starting on an empty graph; fix the cause (a permission problem, say) and restart, or set MEMORY_FILE_PATH to choose a file explicitly.
Set MEMORY_FILE_PATH to an absolute path you own, such as ~/memory.jsonl, as in the configuration above. The default memory.jsonl sits in the server's own directory, next to its code. Under npx or an npm install, that directory is inside a node_modules tree, which npm manages as its own: reinstalling or updating the server, or clearing the npx cache, can delete the file and the knowledge graph in it. A relative MEMORY_FILE_PATH resolves against that same directory, so it has the same problem.
node_modules directory, the server prints a warning on stderr at startup naming the file; most clients show a server's stderr in its log. Move the file to the new path when you set the variable, or the server starts on an empty graph./app/dist, so the graph there survives restarts and draws no warning.Saves are atomic. Every write tool writes the whole graph to a temporary file in the same directory and renames it over the memory file, so a server stopped or killed mid-save leaves the previous graph intact rather than a half-written file. The file's permission bits are kept across the rename. Writes from several processes are serialized by a lock, described next.
Each MCP client starts its own server process, so two clients using the same MEMORY_FILE_PATH (or both using the default) are two processes writing one file. Every write tool takes an exclusive lock file, <memory file>.lock, next to the memory file while it reads, changes and saves the graph, so writes from different processes take turns and none is lost. The lock file exists only while a write is in progress, so the directory holding the memory file must be writable (it already must be, for the atomic save).
<memory file>.lock.break file.For quick installation, use one of the one-click installation buttons below:
For manual installation, you can configure the MCP server using one of these methods:
Method 1: User Configuration (Recommended)
Add the configuration to your user-level MCP configuration file. Open the Command Palette (Ctrl + Shift + P) and run MCP: Open User Configuration. This will open your user mcp.json file where you can add the server configuration.
Method 2: Workspace Configuration
Alternatively, you can add the configuration to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.
For more details about MCP configuration in VS Code, see the official VS Code MCP documentation.
{
"servers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
]
}
}
}On Windows, use:
{
"servers": {
"memory": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@modelcontextprotocol/server-memory"
]
}
}
}{
"servers": {
"memory": {
"command": "docker",
"args": [
"run",
"-i",
"-v",
"claude-memory:/app/dist",
"--rm",
"mcp/memory"
]
}
}
}The prompt for utilizing memory depends on the use case. Changing the prompt will help the model determine the frequency and types of memories created.
Here is an example prompt for chat personalization. You could use this prompt in the "Custom Instructions" field of a Claude.ai Project.
Follow these steps for each interaction:
1. User Identification:
- You should assume that you are interacting with default_user
- If you have not identified default_user, proactively try to do so.
2. Memory Retrieval:
- Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph
- Always refer to your knowledge graph as your "memory"
3. Memory
- While conversing with the user, be attentive to any new information that falls into these categories:
a) Basic Identity (age, gender, location, job title, education level, etc.)
b) Behaviors (interests, habits, etc.)
c) Preferences (communication style, preferred language, etc.)
d) Goals (goals, targets, aspirations, etc.)
e) Relationships (personal and professional relationships up to 3 degrees of separation)
4. Memory Update:
- If any new information was gathered during the interaction, update your memory as follows:
a) Create entities for recurring organizations, people, and significant events
b) Connect them to the current entities using relations
c) Store facts about them as observationsDocker:
docker build -t mcp/memory -f src/memory/Dockerfile . The Docker setup mounts the named volume claude-memory over /app/dist, the image's code directory, so the volume holds the server's code (index.js, version.js) next to your memory.jsonl. Docker copies an image's files into a named volume only while the volume is empty. Once the volume holds your graph, a newer image never reaches it: the container keeps running the code from the image that first filled the volume, which may not even start against the newer image's dependencies. Deleting index.js from the volume does not help; it leaves /app/dist with no entry point.
To upgrade, build or pull the new mcp/memory image, quit the MCP clients that start it, then replace the code in the volume with the new image's, keeping memory.jsonl:
docker run --rm -v claude-memory:/volume --user root --entrypoint sh mcp/memory \
-c 'rm -f /volume/*.js && cp /app/dist/*.js /volume/ && chown -R node:node /volume'The volume is mounted at /volume rather than /app/dist, so the image's own /app/dist stays visible to copy from. Only the .js files are replaced; memory.jsonl (or a legacy memory.json) is left as it is. Repeat this after every image update.
The image runs the server as the unprivileged node user, not root, so it must own the volume to save the graph. A volume an older image created, which ran as root, is owned by root, and without the chown above the server fails to save with EACCES. That is why this step runs as --user root and ends by giving the volume to node.
Mounting a volume on a directory of its own and pointing MEMORY_FILE_PATH at it keeps the code out of the volume, so a new image takes effect with no copying step:
{
"mcpServers": {
"memory": {
"command": "docker",
"args": ["run", "-i", "-v", "claude-memory-data:/data", "-e", "MEMORY_FILE_PATH=/data/memory.jsonl", "--rm", "mcp/memory"]
}
}
}To move an existing graph from the claude-memory volume into the new one, quit the MCP clients that start the server, then run:
docker run --rm -v claude-memory:/old -v claude-memory-data:/data \
--entrypoint cp mcp/memory /old/memory.jsonl /data/memory.jsonlIf the old volume holds only a legacy memory.json, copy /old/memory.json to /data/memory.jsonl instead. Once the server has started on the new volume with your graph, you can remove the old volume with docker volume rm claude-memory.
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
Estimated unpacked size across 4 packages.
13.9 MB
Includes dependencies.
pcarleton
paul@modelcontextprotocol.io
entityName (string): Target entitycontents (string[]): New observations to adddelete_entities
entityNames (string[])delete_relations; to remove facts from an entity, use delete_observationsdelete_observations
deletions (array of objects)
entityName (string): Target entityobservations (string[]): Observations to removedelete_relations
delete_entities)relations (array of objects)
from (string): Source entity nameto (string): Target entity namerelationType (string): Relationship typefrom, to and relationType all match a stored one exactly; read the stored relationType with open_nodes (or search_nodes) first if unsureread_graph
entityTypes (string[], at least one): return only entities of these types, and the relations that touch one of themobservationLimit (integer, 0 or more): see belowobservationLimit, each entity carries at most that many observations (the first ones, in the order they were added) and an observationCount with its total. observationLimit: 0 returns names, types and counts only: a cheap overview of a large graph, from which open_nodes reads the entities you need in fullsearch_nodes
query (string, at most 2048 characters; a longer query is rejected)limit (integer, 1 or more): return at most this many matches (the first, in stored order), with the relations that touch themobservationLimit (integer, 0 or more): as for read_graphopen_nodes
names (string[])observationLimit (integer, 0 or more), as for read_graph^2.3.1
2.4.0