https://github.com/maithanhduyan/memory-graph
Memory Graph - Model Context Protocol
https://github.com/maithanhduyan/memory-graph
mcp-server memory-graph
Last synced: 3 months ago
JSON representation
Memory Graph - Model Context Protocol
- Host: GitHub
- URL: https://github.com/maithanhduyan/memory-graph
- Owner: maithanhduyan
- License: mit
- Created: 2026-01-10T13:14:01.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2026-01-11T04:24:48.000Z (5 months ago)
- Last Synced: 2026-01-11T04:28:09.455Z (5 months ago)
- Topics: mcp-server, memory-graph
- Language: Rust
- Homepage:
- Size: 122 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# π§ Memory Graph MCP Server
[](https://www.rust-lang.org/)
[](https://modelcontextprotocol.io/)
[](https://github.com/maithanhduyan/memory-graph/actions/workflows/rust.yml)
[](https://github.com/maithanhduyan/memory-graph/actions/workflows/release.yml)
[](LICENSE)
[](https://github.com/maithanhduyan/memory-graph)
**π A blazing-fast Knowledge Graph server for AI Agents**
*Give your AI perfect memory. Forever.*
[Features](#-features) β’ [Quick Start](#-quick-start) β’ [API Reference](#-api-reference) β’ [Architecture](#-architecture)
---
> β οΈ **DISCLAIMER: ALL SOURCE CODE IS AI-GENERATED. THE AUTHOR ASSUMES NO LIABILITY FOR PATENT, INTELLECTUAL PROPERTY, OR LEGAL COMPLIANCE ISSUES IN ANY JURISDICTION.**
---
## π― The Problem
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..."
```
---
## β¨ Features
### π οΈ 15 Powerful Tools
| 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 |
### π₯ Why Memory Graph?
| 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` |
---
## π Quick Start
### Option 1: Build from Source
```bash
git clone https://github.com/maithanhduyan/memory-graph.git
cd memory-graph
cargo build --release
```
### Option 2: Docker
```bash
docker run -v $(pwd)/data:/data ghcr.io/maithanhduyan/memory-graph
```
### Configure VS Code
Create `.vscode/mcp.json`:
```json
{
"servers": {
"memory": {
"type": "stdio",
"command": "${workspaceFolder}/target/release/memory-server.exe",
"env": {
"MEMORY_FILE_PATH": "${workspaceFolder}/memory.jsonl"
}
}
}
}
```
### Configure Claude Desktop
Add to `claude_desktop_config.json`:
```json
{
"mcpServers": {
"memory": {
"command": "/path/to/memory-server",
"env": {
"MEMORY_FILE_PATH": "/path/to/memory.jsonl"
}
}
}
}
```
---
## π API Reference
### Memory Tools
#### `create_entities`
```json
{
"entities": [{
"name": "Auth Module",
"entityType": "Module",
"observations": ["Implements JWT", "Uses bcrypt"]
}]
}
```
#### `create_relations`
```json
{
"relations": [{
"from": "Auth Module",
"to": "User Service",
"relationType": "depends_on"
}]
}
```
#### `search_nodes` (with Semantic Search)
```json
{
"query": "developer", // Also matches: coder, programmer, engineer
"limit": 10,
"includeRelations": true
}
```
#### `read_graph` (with Pagination)
```json
{
"limit": 50,
"offset": 0
}
```
### Temporal Queries
#### `get_relations_at_time`
```json
{
"timestamp": 1704067200,
"entityName": "Alice"
}
// Returns: Relations valid at that specific point in time
```
#### `get_relation_history`
```json
{
"entityName": "Alice"
}
// Returns: All relations (current + expired) with isCurrent flag
```
### Graph Traversal
#### `traverse`
```json
{
"startNode": "Project: MyApp",
"path": [
{"relationType": "contains", "direction": "out"},
{"relationType": "implements", "direction": "out", "targetType": "Feature"}
],
"maxResults": 50
}
```
#### `get_related`
```json
{
"entityName": "Auth Module",
"direction": "both",
"relationType": "depends_on"
}
```
---
## ποΈ Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β β Synonym Dictionary β β β
β β β (In-Memory Cache) β β (Semantic Search) β β β
β β βββββββββββββββββββββββ βββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββ
β memory.jsonl β
β (JSONL Storage) β
ββββββββββββββββββββββ
```
### Data Model
**Entity:**
```json
{
"name": "Auth Module",
"entityType": "Module",
"observations": ["Implements JWT", "Uses bcrypt"],
"createdAt": 1704067200,
"updatedAt": 1704153600
}
```
**Relation (with Temporal Support):**
```json
{
"from": "Alice",
"to": "NYC",
"relationType": "lives_in",
"createdAt": 1704067200,
"validFrom": 1704067200,
"validTo": 1735689599
}
```
---
## π Standard Types
### Entity Types (11)
`Project` `Module` `Feature` `Bug` `Decision` `Requirement` `Milestone` `Risk` `Convention` `Schema` `Person`
### Relation Types (12)
`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.
---
## π§ͺ Testing
```bash
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
```
---
## π§ Configuration
| Environment Variable | Default | Description |
|---------------------|---------|-------------|
| `MEMORY_FILE_PATH` | `./memory.jsonl` | Path to knowledge graph storage |
---
## πΊοΈ Roadmap
- [x] Core CRUD operations (9 tools)
- [x] Advanced query tools (3 tools)
- [x] Semantic search with synonyms
- [x] Temporal relations (time-travel)
- [x] Pagination support
- [x] Thread-safe in-memory cache
- [x] 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
---
## π€ Contributing
Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.
```bash
# 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 Request
```
---
## π License
MIT License - see [LICENSE](LICENSE) for details.
---
**Built with π¦ Rust and β€οΈ for AI Agents**
*If this project helps you, please β star the repo!*
[Report Bug](https://github.com/maithanhduyan/memory-graph/issues) Β· [Request Feature](https://github.com/maithanhduyan/memory-graph/issues)