What is a knowledge graph memory server?
What is a knowledge graph memory server? An MCP server that stores what an AI agent learns as entities, directed relations and observations. The reference Knowledge Graph Memory Server keeps the graph in one local JSONL file with 9 tools. XERJ builds a bounded link index over indexed documents, so recall stays a search.
Key number: The shared-term detector links a document to at most 5 others (MAX_EDGES_PER_DOC). (as of 2026-11-14 · source: engine/crates/xerj-autoindex/src/detect/sharedterm.rs)
TL;DR A knowledge graph memory server is an MCP server that stores what an AI agent learns as a small graph: entities (people, projects, tools), directed relations between them, and observations, which are single facts attached to an entity. The reference one, the Knowledge Graph Memory Server, keeps the whole graph in one local JSONL file and gives the agent 9 tools. XERJ takes a related route: it builds a bounded link index over documents it already indexed, so memory and search live in one local binary.
What a knowledge graph memory server stores
entity: a node with a name, a type and facts
{"name": "John_Smith", "entityType": "person",
"observations": ["Speaks fluent Spanish"]}
Written with create_entities. A name that already exists is skipped, so the agent uses add_observations to extend it.
relation: a directed edge in active voice
{"from": "John_Smith", "to": "Anthropic",
"relationType": "works_at"}
Written with create_relations. Both entities must exist first.
observation: one atomic fact on one entity
{"entityName": "John_Smith",
"contents": ["Prefers morning meetings"]}
Written with add_observations. One fact per observation keeps later edits and deletes simple.
search: text inside names, types and facts
search_nodes {"query": "spanish"}
Returns John_Smith, because "spanish" appears inside one of its observations when case is ignored, plus the relations that touch it.
Act as a coding agent. Read https://xerj.org/llms.txt, run `xerj autoindex ./notes --url http://127.0.0.1:9430 --prefix br --brain notes --progress plain`, GET /_graph/notes/overview to read the totals and the detector split, then request /_graph/notes/ego at hops=1, hops=2 and hops=3 and report the edge counts plus the exact text of the refusal you get at 3 hops.
xerj autoindex ./notes --url http://127.0.0.1:9430 --prefix br --state-dir ./state-br --brain notes --progress plain
Index a notes folder with XERJ and build its link index in the same run.
curl -s -XGET 'http://127.0.0.1:9430/_graph/notes/overview'
Read the edge total, the node total and the detector breakdown.
curl -s -XGET 'http://127.0.0.1:9430/_graph/notes/ego?node=0ddfc0b862bd2b7ee0b308b8ce4768c9&hops=2&include_nodes=true'
Expand two hops from one document. Two hops is the cap.
How a knowledge graph memory server works
The agent turns what it learns into three kinds of entries. An entity has a name, a type and a list of observations, for example a person named John_Smith with the observation "Speaks fluent Spanish". A relation is a directed edge written in active voice, such as works_at. An observation is one atomic fact about one entity.
The agent writes these records with tool calls during a conversation and reads them in a later one. Because the store sits outside the model, the facts stay available after the chat ends. This is the same idea as any MCP memory server, with the facts arranged as a graph instead of loose notes.
The tools the agent calls
The reference server exposes 9 tools, all listed in its README.
| tool | what it does |
|---|---|
create_entities | adds new entities with a name, a type and observations |
create_relations | adds directed relations between two existing entities |
add_observations | appends facts to an existing entity |
delete_entities | removes entities and every relation that touches them |
delete_observations | removes specific facts from an entity |
delete_relations | removes one relation and keeps both entities |
read_graph | returns the whole graph, with an optional cap on observations per entity |
search_nodes | finds entities whose name, type or observations contain the query |
open_nodes | returns named entities and the relations between them |
How search works in the reference server
search_nodes lowercases the query and checks whether it appears inside each entity name, entity type and observation. Matching entities come back with the relations that touch them. The query can be up to 2,048 characters, and an optional limit caps the number of matches.
This makes the reference server simple to read and predictable. It works best when the agent asks with the same words it used when it saved the fact. For questions phrased differently from the stored text, a server with ranked search, such as BM25 or hybrid search, finds more.
Set it up in Claude Code
Add the server with one command and point MEMORY_FILE_PATH at a file you own. The README recommends an absolute path, because the default file sits next to the server's code.
claude mcp add --env MEMORY_FILE_PATH=$HOME/memory.jsonl memory -- npx -y @modelcontextprotocol/server-memory
Running it through npx needs Node.js 24 or later. After a restart, /mcp in Claude Code lists the server and its tools. For Claude Code's built-in files and when to add a server at all, see Claude Code memory.
Other knowledge graph memory servers
Graph memory comes in a few shapes. The reference server is a single JSONL file with no database and no LLM. The Graphiti MCP server builds temporally aware graphs on FalkorDB by default or Neo4j, and it uses an LLM (an OpenAI key or another supported provider) to extract entities. For a side-by-side of memory tools for agents, see XERJ vs agent memory tools.
Answer three questions
Knowledge Graph Memory Server
Entities, relations and observations in one JSONL file, 9 MCP tools, text matching on search.
A graph database server
For example the Graphiti MCP server on FalkorDB or Neo4j, with an LLM extracting entities.
XERJ link index
Links built from files you index, BM25 recall, and 1 or 2 hop expansion in one process.
How XERJ does it: a link index over your documents
XERJ builds links from files you already indexed, so you do not have to turn every fact into an entity first. Deterministic detectors read the documents and write edges into an index named .xerj-memory-{brain}-edges. The current source registers nine detectors: wikilink, mdlink, href, pathcite, cratecite, sequence, samedir, emailthread and sharedterm. Eight read structure, such as links, section order and shared folders. sharedterm compares literal terms and links a document to at most 5 others.
One autoindex run on a 3-file notes folder built 7 edges over 6 documents. The terminal line reports the whole result.
graph: 7 edges → .xerj-memory-notes-edges (samedir@2 2, sequence@2 3, wikilink@2 2);
0 unresolved, 0 ambiguous, 0 capped, 0 self-dropped, 0 invalidated
Expansion is bounded and reported. A 1-hop request from one document returned 3 edges, and a 2-hop request from the same seed returned 6. A 3-hop request returns HTTP 400 with this text.
hops is capped at 2: XERJ's second brain is a relationship layer over documents,
not a graph database (no Cypher, no shortest-path, no variable-depth traversal).
Iterate: expand again from this response's 'reachable' ids.
| bound | limit |
|---|---|
| hops | 2 |
| frontier ids per hop | 4,096 |
| result edges per request | 100,000 |
| ego seeds | 64 |
| ego edges per response | 1,000 |
| restrict prefilter ids | 10,000 |
Recall can use the links too. Pass a graph object to _recall with mode set to restrict to stay near a known document, or blend to shift ranking while keeping every candidate.
Which one to choose
Choose the reference Knowledge Graph Memory Server when you want the agent to curate a small set of named facts by hand, in a file you can open and read. Choose a graph database backed server, such as Graphiti, when facts change over time and you need typed entities, history and deep traversal. Choose the XERJ link index when the relationships already live in your files and you want search, memory and 1 or 2 hop expansion from one local process.
The 3-file capture above shows the mechanism, not scale. Only 3 of the 9 detectors fired on that fixture.
Try it
Copy the prompt on this page into your coding agent. It indexes a notes folder, reads the link overview and expands 1, 2 and 3 hops, so you see each answer for yourself.
More comparisons: best graph database for GraphRAG 2026 and neurosymbolic AI frameworks 2026.
FAQ
What is a knowledge graph memory server?
An MCP server that stores agent memory as entities, directed relations between them, and observations attached to each entity. The agent writes and reads that graph through tool calls.
Which knowledge graph memory server is the reference one?
The Knowledge Graph Memory Server in the modelcontextprotocol/servers repository, published on npm as @modelcontextprotocol/server-memory. It keeps the graph in one local JSONL file.
How does the reference server search memory?
search_nodes looks for the query text, ignoring case, inside entity names, entity types and observations, then returns the matching entities with their relations.
Where does the reference server keep the graph?
In a JSONL file. Set MEMORY_FILE_PATH to an absolute path you own, such as ~/memory.jsonl. The default is memory.jsonl in the server's own directory.
How is the XERJ link index different?
XERJ links documents you already indexed, using deterministic detectors such as wikilinks, Markdown links and section order. You get search plus 1 or 2 hop expansion from one local binary.
How many hops can XERJ expand?
One or two. A 3-hop request returns HTTP 400 with the cap stated, and the response tells you to expand again from the returned reachable ids.
When should I pick a graph database instead?
Pick a graph database when you need variable-depth traversal, shortest paths or a graph query language such as Cypher.
Evidence
- The Knowledge Graph Memory Server is published on npm as @modelcontextprotocol/server-memory and models memory as entities, relations and observations. Source: https://github.com/modelcontextprotocol/servers/blob/main/src/memory/README.md
- The server stores the graph in a JSONL file set by MEMORY_FILE_PATH (default memory.jsonl in the server directory) and needs Node.js 24 or later through npx. Source: https://github.com/modelcontextprotocol/servers/blob/main/src/memory/README.md
- search_nodes matches the query, case-insensitively, as a substring of entity names, entity types and observation text. Source: https://github.com/modelcontextprotocol/servers/blob/main/src/memory/index.ts
- The Graphiti MCP server uses FalkorDB (default) or Neo4j and needs an OpenAI API key or another supported LLM provider. Source: https://github.com/getzep/graphiti/blob/main/mcp_server/README.md
- XERJ registers nine edge detectors: wikilink, mdlink, href, pathcite, cratecite, sequence, samedir, sharedterm and emailthread. Source:
engine/crates/xerj-autoindex/src/detect/mod.rs - XERJ graph bounds: GRAPH_MAX_HOPS 2, GRAPH_MAX_FRONTIER 4096, GRAPH_MAX_RESULT_EDGES 100000. Source:
engine/crates/xerj-engine/src/graph.rs - XERJ ego expansion caps: EGO_SEEDS_CAP 64 and MAX_EGO_LIMIT 1000. Source:
engine/crates/xerj-api/src/graph_api.rs - XERJ recall graph restrict prefilter cap: MAX_RESTRICT_IDS 10000. Source:
engine/crates/xerj-api/src/memory_api.rs
Related
- What is an MCP memory server?
- Mem0 vs Zep vs Letta vs Cognee: which agent memory framework fits in 2026?
- Claude Code memory: CLAUDE.md, auto memory, or an MCP memory server?
- What is agentic memory?
- How can agent-memory links retain evidence?
- How do I give two agents private memory on one laptop?
- How do people store user preferences so an agent can recall them next week?
- XERJ vs Mem0: which memory fits your AI agent?
- What's a simple way to give an agent long-term memory on my laptop without Qdrant? · same intent: agent memory
- MemPalace vs claude-mem (and XERJ): which memory should Claude Code use? · same intent: agent memory
- XERJ vs mcp-memory-service: two MCP memory servers, tested · same intent: agent memory