mcp-memory
A Model Context Protocol (MCP) server that gives LLM agents a persistent knowledge graph memory — entities, relations, and observations stored in a compact custom binary log with write-ahead durability.
It speaks MCP over stdio, so it plugs directly into Claude Desktop, Claude Code, and any other MCP-compatible client.
Features
- Knowledge graph model — entities (typed, with free-form observations) connected by directed relations.
- Durable binary log — every mutation is written ahead to an append-only log and
fsynced; state is replayed on startup.compactrewrites the log to its minimal form via an atomic rename. - Fast lookups — string interning, an open-addressing name table, and an inverted search index keep CRUD, substring search, and BFS path-finding cheap.
- 14 MCP tools covering reads, writes, search, and graph traversal.
Installation
Or build from source:
Usage
The server runs in stdio mode:
The memory file path is resolved in this order:
--memory-file/-fflagMEMORY_FILE_PATHenvironment variable- Default:
memory.mcpmemin the working directory
Claude Desktop / Claude Code config
Tools
| Tool | Kind | Description |
|---|---|---|
create_entities |
write | Create new entities (deduplicated by name). |
create_relations |
write | Create directed relations between entities. |
add_observations |
write | Append observations to an existing entity. |
delete_entities |
write | Delete entities; relations touching them are cascaded away. |
delete_observations |
write | Remove specific observations from an entity. |
delete_relations |
write | Remove exact (from, to, type) relations. |
compact |
write | Rewrite the log to its minimal form. |
read_graph |
read | Return the full graph. |
search_nodes |
read | Substring search over names/types/observations. |
open_nodes |
read | Fetch a specific set of entities and their relations. |
get_entity |
read | Fetch a single entity by name. |
graph_stats |
read | Entity/relation counts and other stats. |
search_relations |
read | Filter relations by from, to, and/or type. |
find_path |
read | Shortest path (BFS, undirected) between two entities. |
Development
The test suite includes property-style fuzzy tests (tests/fuzzy.rs) that drive
randomized CRUD sequences against an in-memory model and assert graph invariants
(uniqueness, cascade deletes, durability across reopen, search/path correctness, and
Unicode/large-string handling).
License
Licensed under the Apache License, Version 2.0.