ANSWERS · AGENT MEMORY: LINK RETRIEVAL

What is a knowledge graph memory server?

AUTHOR · XERJ documentation team · REVIEWED BY · XERJ engineering team · PUBLISHED · 2026-08-21 · UPDATED · 2026-11-14
SHORT ANSWER · UPDATED 2026-11-14

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.

Try it: the three entry types

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.

Record shapes and tool names follow the Knowledge Graph Memory Server README and src/memory/index.ts in modelcontextprotocol/servers (checked 2026-11-14). The example values come from the README examples, not a recorded session.
PASTE THIS TO YOUR AI AGENT. IT DOES THE REST 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.
RUN THIS XERJ COMMAND 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.
RUN THIS XERJ COMMAND curl -s -XGET 'http://127.0.0.1:9430/_graph/notes/overview' Read the edge total, the node total and the detector breakdown.
RUN THIS XERJ COMMAND 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.

toolwhat it does
create_entitiesadds new entities with a name, a type and observations
create_relationsadds directed relations between two existing entities
add_observationsappends facts to an existing entity
delete_entitiesremoves entities and every relation that touches them
delete_observationsremoves specific facts from an entity
delete_relationsremoves one relation and keeps both entities
read_graphreturns the whole graph, with an optional cap on observations per entity
search_nodesfinds entities whose name, type or observations contain the query
open_nodesreturns 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.

Try it: which graph memory fits?

Answer three questions

Where do the facts come from?
How deep do questions go?
What can you run?

Small and readable

Knowledge Graph Memory Server

Entities, relations and observations in one JSONL file, 9 MCP tools, text matching on search.

Deep and temporal

A graph database server

For example the Graphiti MCP server on FalkorDB or Neo4j, with an LLM extracting entities.

Search first

XERJ link index

Links built from files you index, BM25 recall, and 1 or 2 hop expansion in one process.

Runs in your browser and sends nothing. Each answer adds a point to the option it matches. A rule of thumb from each project's README and the XERJ source, not a benchmark.

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.
boundlimit
hops2
frontier ids per hop4,096
result edges per request100,000
ego seeds64
ego edges per response1,000
restrict prefilter ids10,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

Related