memory-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@memory-mcp remember that John Smith works at Anthropic and speaks Spanish"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
memory-mcp
A basic implementation of persistent, namespaced memory using a local knowledge graph. This lets agent harnesses remember information across chats.
This is a fork of: https://github.com/modelcontextprotocol/servers/tree/main/src/memory
Core Concepts
Entities
Entities are the primary nodes in the knowledge graph. Each entity has:
A name that identifies it within its namespace
An entity type (e.g., "person", "organization", "event")
A list of observations
A namespace (see Namespaces), which the server sets from the
namespaceinput of the call that creates the entity
Example:
{
"name": "John_Smith",
"entityType": "person",
"observations": ["Speaks fluent Spanish"],
"namespace": "story"
}Relations
Relations define directed connections between entities of the same namespace. They are always stored in active voice and describe how entities interact or relate to each other. A relation has the namespace of the entities it connects, set from the call that creates it.
Example:
{
"from": "John_Smith",
"to": "Anthropic",
"relationType": "works_at",
"namespace": "story"
}Observations
Observations are discrete pieces of information about an entity. They are:
Stored as strings
Attached to specific entities
Can be added or removed independently
Should be atomic (one fact per observation)
Example:
{
"entityName": "John_Smith",
"observations": [
"Speaks fluent Spanish",
"Graduated in 2019",
"Prefers morning meetings"
]
}Namespaces
A namespace keeps one set of entities and relations apart from another in the same memory file, for example one per project, story or user. Every entity and relation belongs to exactly one namespace.
Isolation. An entity is identified by its namespace and name together, so
Alicecan exist in several namespaces as different entities. A relation connects entities of its own namespace only; relating to an entity that exists only in another namespace fails as not found.Explicit, with no default. Every tool that works inside a namespace requires a
namespaceinput, and the model has to name one on every call. There is no default namespace and an omittednamespaceis a validation error, never a fallback.Namespaces are created, not implied.
create_namespacemakes one; every other tool fails with an error that points atcreate_namespaceandlist_namespacesif the namespace it names does not exist, for reads as well as writes. A write never creates a namespace as a side effect, so a misspelled name is caught instead of silently starting a second graph.create_namespacefails if the namespace already exists, which tells the model to reuse it. A namespace stays untildelete_namespace, even when it is empty.One namespace per call, applied by the server. A call names its namespace once. The
entities,relations,observationsanddeletionsin it areOmit<Entity, "namespace">and the like: they have nonamespaceof their own, and the server puts the call's namespace on each entity and relation it creates. The entities and relations a tool returns do carry theirnamespace. Anamespacemember written on an input item is not part of the schema and is ignored, so the call'snamespacealways decides.Names. A namespace is a case-sensitive string of 1 to 256 characters, matched exactly.
Reads stay inside one namespace.
read_graph,search_nodesandopen_nodesread the namespace they are given; there is no way to read "all of them" through a tool. The knowledge-graph resource is the one place that serves every namespace.Whole namespaces.
rename_namespaceanddelete_namespaceact on a namespace and everything in it at once. Renaming never merges into an existing namespace.
In the memory file, each namespace is a {"type":"namespace","name":…} line, written before the entities and relations, and every entity and relation line carries a namespace member. A record with no namespace member, as in a file written before namespaces existed, is not given one: it is treated like any other unreadable line, skipped and written back unchanged, so it is never served and never lost. To use such a file, add "namespace":"<name>" to its entity and relation lines. A record whose namespace is not a non-empty string, or a namespace line with no valid name, is treated like any other unreadable line: it is skipped and written back unchanged.
Related MCP server: dejaview-mcp
API
Tools
Every tool except the namespace-management tools (create_namespace, list_namespaces, rename_namespace, delete_namespace) takes a required namespace input (a string of 1 to 256 characters, naming a namespace that exists) and works only inside that namespace; see Namespaces. It is not repeated in each tool below. The entities and relations a tool returns carry their namespace; the ones a tool takes do not.
create_entities
Create multiple new entities in the knowledge graph
Input:
entities(array of objects)Each object contains:
name(string): Entity identifierentityType(string): Type classificationobservations(string[]): Associated observations
Ignores entities whose name already exists in the namespace (and repeats of a name earlier in the same call); their observations are not added. The same name in another namespace is a different entity
Returns the created entities. When any were skipped, the structured result also lists their names in
skipped, and a second text item says which were skipped (useadd_observationsto extend an existing entity)
create_relations
Create multiple new relations between entities
Input:
relations(array of objects)Each object contains:
from(string): Source entity nameto(string): Target entity namerelationType(string): Relationship type in active voice
Skips duplicate relations
Fails if either the source or target entity doesn't exist in the namespace; the error names the namespace
add_observations
Add new observations to existing entities
Input:
observations(array of objects)Each object contains:
entityName(string): Target entitycontents(string[]): New observations to add
Returns added observations per entity
Fails if entity doesn't exist in the namespace
delete_entities
Remove entities and their relations
Input:
entityNames(string[])Cascading deletion of associated relations, within the namespace
No error if an entity doesn't exist in the namespace; the response reports which names were not found
delete_observations
Remove specific observations from entities
Input:
deletions(array of objects)Each object contains:
entityName(string): Target entityobservations(string[]): Observations to remove
No error if an observation doesn't exist; the response reports how many were deleted
delete_relations
Remove specific relations from the graph
Input:
relations(array of objects)Each object contains:
from(string): Source entity nameto(string): Target entity namerelationType(string): Relationship type
No error if a relation doesn't exist; the response reports how many were deleted
read_graph
Read the entire knowledge graph of one namespace
Optional input:
entityTypes(string[], at least one): return only entities of these types, and the relations that touch one of themobservationLimit(integer, 0 or more): see below
Returns complete graph structure with all entities and relations of the namespace
With
observationLimit, each entity carries at most that many observations (the first ones, in the order they were added) and anobservationCountwith its total.observationLimit: 0returns names, types and counts only: a cheap overview of a large graph, from whichopen_nodesreads the entities you need in full
search_nodes
Search for nodes based on query
Input:
query(string, at most 2048 characters; a longer query is rejected)Searches across:
Entity names
Entity types
Observation content
Returns matching entities and their relations
Optional input:
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 forread_graph
open_nodes
Retrieve specific nodes by name
Input:
names(string[])Returns:
Requested entities
Relations between requested entities
Silently skips non-existent nodes
Optional input:
observationLimit(integer, 0 or more), as forread_graph
create_namespace
Create a namespace, where entities and relations live
Input:
namespace(string, required): the name to createFails if the namespace already exists, so the model reuses it (see
list_namespaces) instead of creating it again
list_namespaces
List every namespace, empty ones included
Input: none
Returns each namespace with its
entityCountandrelationCount, in name order; a new graph has none
rename_namespace
Move every entity and relation of a namespace to a new name
Input:
namespace(string, required): the current name;newNamespace(string, required): the new nameFails if the namespace does not exist, if the new name is the current one, or if the new name already exists: namespaces are never merged, so delete the target or choose another name
Returns how many entities and relations moved
delete_namespace
Delete a namespace with every entity and relation in it; this cannot be undone
Input:
namespace(string, required)No error if the namespace does not exist; the response reports 0 deleted
Returns how many entities and relations were deleted
Resources
knowledge-graph (
memory://knowledge-graph)The full knowledge graph as a readable MCP Resource
MIME type:
application/jsonReturns the same shape as
read_graph(entities and relations), but for every namespace at once: each entity and relation carries itsnamespace. A namespace with nothing in it shows up only inlist_namespacesMutation tools (
create_entities,create_relations,add_observations,delete_entities,delete_observations,delete_relations,create_namespace,rename_namespace,delete_namespace) emitnotifications/resources/updatedfor this URI, so subscribed clients see live changesHow a client subscribes depends on its protocol version: a 2026-07-28 client names the URI in the
resourceSubscriptionsof itssubscriptions/listenrequest and gets the updates on that stream; a 2025-era client callsresources/subscribe
Protocol versions
The 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.
Requirements
Node.js 24 or later, when the server runs through npx or from source.
Usage with Claude Desktop
Setup
Add this to your claude_desktop_config.json:
Docker
{
"mcpServers": {
"memory": {
"command": "docker",
"args": [
"run",
"-i",
"-v",
"claude-memory:/app/dist",
"--rm",
"mcp/memory"
]
}
}
}NPX
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@analyticsrequired/memory-mcp"]
}
}
}On Windows, use cmd /c to launch npx:
{
"mcpServers": {
"memory": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@analyticsrequired/memory-mcp"]
}
}
}NPX with custom setting
The server can be configured using the following environment variables:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@analyticsrequired/memory-mcp"],
"env": {
"MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl"
}
}
}
}On Windows, use:
{
"mcpServers": {
"memory": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@analyticsrequired/memory-mcp"],
"env": {
"MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl"
}
}
}
}MEMORY_FILE_PATH: Path to the memory storage JSONL file (default:memory.jsonlin 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.
Choosing where the graph is stored
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.
When the memory file it resolves is inside a
node_modulesdirectory, 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.The directory must already exist: the server creates the memory file, not the directories above it.
The default stays where it is so that existing graphs keep loading. The Docker setup above keeps it in a named volume mounted over
/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.
Sharing one memory file between clients
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).
A lock left behind by a server that crashed mid-write is removed automatically: at once if its process is known to have exited on the same machine, otherwise once it has gone 30 seconds without being refreshed (a server holding the lock refreshes it every 15 seconds while it works). Only one waiting server breaks a stale lock at a time, guarded by a momentary
<memory file>.lock.breakfile.A write that cannot get the lock within 60 seconds fails with a tool error rather than overwriting the file.
The lock relies on exclusive file creation, which local filesystems provide; a network filesystem that does not honour it cannot be shared safely this way.
VS Code Installation Instructions
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.
NPX
{
"servers": {
"memory": {
"command": "npx",
"args": ["-y", "@analyticsrequired/memory-mcp"]
}
}
}On Windows, use:
{
"servers": {
"memory": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@analyticsrequired/memory-mcp"]
}
}
}Docker
{
"servers": {
"memory": {
"command": "docker",
"args": [
"run",
"-i",
"-v",
"claude-memory:/app/dist",
"--rm",
"mcp/memory"
]
}
}
}System Prompt
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. If you use namespaces, tell the model which one to work in (for example "use the namespace project-x for every memory tool call"), since every call has to name one and the model cannot guess which. Ask it to run list_namespaces first and to create_namespace only when the one you want is missing.
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 observationsBuilding
Docker:
docker build -t mcp/memory .For Awareness: a prior mcp/memory volume contains an index.js file that could be overwritten by the new container. If you are using a docker volume for storage, delete the old docker volume's index.js file before starting the new container.
License
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.
Available Tools
13 toolsadd_observationsAdd ObservationsBIdempotent
Add new observations to existing entities in the knowledge graph
Inputs: namespace (required), observations (required). Returns: results
create_entitiesCreate EntitiesAIdempotent
Create multiple new entities in the knowledge graph. An entity whose name already exists, or repeats an earlier entity in the same call, is skipped and its observations are not added; the result lists the skipped names in skipped. Use add_observations to add observations to an existing entity.
Inputs: entities (required), namespace (required). Returns: skipped, entities
create_namespaceCreate NamespaceA
Create a namespace, which is where entities and relations live: every other tool takes the namespace to work in, and it must exist. Fails if a namespace of that name already exists, so reuse the existing one (see list_namespaces) rather than creating it again. Names are case-sensitive.
Inputs: namespace (required). Returns: message, success
create_relationsCreate RelationsCIdempotent
Create multiple new relations between entities in the knowledge graph. Relations should be in active voice
Inputs: namespace (required), relations (required). Returns: relations
delete_entitiesDelete EntitiesBDestructiveIdempotent
Delete multiple entities and their associated relations from the knowledge graph
Inputs: namespace (required), entityNames (required). Returns: message, success
delete_namespaceDelete NamespaceADestructiveIdempotent
Delete a namespace with every entity and relation in it. This cannot be undone. A namespace that does not exist is not an error; the response reports 0 deleted.
Inputs: namespace (required). Returns: message, success, entityCount, relationCount
delete_observationsDelete ObservationsCDestructiveIdempotent
Delete specific observations from entities in the knowledge graph
Inputs: deletions (required), namespace (required). Returns: message, success
delete_relationsDelete RelationsCDestructiveIdempotent
Delete multiple relations from the knowledge graph
Inputs: namespace (required), relations (required). Returns: message, success
list_namespacesList NamespacesARead-onlyIdempotent
List the namespaces of the knowledge graph, each with its number of entities and relations (0 for a namespace nothing is in yet). Use this to find out which namespaces exist before reading from or writing to one; every other tool works inside the namespace named by its required namespace input, which must exist.
Inputs: no named parameters. Returns: namespaces
open_nodesOpen NodesARead-onlyIdempotent
Retrieve specific entities by their exact names, with every relation that touches one of them. Use this when you already know the names (from the conversation, or from an earlier search_nodes or read_graph result); it is the cheapest way to read entities you can name. Prefer search_nodes when you only have a keyword or part of a name. Names that do not exist are skipped.
Inputs: names (required), namespace (required), observationLimit. Returns: entities, relations
read_graphRead GraphARead-onlyIdempotent
Read the entire knowledge graph: every entity with its observations, and every relation. The result grows with the graph, so use this only when you need everything; prefer search_nodes to find entities by keyword and open_nodes to read entities whose names you know.
Inputs: namespace (required), entityTypes, observationLimit. Returns: entities, relations
rename_namespaceRename NamespaceADestructive
Rename a namespace: every entity and relation in it moves to the new name. Fails if the namespace does not exist, or if the new name already exists, since namespaces are never merged.
Inputs: namespace (required), newNamespace (required). Returns: message, success, entityCount, relationCount
search_nodesSearch NodesARead-onlyIdempotent
Search the knowledge graph for entities whose name, type or observations contain the query (case-insensitive). Use this when you have a keyword, a topic or part of a name but not the exact entity names. Prefer open_nodes when you already know the exact names, and use read_graph only when you need the whole graph. Returns the matching entities and every relation that touches one of them.
Inputs: query (required), namespace (required), limit, observationLimit. Returns: entities, relations
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Each tool targets a distinct resource+action: entities, relations, observations, and namespaces are cleanly separated. The read tools (read_graph, search_nodes, open_nodes) overlap conceptually but their descriptions explicitly state when to use each, eliminating misselection risk.
All 13 tools follow a consistent verb_noun pattern (create_entities, add_observations, delete_relations, list_namespaces, rename_namespace, read_graph, open_nodes). No mixed conventions or vague verbs anywhere.
13 tools is well within the ideal range and every tool earns its place: entity/relation/observation lifecycle plus a coherent four-tool namespace management set. No redundant or filler tools.
Strong coverage: create/delete for entities, relations, observations, plus full namespace CRUD (create, list, rename, delete) and three read modes. Minor gaps exist—no way to update an entity's type or name, and no relation update (only delete+recreate).
Related MCP Connectors
Shared long-term memory for AI agents: save and recall context as a searchable knowledge graph.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Persistent knowledge graph for AI agents. Remember, recall, and forget facts.
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
Related MCP Servers
AlicenseAqualityDmaintenanceProvides persistent long-term memory for AI agents through semantic search and automated knowledge graph extraction. It enables agents to store, recall, and reason over facts, preferences, and relationships across multiple conversations and sessions.1423 npmMIT- AlicenseNot gradedqualityDmaintenanceProvides persistent knowledge graph memory for AI agents, enabling them to store, recall, and query facts about people, projects, and relationships across sessions.MIT
- AlicenseNot gradedqualityBmaintenanceEnables persistent, graph-based memory for AI agents, allowing them to store, traverse, and recall relationships between facts, decisions, and context across sessions for efficient reasoning and reduced token usage.MIT
- AlicenseNot gradedqualityDmaintenanceEnables storing and querying a personal knowledge graph as a shared memory, allowing agents and tools to remember facts, entities, relations, and recall relevant context via natural language hybrid search.1MIT