Knowledge graph as memory for AI agents: how it works
Graph memory stores what an agent learns as entities, the links between them, and short facts about each. The agent can follow links and search by name, instead of re-reading a long notes file. It suits connected facts. Plain notes are simpler for small projects, and vector search suits fuzzy lookups.
What graph memory is
A knowledge graph breaks information into three parts. Entities are the things: a person, a service, a file, a decision. Relations are the directed links between them, such as a service depends on a database. Observations are small facts attached to an entity.
The official MCP memory server uses exactly this model. Entities have a unique name and a type. Relations are stored in active voice. Observations are meant to be atomic, one fact each. It saves everything to a JSONL file, and the path comes from the MEMORY_FILE_PATH environment variable.
Graph vs notes vs vector search
A notes file such as CLAUDE.md is easy to read and edit but is loaded whole, so it grows until it is a cost on every session. A vector store finds text that is similar in meaning to a query, which is good for fuzzy questions and weak at questions like which services depend on this one.
A graph answers questions that follow links. It can return one entity and what is connected to it without loading the rest. Microsoft Research's GraphRAG applies the same idea to documents: it extracts entities, relationships and key claims, clusters them into communities and summarizes those, aiming at questions that need an overview, not just the nearest passage. Many systems combine graph and vector lookup, and which wins depends on your data.
Try it: the MCP memory server
You can add the reference server to Claude Code with one command. It is a local server running on your machine.
claude mcp add --env MEMORY_FILE_PATH=$HOME/agent-memory.jsonl memory -- npx -y @modelcontextprotocol/server-memoryA worked example of what goes in
Say your agents work on a web app. You might record an entity named checkout-service with the type service, and an entity named payments-db with the type database. A relation says checkout-service depends on payments-db. Observations on checkout-service might be: runs on port 8080, and retries failed calls three times.
Later, an agent that is asked to change the database can search for payments-db, open that node, and find the services connected to it, without reading the whole repository again. The fact was written once and every agent can find it. The quality of the result depends on writing small, true facts and correcting them when they change.
What the tools look like
The server exposes tools to create entities, create relations, add observations, delete any of these, read the whole graph, search nodes by query across names, types and observations, and open specific nodes by name. Because the store is a plain JSONL file, you can open it and see what the agent remembers.
When a graph is the wrong tool
A graph needs discipline. If each agent invents its own names, you get duplicates that never connect. Keep a short convention for entity names and types. For a small project, a few paragraphs in CLAUDE.md or AGENTS.md are simpler and enough. Reading the entire graph also brings back the cost problem, so search and open nodes instead.
Where a NodePress node fits
The agents in a node share memory that is a graph, along with a thread, files and context you choose. Several agents write to the same graph, so what one agent learns is there for the others. Every step is also written to one readable thread, so you can see where a fact came from. A node runs on your own computer.
Do it with a NodePress node
- Name a node on nodepress.ai. It is free to start, with no sign-up for the first node.
- Paste the one line into each agent that should share the memory.
- Tell each agent to record durable facts, such as decisions and dependencies, rather than chat.
- Read the thread to check what each agent added.
- Prune facts that are wrong or no longer true.
If you have one agent and a small project, a short notes file is simpler than a graph. Add a graph when facts are connected and you keep re-explaining them.
Questions people ask
What is knowledge graph memory for AI agents?
It stores what an agent learns as entities, relations between them, and small facts about each, so the agent can search and follow links instead of re-reading a long file.
Graph memory vs vector memory: which is better?
Graphs suit connected facts and questions that follow links. Vector search suits fuzzy, meaning-based lookups. Many systems use both.
Is there a graph memory MCP server?
Yes. The reference server @modelcontextprotocol/server-memory stores entities, relations and observations in a JSONL file and exposes tools to read, search and edit them.
What is GraphRAG?
It is a Microsoft Research approach that builds an entity graph from documents and summarizes clusters of it, to answer questions that need a wider view than baseline vector search.
Can I see my agents' shared memory as a graph?
With the MCP memory server you can read the JSONL file or call read_graph. In a NodePress node, the memory is a graph shared by the agents in it.
Related
- How to give AI agents shared memory
- How do I see what my AI agent remembers?
- How to keep an AI agent's state across restarts and crashes
- Agent memory tools compared: mem0, Letta, Zep and memory MCP
- How to get AI agents talking to each other
- How to get AI agents talking to each other