Persistent semantic memory for AI agents via an authority-weighted knowledge graph
Project description
mcp-memory-graph
A context-aware memory MCP server for Claude Code and any MCP-compatible AI agent.
Goes beyond basic vector search by adding authority weighting, conflict detection, and typed relationship edges between memories — so your agent always retrieves the right answer when sources disagree.
Inspired by the context engine architecture described in Unblocked's "How a Context Engine Actually Works".
Why this exists
Standard memory MCP servers store and retrieve memories by semantic similarity. That works until you have conflicting memories — an old instruction saying one thing and a new one saying another. Without authority weighting, the agent retrieves whichever is semantically closer to the query, not whichever is more trustworthy.
mcp-memory-graph solves this with three mechanisms:
| Problem | Solution |
|---|---|
| All memories treated equally | Priority tiers: high / medium / low → authority scores 1.0 / 0.6 / 0.3 |
| Stale memories persist silently | Supersession tracking: old memories marked status=superseded with typed edges |
| Duplicates accumulate over time | Conflict detection before every store; auto-resolve by authority |
Installation
pip install mcp-memory-graph
Or run directly:
git clone https://github.com/RetroRobAI/mcp-memory-graph
cd mcp-memory-graph
pip install -r requirements.txt
python server.py
Claude Code setup
Add to ~/.claude.json under mcpServers:
"mcp-memory-graph": {
"type": "stdio",
"command": "mcp-memory-graph",
"env": {
"MEMORY_GRAPH_DB_PATH": "/path/to/memories.db"
}
}
Or with the raw script:
"mcp-memory-graph": {
"type": "stdio",
"command": "python",
"args": ["/path/to/mcp-memory-graph/server.py"],
"env": {
"MEMORY_GRAPH_DB_PATH": "/path/to/memories.db"
}
}
Migrating from an existing memory service
If you have an existing memory service (mcp-memory-service, Mem0, or a markdown-based memory system), you can import your memories into mcp-memory-graph using the included migration script.
Migration is manual and opt-in — it never runs automatically. Nothing is written until you explicitly confirm.
Run the migration script
python -m mcp_memory_graph.migrate
The script will:
- Auto-detect any existing
mcp-memory-serviceSQLite database - Ask if you have a markdown memory directory to import
- Show you how many memories it found
- Present three choices:
- [1] Migrate — import everything into mcp-memory-graph
- [2] Run in parallel — start mcp-memory-graph fresh, keep your old service running
- [3] Skip — do nothing
- Ask for a final confirmation before writing anything
Your existing memory service is never modified — the script only reads from it.
Configuration
All settings via environment variables:
| Variable | Default | Description |
|---|---|---|
MEMORY_GRAPH_DB_PATH |
~/.mcp-memory-graph/memories.db |
SQLite database path |
MEMORY_GRAPH_MODEL |
all-MiniLM-L6-v2 |
sentence-transformers model |
MEMORY_GRAPH_DIM |
384 |
Embedding dimensions |
MEMORY_GRAPH_CONFLICT_THRESHOLD |
0.85 |
Cosine similarity above which memories are flagged as conflicting |
MEMORY_GRAPH_DEFAULT_RESULTS |
10 |
Default retrieval limit |
Tools
| Tool | Description |
|---|---|
store_memory |
Store with conflict detection and optional auto-resolve |
retrieve_memories |
Semantic search ranked by similarity × authority |
check_conflicts |
Preview conflicts before storing |
update_memory |
Update content/priority with supersession tracking |
delete_memory |
Soft delete (preserves history) |
add_memory_edge |
Manually add typed relationship |
get_related_memories |
Traverse relationship graph for a memory |
list_memories |
List with filters (status, type, priority) |
Priority system
priority="high" # authority_score=1.0 — explicit instructions, confirmed preferences
priority="medium" # authority_score=0.6 — inferred preferences, reference data
priority="low" # authority_score=0.3 — session summaries, historical context
Retrieval ranking: weighted_score = 1 - (distance / (authority_score + 0.001) / 10)
A high-authority memory will rank above a semantically closer low-authority one when their similarity scores are within ~3x of each other.
Edge types
supersedes— this memory replaces anotherrelates_to— connected but not conflictingcontradicts— explicitly conflicting, unresolvedreferenced_by— another memory cites this one
Stack
- sqlite-vec — vector similarity search
- sentence-transformers — local embeddings, no API key needed
- FastMCP — MCP server framework
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_memory_graph-0.1.0.tar.gz.
File metadata
- Download URL: mcp_memory_graph-0.1.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6edb96a5497d07b0893372e21a234189dd0056d89db6612684dbf7a3b222b665
|
|
| MD5 |
3a7510c82639dc41f0c89275546c5c5a
|
|
| BLAKE2b-256 |
7cf27fcd5ffe230613dfe829ea407b2a5ee6d6ec27c49ad4917845429e6279ac
|
Provenance
The following attestation bundles were made for mcp_memory_graph-0.1.0.tar.gz:
Publisher:
publish.yml on RetroRobAI/mcp-memory-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_memory_graph-0.1.0.tar.gz -
Subject digest:
6edb96a5497d07b0893372e21a234189dd0056d89db6612684dbf7a3b222b665 - Sigstore transparency entry: 1436393433
- Sigstore integration time:
-
Permalink:
RetroRobAI/mcp-memory-graph@40da85ce2889ee15011b522f3b8e94e1b0feb191 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RetroRobAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@40da85ce2889ee15011b522f3b8e94e1b0feb191 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file mcp_memory_graph-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_memory_graph-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8aac7a33eb22ee99c44c9f9fa07a1b5ef41ac28d52959f64757b6858d280c86e
|
|
| MD5 |
1a00714def385d2d5e6778886f97f798
|
|
| BLAKE2b-256 |
7cbc9612eefc661a397e7bd8abf628bcf93406013e0b93a1c468b4d1986acafe
|
Provenance
The following attestation bundles were made for mcp_memory_graph-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on RetroRobAI/mcp-memory-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_memory_graph-0.1.0-py3-none-any.whl -
Subject digest:
8aac7a33eb22ee99c44c9f9fa07a1b5ef41ac28d52959f64757b6858d280c86e - Sigstore transparency entry: 1436393464
- Sigstore integration time:
-
Permalink:
RetroRobAI/mcp-memory-graph@40da85ce2889ee15011b522f3b8e94e1b0feb191 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RetroRobAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@40da85ce2889ee15011b522f3b8e94e1b0feb191 -
Trigger Event:
workflow_dispatch
-
Statement type: