What the official Memory MCP server does
The Knowledge Graph Memory Server is the reference MCP server for local memory. A client starts it on your machine, and it keeps entities, relations, and observations in a file so a later chat can read them back. The npm package is @modelcontextprotocol/server-memory. The source is modelcontextprotocol/servers, src/memory. The directory listing Memory on MCP Server Hub is this server. Behavior, tools, and config are defined in the README. These notes match that README and npm package 2.2.2. If this walkthrough and the README disagree, follow the README.
People looking for an MCP Memory server tutorial, or a local MCP Memory server, usually want that package, a file path that survives updates, and a client config. The general pattern for any local command is in how to install an MCP server. The rest of this page is this server.
The graph it stores
An entity has a unique name, an entityType such as person or organization, and a list of observations. A relation is directed: from, to, and relationType in active voice, such as works_at. An observation is one string attached to one entity. The README says to keep each observation atomic.
The file is JSONL. Each line is one JSON object. Entities use "type": "entity". Relations use "type": "relation". A short graph looks like this:
{"type":"entity","name":"Jane_Roe","entityType":"person","observations":["Prefers morning meetings"]}
{"type":"relation","from":"Jane_Roe","to":"Example_Co","relationType":"works_at"} search_nodes matches a query against names, types, and observation text. In the current source that comparison is a case-insensitive substring. There is no embedding step and no separate vector index in this server. A query longer than 2048 characters is rejected.
The assistant has to call the tools
Installing the server does not transcribe the chat. The process exposes tools. The model has to call search_nodes, open_nodes, or read_graph to read, and the create or add tools to write. A client that never approves those calls leaves the file empty.
The README’s example prompt is for the custom instructions of a Claude Project. It tells the model to read the graph at the start of a chat and to write entities, relations, and observations when it learns something in the listed categories. The opening word “Remembering...” is part of that example. The server does not require that word. Paste the prompt, or a shorter instruction of your own, into the project or into the client’s rules. Then ask it to store one fact, open the JSONL file, and confirm a line was written before you trust a later chat to recall it.
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 observationsChoose the file before the first fact
Set MEMORY_FILE_PATH to an absolute path in a directory that already exists. The README’s example is ~/memory.jsonl. A leading ~ is expanded by the server, because a JSON config does not get a shell. The server creates the file. It does not create the directories above it.
If the variable is unset, the file is memory.jsonl in the server directory. Under npx or an npm install, that directory is inside node_modules. Reinstalling, updating, or clearing the npx cache can delete the graph. A relative MEMORY_FILE_PATH resolves against that same directory, so it has the same problem. When the resolved file is inside node_modules, the server prints a warning on stderr. Most clients show that in the server log. Move the existing file when you set the variable, or the next start is an empty graph.
An older README called the default file memory.json. The current server uses memory.jsonl. When MEMORY_FILE_PATH is unset, a leftover memory.json is renamed to memory.jsonl if the new file is not already there. If that rename fails, the server exits and names both paths. It does not start on an empty file while the old graph is still sitting beside it. If both files already exist, it uses memory.jsonl and leaves the old file alone. The listing shows the README captured for that page. Use the repository README when the two differ.
Every write reads the whole file, changes the graph, and writes the whole file back through a temporary file in the same directory, then renames it into place. A stop in the middle of a save leaves the previous graph. Each client starts its own process. Two processes can share one path. Writes take an exclusive lock file, .lock, next to the memory file, so the directory has to be writable. A write that cannot get the lock within 60 seconds returns a tool error. The README says the lock depends on exclusive file creation, which a network filesystem may not provide.
Three limits are optional, and each must be a positive whole number if you set it. An empty or invalid value stops the server at startup and names the variable. MEMORY_MAX_ENTITIES, MEMORY_MAX_RELATIONS, and MEMORY_MAX_FILE_BYTES are unset by default, which means no cap. A create or add call that would pass a limit is refused as a whole and saves nothing. Delete calls are still allowed, so a graph that is already over a limit can be shrunk. The README’s size note is that a write rewrites the entire file, so the cost grows with the file. Its illustration is about 100,000 entities, around 24 MB at about 240 bytes each, rewritten in roughly 0.4 seconds on a laptop.
Run it with npx
The README requires Node.js 24 or later when you use npx or run from source. The package’s engines field is node >= 24. Check with node -v before debugging the client. The published bin name is mcp-server-memory. The README’s install path is npx, which runs the current release. This page was checked against 2.2.2.
The README also shows an npx block with no env. Use the block below instead. It is the README’s custom setting, with the path filled by you. Create the parent directory first.
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"],
"env": {
"MEMORY_FILE_PATH": "/absolute/path/to/memory.jsonl"
}
}
}
} On Windows the README launches npx through cmd /c:
{
"mcpServers": {
"memory": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@modelcontextprotocol/server-memory"],
"env": {
"MEMORY_FILE_PATH": "/absolute/path/to/memory.jsonl"
}
}
}
}Connect the Memory server in Claude Desktop
Claude Desktop reads claude_desktop_config.json. Open it from Settings, Developer, Edit Config, so you do not have to guess the path. Put the memory entry inside mcpServers. On Windows, use the cmd block. Fully quit Claude Desktop and reopen it. A half-restart keeps the old process, and the new server never appears.
There is no API key and no OAuth screen. The trust boundary is the user the process runs as and the file you named. Approve the tools in the client. The server can read and write that file, and the delete tools remove data from it.
Connect the Memory server in Cursor
Cursor uses the same mcpServers command the README shows for Claude Desktop. For one graph across projects, put it in ~/.cursor/mcp.json. A .cursor/mcp.json in a repo applies only there. Keep a personal home-directory path out of a file you commit. Enable the server in Cursor’s MCP settings. Cursor’s MCP docs show a local server with command, args, and env. Their field table also lists type set to stdio. The README’s block does not include type. Copy that block first. If Cursor reports the entry is missing a type, add "type": "stdio" next to command.
Cursor’s docs also say hosted cloud agents do not read ~/.cursor/mcp.json. A cloud agent uses the servers configured for that agent. The file you just edited is for the Cursor app on this computer. Restart Cursor if the server does not show up, and read the MCP log if stderr printed the node_modules warning.
Connect the Memory server in Claude Code
Claude Code’s documented way to add a local stdio server is claude mcp add. Everything after -- is the process, so -y is an npx flag. Claude Code’s docs say to put another option, such as --transport stdio, between --env and the server name. If the name comes directly after --env, the CLI reads the name as another variable and rejects it. -s user makes the entry available in every project, which is what you want when one file holds a personal graph. Without that flag the entry is local to the directory where you ran the command.
claude mcp add -s user --env MEMORY_FILE_PATH=/absolute/path/to/memory.jsonl --transport stdio memory -- npx -y @modelcontextprotocol/server-memory Start Claude Code and run /mcp to approve it. claude mcp list shows whether the entry was saved. The current flags are in Claude Code’s MCP docs. The Memory README itself publishes the JSON for Claude Desktop and VS Code, not this command. The command is the same npx process, passed the way Claude Code accepts a stdio server.
Connect the Memory server in VS Code
The README’s VS Code block uses the key servers, not mcpServers. A block copied from Claude Desktop or Cursor will not match this file. Open the Command Palette and run MCP: Open User Configuration, or add .vscode/mcp.json in one workspace. The README also links one-click NPX and Docker installs for VS Code and VS Code Insiders. The manual NPX shape, with the file path added the same way as the Claude block, is:
{
"servers": {
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"],
"env": {
"MEMORY_FILE_PATH": "/absolute/path/to/memory.jsonl"
}
}
}
} On Windows, the README uses command cmd and args ["/c", "npx", "-y", "@modelcontextprotocol/server-memory"] inside servers, the same switch as the Claude Desktop Windows block.
Docker
The README’s first Docker block runs an image tagged mcp/memory and mounts the named volume claude-memory on /app/dist. You create that tag from a checkout of the servers repository:
docker build -t mcp/memory -f src/memory/Dockerfile . That volume sits on the image’s code directory, so it holds memory.jsonl next to the server’s JavaScript. Docker fills a named volume from the image only while the volume is empty. After the graph is there, a newer image does not replace the code in the volume. The README’s “Upgrading a Docker install” section has the copy that replaces the .js files and leaves the graph, and it explains the EACCES failure when an older root-owned volume is not given to the node user.
The same README gives a layout that keeps code and data apart. The graph lives in its own volume, and a new image takes effect without the copy step. This is the block to use for a new Docker install:
{
"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, quit the clients that start the server, then follow the README’s docker run ... cp from claude-memory onto claude-memory-data. A leftover memory.json is copied to /data/memory.jsonl. The default volume-on-/app/dist layout draws no node_modules warning, because that path is not inside node_modules.
Local HTTP, and ChatGPT
Stdio is the default. The README also documents one HTTP endpoint for clients that connect to a URL. Start it yourself:
npx -y @modelcontextprotocol/server-memory --transport streamable-http It listens on 127.0.0.1:3001 unless HOST and PORT say otherwise. The path is /mcp. The README’s client block is:
{
"mcpServers": {
"memory": {
"type": "http",
"url": "http://127.0.0.1:3001/mcp"
}
}
} "type": "http" is in that block. Claude Code requires it on a URL entry. The graph is still the file from MEMORY_FILE_PATH, so a new HTTP request does not wipe it. The README says each HTTP request is served by a fresh server, and a 2025-era client gets no session: GET and DELETE on /mcp answer 405.
A browser page whose origin is not localhost is refused with 403, and the endpoint sends no CORS headers. ChatGPT in the browser does not launch this stdio process, and it is not a page on localhost, so the default listener is not a ChatGPT connector. HOST=0.0.0.0 exposes the port to every machine that can reach yours. The README says to set that deliberately. Leave the bind on localhost unless you have a separate reason to publish the port. Use Claude Desktop, Claude Code, Cursor, or VS Code for the normal install.
Tools and the knowledge-graph resource
The README documents nine tools. Names and fields below are that list. The tool descriptions in the source also say to prefer search_nodes when you have a keyword, open_nodes when you know the exact names, and read_graph only when you need the whole file.
create_entities. Adds entities. Each item has name, entityType, and observations. A name that already exists, or that repeats earlier in the same call, is skipped, and the observations on that item are not added. The result lists skipped names. Extend an existing entity with add_observations.create_relations. Adds directed relations. Each item has from, to, and relationType. relationType is stored in active voice. Duplicate relations are skipped. The call fails if either entity does not already exist.add_observations. Adds facts to entities that already exist. Each item has entityName and contents, which is the array of new observation strings. The call fails if the entity does not exist.delete_entities. Removes entities by entityNames, including their observations, and every relation that points to or from them. A missing name is reported and does not fail the call.delete_observations. Removes specific observation strings. Each item in deletions has entityName and observations. A missing observation is reported and does not fail the call.delete_relations. Removes relations and keeps the entities. from, to, and relationType must all match a stored relation. Read the stored relationType with open_nodes or search_nodes first.read_graph. Returns the whole graph. Optional entityTypes limits entities to those types and the relations that touch them. Optional observationLimit caps how many observations each entity includes. 0 returns names, types, and counts only.search_nodes. Takes query, at most 2048 characters. It matches entity names, entity types, and observation text, then returns those entities and every relation that touches one of them. Optional limit keeps the first matches in stored order. Optional observationLimit works as it does on read_graph. The current server source compares those fields as a case-insensitive substring.open_nodes. Takes names and returns those entities. The current source also returns every relation that touches one of them, including a link whose other end was not named. Names that do not exist are skipped. Optional observationLimit works as it does on read_graph.
There is one resource, memory://knowledge-graph, with MIME type application/json. It returns the same entities-and-relations shape as read_graph. The six mutation tools emit notifications/resources/updated for that URI. How a client subscribes depends on its protocol version. The README covers a 2026-07-28 client and a 2025-era client. The tools and the resource are the same on both. Stdio serves both from one process. The client’s first message picks the era.
Setup questions that waste an afternoon
- Yesterday’s facts are gone after an update. The file was the default
memory.jsonlinsidenode_modules, and npx replaced that directory. SetMEMORY_FILE_PATHto a path you own and move the old file there. The stderr warning names the file when it is still insidenode_modules. - The process exits before any tool is listed.
node -vis below 24, a limit variable is set to something other than a positive whole number, or a legacymemory.jsonrename failed. The exit text names the variable or both paths. The parent directory ofMEMORY_FILE_PATHalso has to exist already. - Cursor remembers a fact and Claude does not. They are two processes. They share a graph only when both configs use the same
MEMORY_FILE_PATH. One of them is probably still on the default file inside its own install. create_entitiesdid not add the new fact. The name was already in the graph, so the entity was skipped and its observations were ignored. Calladd_observationswithentityNameandcontents. The concept example in the README that shows anobservationsfield on an entity is not the input shape ofadd_observations.create_relationsfails, ordelete_relationsremoves nothing. Both endpoints have to exist before a relation can be created. A delete matchesfrom,to, andrelationTypeexactly. Read the stored type withopen_nodesfirst.- Windows says
npxis not recognized. Use the README’scmd//cblock in Claude Desktop, Cursor, and VS Code. A command that works in a terminal you opened yourself can still be invisible to the client. - The Docker container never picks up a new image. The volume is mounted on
/app/dist, so it kept the first image’s code. Use the data-volume block above, or the README’s upgrade copy. Deletingindex.jsfrom that volume leaves the directory with no entry point. - ChatGPT’s website never lists the server. That site does not start a stdio command from a JSON file on your laptop. The HTTP mode on
127.0.0.1is for a client on that machine. Point Claude Desktop, Claude Code, Cursor, or VS Code at the npx command instead.
This walkthrough, the README, and the listing
Use the Memory README for the current client blocks, the Docker upgrade commands, and the lock and limit rules. Use this page to pick a file path, a client, and the failures that show up on a first install. Use the Memory listing for the directory card and the README it has stored. Other knowledge and search servers are in Search & Knowledge.
Common questions
What package runs the official MCP Memory server?
The Knowledge Graph Memory Server is published as @modelcontextprotocol/server-memory. The source is https://github.com/modelcontextprotocol/servers/tree/main/src/memory. The directory listing at https://mcpserver.dev/s/memory is that server. The README’s npx command is npx -y @modelcontextprotocol/server-memory. The package requires Node.js 24 or later for npx and for a run from source. The npm bin name is mcp-server-memory.
Where does a local MCP Memory server store the graph?
In one JSONL file. Set MEMORY_FILE_PATH to an absolute path you own, such as ~/memory.jsonl. The server expands a leading ~. A relative path is resolved against the server directory. If the variable is unset, the file is memory.jsonl next to the server code, which under npx is inside node_modules and can disappear when that install is replaced. The server creates the file. It does not create parent directories.
Does the Memory MCP server remember a chat on its own?
No. It exposes nine tools and one resource, memory://knowledge-graph. The assistant has to call them. The README includes an example system prompt for a Claude Project. Nothing in that design uploads the graph to a hosted memory service. Two clients share a graph only when they use the same file.
Can I connect the Memory MCP server in Claude, Cursor, VS Code, and ChatGPT?
Claude Desktop and VS Code have config blocks in the server README. Cursor uses the same mcpServers command in ~/.cursor/mcp.json or .cursor/mcp.json. Claude Code can launch the same npx command over stdio. ChatGPT in the browser does not start a local stdio process. The optional HTTP mode listens on 127.0.0.1:3001 by default and refuses browser pages that are not on localhost.
Where is the official Memory MCP documentation?
The README at https://github.com/modelcontextprotocol/servers/blob/main/src/memory/README.md is the setup document, and the package is https://www.npmjs.com/package/@modelcontextprotocol/server-memory. This page matches that README and npm 2.2.2. Tool names, the file format, and the client blocks change there first.