Purpose
Knowledge Graph Memory Server is a reference server of the Model Context Protocol. It implements persistent memory using a local knowledge graph, enabling MCP-capable clients such as Claude to remember information about the user across different conversations. It has been published as the npm package @modelcontextprotocol/server-memory.
Main capabilities
The knowledge graph consists of three types of elements:
- Entities: the primary nodes of the graph. Each entity has a unique name (identifier), an entity type (such as person, organization, event), and a set of observations.
- Relations: directed connections between entities, stored in the active voice, describing how entities interact or are associated.
- Observations: discrete pieces of information about an entity, stored as strings and attached to a specific entity. They can be added and removed independently and should remain atomic (one observation, one fact).
The tools provided by the server include:
create_entities: creates entities in bulk. The input is an array of objects, each containing name, entityType, and observations. Names that already exist are ignored, and their observations are not added; the created entities are returned, and if any items were skipped, the structured result lists their names in skipped, along with a separate text explanation. To extend an existing entity, useadd_observations。create_relations: creates relations in bulk. Each item contains from, to, and relationType (active voice). Duplicate relations are skipped; if the source or target entity does not exist, the operation fails.add_observations: adds observations to existing entities. Each item contains entityName and contents; if the entity does not exist, the operation fails.delete_entities: deletes an entire entity along with all its observations, and cascades the deletion to all relations pointing to or originating from that entity; if the entity does not exist, no error is raised, and the response reports the names that were not found. To remove only the connection between two entities, usedelete_relations; to remove only facts about an entity, usedelete_observations。delete_observations: removes specified observations from an entity; if an observation does not exist, no error is raised, and the response reports the number deleted.delete_relations: removes a specific relation while keeping the entities it connects; deletion occurs only when from, to, and relationType all exactly match an existing relation. If unsure, you can first useopen_nodesorsearch_nodesto read the stored relationType; if the relation does not exist, no error is raised, and the response reports the number deleted.read_graph: reads the entire knowledge graph. The optional input entityTypes (at least one) returns only entities of those types and the relations that touch them; observationLimit (0 or greater) limits the number of observations carried by each entity (taking the first several in the order they were added), along with the total observationCount; when observationLimit is 0, only names, types, and counts are returned, which is suitable for first getting an overview of a large graph and then usingopen_nodesto fully read the required entities.search_nodes: Search nodes by query. The query can be up to 2048 characters; longer queries are rejected. The search scope includes entity names, entity types, and observation content, and returns matching entities and their relations. An optional limit (1 or greater) limits the number of returned matches (taking the first several in storage order); observationLimit is the sameread_graph。open_nodes: Read specific nodes by name. Takes a names array and returns the requested entities and the relations between them, silently skipping nonexistent nodes; the optional observationLimit is the sameread_graph. In addition, the server exposes the complete knowledge graph as a readable MCP resource with URImemory://knowledge-graphand MIME type application/json, returning the same structure asread_graph(entities and relations). Mutation tools (create_entities、create_relations、add_observations、delete_entities、delete_observations、delete_relations) emitnotifications/resources/updatedfor that URI, and subscribed clients can see real-time changes. The subscription method depends on the protocol version: 2026-07-28 clients specify the URI in the resourceSubscriptions of thesubscriptions/listenrequest and receive updates on that stream; 2025-era clients callresources/subscribe.
Usage
The server serves both protocol eras simultaneously over stdio within the same process; the client's first message determines the connection era: 2026-07-28 clients start with server/discover and carry the protocol version, identity, and capabilities in every request; 2025-era clients start with the initialize handshake. Tools and resources are the same in both eras. Running via npx or from source requires Node.js 24 or later.
Communication is via stdio by default. When using --transport streamable-http , the server runs as a standalone HTTP service, providing a single MCP endpoint /mcpand serving any number of clients of both protocol eras. It listens on 127.0.0.1:3001by default, which can be changed with HOST and PORT (for example, PORT=8080);HOST=0.0.0.0 exposes it to all devices that can access the machine, so set it with care. Browser page requests from non-localhost origins are rejected with 403, and the endpoint does not send CORS headers, so it serves non-browser page clients. In this case, point the client at the URL (e.g. http://127.0.0.1:3001/mcp) rather than providing a command.
In HTTP mode, each request is handled by a new server instance; 2025-era clients have no session (GET and DELETE to /mcp return 405), and the server cannot send requests or notifications to them between their own requests. The graph is stored in a file and is not lost between requests. If a 2026-07-28 client specifies subscriptions/listen filter, it learns of every change made by any client; a 2025-era client's memory://knowledge-graphin the resources/subscribe is only valid during its own request, so it receives no changes under HTTP.
When used with Claude Desktop, add the corresponding configuration to claude_desktop_config.json; on Windows, use cmd /c to launch npx.
The server can be configured via the following environment variables:
MEMORY_FILE_PATH: Path to the memory storage JSONL file (default: memory.jsonl in the server directory). A leading~expands to the user's home directory; relative paths are resolved relative to the server directory. It should be set to an absolute path owned by the user.MEMORY_MAX_ENTITIES: Maximum number of entities the graph can hold. Unset by default (no limit).MEMORY_MAX_RELATIONS: Maximum number of relations the graph can hold. Unset by default (no limit).MEMORY_MAX_FILE_BYTES: The maximum number of bytes the memory file can hold. Not set by default (unlimited).
All three limits are optionally enabled. Variables that are set must be positive integers; any other value (including an empty value) will cause the server to report an error at startup and indicate the variable name.
When not set MEMORY_FILE_PATH, and the server directory still contains the legacy memory.json but no memory.jsonl, the server will rename memory.json to memory.jsonl at startup. If the rename fails, the server will report an error indicating both paths and the reason, then exit, rather than starting with an empty graph.
Use cases
Suitable for scenarios where an MCP client needs to retain user-related information across multiple conversations, such as recording user preferences, person and organization relationships, events, and other structured facts, and retrieving them on demand through search and reading by name.
Limitations
The materials do not provide information on fees, pricing, platform support scope, or effectiveness. The graph size is unlimited by default, but can be limited via the three environment variables above; in HTTP mode, 2025-era clients have no session and cannot receive server-initiated requests or notifications, and their resource subscriptions are limited to a single request.