π A blazing-fast Knowledge Graph server for AI Agents
Give your AI perfect memory. Forever.
Features β’ Quick Start β’ API Reference β’ Architecture
β οΈ DISCLAIMER: ALL SOURCE CODE IS AI-GENERATED. THE AUTHOR ASSUMES NO LIABILITY FOR PATENT, INTELLECTUAL PROPERTY, OR LEGAL COMPLIANCE ISSUES IN ANY JURISDICTION.
AI Agents forget everything between sessions. They hallucinate facts. They lose context.
Memory Graph fixes this.
Before: "Sorry, I don't have information about your project structure..."
After: "Based on your Auth Module which implements JWT, I suggest..."
| Category | Tools | Description |
|---|---|---|
| Memory | create_entities, create_relations, add_observations, delete_entities, delete_observations, delete_relations, read_graph, search_nodes, open_nodes |
Full CRUD for knowledge graph |
| Query | get_related, traverse, summarize |
Advanced graph traversal |
| Temporal | get_relations_at_time, get_relation_history |
Time-travel queries |
| Utility | get_current_time |
Timestamp helper |
| Feature | Description |
|---|---|
| β‘ Blazing Fast | In-memory cache with file persistence. Nanosecond reads. |
| π Thread-Safe | Production-ready with Mutex-based concurrency control |
| π Semantic Search | Built-in synonym matching (developer β coder β engineer) |
| β° Time Travel | Query historical state with validFrom/validTo |
| π Pagination | Handle massive graphs with limit/offset |
| β Type Validation | Soft warnings for non-standard types |
| π¦ Pure Rust | Single binary, ~3MB. Only depends on serde |
git clone https://github.com/maithanhduyan/memory-graph.git
cd memory-graph
cargo build --releasedocker run -v $(pwd)/data:/data ghcr.io/maithanhduyan/memory-graphCreate .vscode/mcp.json:
{
"servers": {
"memory": {
"type": "stdio",
"command": "${workspaceFolder}/target/release/memory-server.exe",
"env": {
"MEMORY_FILE_PATH": "${workspaceFolder}/memory.jsonl"
}
}
}
}Add to claude_desktop_config.json:
{
"mcpServers": {
"memory": {
"command": "/path/to/memory-server",
"env": {
"MEMORY_FILE_PATH": "/path/to/memory.jsonl"
}
}
}
}{
"entities": [{
"name": "Auth Module",
"entityType": "Module",
"observations": ["Implements JWT", "Uses bcrypt"]
}]
}{
"relations": [{
"from": "Auth Module",
"to": "User Service",
"relationType": "depends_on"
}]
}{
"query": "developer", // Also matches: coder, programmer, engineer
"limit": 10,
"includeRelations": true
}{
"limit": 50,
"offset": 0
}{
"timestamp": 1704067200,
"entityName": "Alice"
}
// Returns: Relations valid at that specific point in time{
"entityName": "Alice"
}
// Returns: All relations (current + expired) with isCurrent flag{
"startNode": "Project: MyApp",
"path": [
{"relationType": "contains", "direction": "out"},
{"relationType": "implements", "direction": "out", "targetType": "Feature"}
],
"maxResults": 50
}{
"entityName": "Auth Module",
"direction": "both",
"relationType": "depends_on"
}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Agent (Claude, etc.) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β JSON-RPC 2.0 (stdio)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Memory Graph MCP Server β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β MCP Protocol Layer β β
β β (initialize, tools/list, tools/call) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Tool Registry β β
β β ββββββββββββ ββββββββββββ ββββββββββββ β β
β β β Memory β β Query β β Temporal β β β
β β β Tools(9) β β Tools(3) β β Tools(2) β β β
β β ββββββββββββ ββββββββββββ ββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β KnowledgeBase (Thread-Safe) β β
β β βββββββββββββββββββββββ βββββββββββββββββββββββββββ β β
β β β Mutex<Graph> β β Synonym Dictionary β β β
β β β (In-Memory Cache) β β (Semantic Search) β β β
β β βββββββββββββββββββββββ βββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββ
β memory.jsonl β
β (JSONL Storage) β
ββββββββββββββββββββββ
Entity:
{
"name": "Auth Module",
"entityType": "Module",
"observations": ["Implements JWT", "Uses bcrypt"],
"createdAt": 1704067200,
"updatedAt": 1704153600
}Relation (with Temporal Support):
{
"from": "Alice",
"to": "NYC",
"relationType": "lives_in",
"createdAt": 1704067200,
"validFrom": 1704067200,
"validTo": 1735689599
}Project Module Feature Bug Decision Requirement Milestone Risk Convention Schema Person
contains implements fixes caused_by depends_on blocked_by assigned_to part_of relates_to supersedes affects requires
β οΈ Custom types are allowed with soft warnings.
cargo test
# Output:
# test tests::test_create_entities ... ok
# test tests::test_create_relations ... ok
# test tests::test_search_nodes ... ok
# test tests::test_delete_entities ... ok
# test tests::test_concurrent_access ... ok # 10 threads
# test tests::test_concurrent_read_write ... ok # 5 readers + 3 writers
#
# test result: ok. 6 passed; 0 failed| Environment Variable | Default | Description |
|---|---|---|
MEMORY_FILE_PATH |
./memory.jsonl |
Path to knowledge graph storage |
- Core CRUD operations (9 tools)
- Advanced query tools (3 tools)
- Semantic search with synonyms
- Temporal relations (time-travel)
- Pagination support
- Thread-safe in-memory cache
- Type validation with warnings
- Vector embeddings for true semantic search
- Web UI for graph visualization
- Multi-tenant support
- WAL (Write-Ahead Log) for large graphs
Contributions are welcome! Please read CONTRIBUTING.md first.
# Fork the repo, then:
git checkout -b feature/amazing-feature
cargo test
git commit -m "Add amazing feature"
git push origin feature/amazing-feature
# Open a Pull RequestMIT License - see LICENSE for details.
Built with π¦ Rust and β€οΈ for AI Agents
If this project helps you, please β star the repo!