Agentic Memory Management via MCP — Knowledge Graph for AI agents
Project description
agentic-memory-mcp
Agentic Memory Management via MCP — Knowledge Graph for AI agents.
A Model Context Protocol (MCP) server that gives AI agents persistent, structured, and queryable memory via a Knowledge Graph. Designed to be used standalone, embedded in any agentic framework, or served as an MCP tool server.
Architecture
agentic_memory/
├── core/
│ ├── graph.py # KnowledgeGraph — nodes, edges, JSON persistence
│ ├── score.py # Score & ScoreStore — reputation / relevance scoring
│ └── prune.py # AutoPruner — maintenance & auto-pruning
├── mcp/
│ └── server.py # MCP server (stdio transport)
├── cli/
│ └── main.py # Click CLI (memory-cli command)
├── api.py # MemorySkills — Python API (standalone use)
└── hermes/ # Hermes Agent plugin integration
Persistence: JSON files (memory_graph.json, memory_scores.json) — no external database required.
Installation
# From PyPI
pip install agentic-memory-mcp
# Development
git clone https://github.com/alexandrerodenas/agentic-memory-mcp.git
cd agentic-memory-mcp
uv sync
Quick Start
CLI
# Add a memory entry
memory-cli --graph memory.json node add --id alice --label Person --content "Alice lives in Paris"
# Search
memory-cli retrieve --query "Paris"
# Link two entries
memory-cli --graph memory.json edge add --id e1 --source alice --target paris --label lives_in
# Get stats
memory-cli --graph memory.json stats
# Prune old entries
memory-cli --graph memory.json prune --max-nodes 500 --strategy oldest
MCP Server
# Start the MCP server (stdio)
memory-mcp
# Or with custom paths
MEMORY_GRAPH_PATH=/data/memory.json MEMORY_SCORES_PATH=/data/scores.json memory-mcp
Then connect any MCP-compatible AI agent (Claude Code, OpenCode, etc.) to use the tools:
memory_node_add— Add a fact or entitymemory_node_update— Update an entrymemory_node_delete— Delete an entrymemory_node_get— Retrieve by IDmemory_retrieve— Token-optimized top-N retrieval by score (with optional text filter)memory_edge_add— Create a relationshipmemory_corroborate— Reinforce a memory (increases score)memory_prune— Manual pruningmemory_stats— Graph statistics
Hermes Agent Plugin
# Install
hermes plugin install agentic-memory-mcp
# Use in Hermes
/memory add alice "Alice works at Acme Corp"
/memory retrieve --query Acme --limit 10
/memory retrieve --limit 10
/memory corroborate alice
/memory prune --max-nodes 500
Or import in your own agent:
from agentic_memory.hermes import setup
setup(agent=your_agent_instance)
Scoring System
Each memory entry gets a composite relevance score:
score = (3 × corroborations) + (1 × read_count) + (0.5 × recency_bonus)
- Corroborations increase when the same fact is reinforced (e.g., mentioned again by the user or confirmed by another source).
- Read count increases each time the memory is retrieved.
- Recency bonus decays over time — recently accessed memories score higher.
This ensures the most relevant, most frequently accessed, and most corroborated memories bubble up to the top during retrieval, keeping LLM context windows tight.
Auto-Pruning
from agentic_memory.core.prune import AutoPruner
pruner = AutoPruner(max_nodes=1000, max_size_mb=10.0)
removed = pruner.auto_prune(graph)
Triggers:
- Max nodes — prune oldest entries when graph exceeds the limit
- Max size (MB) — prune when the JSON file exceeds the limit
- Manual — via CLI or
memory_pruneMCP tool
Configuration
| Variable | Default | Description |
|---|---|---|
MEMORY_GRAPH_PATH |
memory_graph.json |
Path to graph JSON file |
MEMORY_SCORES_PATH |
memory_scores.json |
Path to scores JSON file |
Development
# Install dev deps
uv sync --all-extras
# Run tests
uv run pytest tests/ -v
# Lint
uv run ruff check src/
License
MIT — Alexandre Rodenas
Project details
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 agentic_memory_mcp-0.3.0.tar.gz.
File metadata
- Download URL: agentic_memory_mcp-0.3.0.tar.gz
- Upload date:
- Size: 48.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff102c5b467933779afde1b32efb9aa46aed4193329c0a51ffccc9120220de13
|
|
| MD5 |
2b9342432a83247aa01c799076f358e0
|
|
| BLAKE2b-256 |
78b871d46417af3d28866c260949e902cb2bc291c6275abdc99ad4dac793e545
|
Provenance
The following attestation bundles were made for agentic_memory_mcp-0.3.0.tar.gz:
Publisher:
publish.yml on alexandrerodenas/agentic-memory-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentic_memory_mcp-0.3.0.tar.gz -
Subject digest:
ff102c5b467933779afde1b32efb9aa46aed4193329c0a51ffccc9120220de13 - Sigstore transparency entry: 1548727831
- Sigstore integration time:
-
Permalink:
alexandrerodenas/agentic-memory-mcp@7e8889e95b2d6a5c143fcf8bca0b644fb65afb09 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/alexandrerodenas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7e8889e95b2d6a5c143fcf8bca0b644fb65afb09 -
Trigger Event:
release
-
Statement type:
File details
Details for the file agentic_memory_mcp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: agentic_memory_mcp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 18.7 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 |
9394286134f06ee3bf8e3849d204e0f4115ec6b46c7a4499446e56ac6698c43c
|
|
| MD5 |
d94bf5d9b0466f1b54b8eb60b7a432db
|
|
| BLAKE2b-256 |
23ee49cbb5fa375d3e489bfba2a0ec2c8ec544ce34dd7b1ff2264dcc6b5a5d2f
|
Provenance
The following attestation bundles were made for agentic_memory_mcp-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on alexandrerodenas/agentic-memory-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentic_memory_mcp-0.3.0-py3-none-any.whl -
Subject digest:
9394286134f06ee3bf8e3849d204e0f4115ec6b46c7a4499446e56ac6698c43c - Sigstore transparency entry: 1548727856
- Sigstore integration time:
-
Permalink:
alexandrerodenas/agentic-memory-mcp@7e8889e95b2d6a5c143fcf8bca0b644fb65afb09 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/alexandrerodenas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7e8889e95b2d6a5c143fcf8bca0b644fb65afb09 -
Trigger Event:
release
-
Statement type: