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.
- 20 MCP tools covering reads, writes, search, graph traversal, and agent-productivity helpers.
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. |
upsert_entities |
write | Create-or-merge entities idempotently (re-assert facts without losing observations). |
read_graph |
read | Return the graph; optionally filter by entityType and paginate. |
search_nodes |
read | Relevance-ranked substring search over names/types/observations; optional type filter + pagination. |
open_nodes |
read | Fetch a specific set of entities and their relations. |
get_entity |
read | Fetch a single entity by name. |
describe_entity |
read | One-shot bundle: entity + incident relations + neighbors + degree. |
get_neighbors |
read | Neighborhood expansion to N hops, by direction and relation type. |
graph_stats |
read | Entity/relation counts and other stats. |
list_entity_types |
read | Distinct entity types with counts, ranked. |
list_relation_types |
read | Distinct relation types with counts, ranked. |
search_relations |
read | Filter relations by from, to, and/or type. |
find_path |
read | Shortest path (BFS, undirected) between two entities. |
export_graph |
read | Export the graph as json, mermaid, or dot. |
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.