long-term-memory 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- long_term_memory-0.3.0/.gitignore +38 -0
- long_term_memory-0.3.0/CHANGELOG.md +57 -0
- long_term_memory-0.3.0/CLAUDE.md +12 -0
- long_term_memory-0.3.0/LICENSE +21 -0
- long_term_memory-0.3.0/PKG-INFO +302 -0
- long_term_memory-0.3.0/PROJECT_SUMMARY.md +295 -0
- long_term_memory-0.3.0/README.md +259 -0
- long_term_memory-0.3.0/docs/ARCHITECTURE.md +353 -0
- long_term_memory-0.3.0/docs/BLOG_POST.md +154 -0
- long_term_memory-0.3.0/lib/bindings/utils.js +189 -0
- long_term_memory-0.3.0/lib/tom-select/tom-select.complete.min.js +356 -0
- long_term_memory-0.3.0/lib/tom-select/tom-select.css +334 -0
- long_term_memory-0.3.0/lib/vis-9.1.2/vis-network.css +1 -0
- long_term_memory-0.3.0/lib/vis-9.1.2/vis-network.min.js +27 -0
- long_term_memory-0.3.0/pyproject.toml +96 -0
- long_term_memory-0.3.0/src/aimemory/__init__.py +3 -0
- long_term_memory-0.3.0/src/aimemory/config.py +267 -0
- long_term_memory-0.3.0/src/aimemory/dataset/__init__.py +16 -0
- long_term_memory-0.3.0/src/aimemory/dataset/builder.py +262 -0
- long_term_memory-0.3.0/src/aimemory/dataset/splitter.py +194 -0
- long_term_memory-0.3.0/src/aimemory/dataset/stats.py +290 -0
- long_term_memory-0.3.0/src/aimemory/i18n/__init__.py +95 -0
- long_term_memory-0.3.0/src/aimemory/i18n/en.py +247 -0
- long_term_memory-0.3.0/src/aimemory/i18n/ko.py +321 -0
- long_term_memory-0.3.0/src/aimemory/live_graph/__init__.py +12 -0
- long_term_memory-0.3.0/src/aimemory/live_graph/events.py +65 -0
- long_term_memory-0.3.0/src/aimemory/live_graph/notify.py +58 -0
- long_term_memory-0.3.0/src/aimemory/live_graph/server.py +189 -0
- long_term_memory-0.3.0/src/aimemory/live_graph/static/index.html +478 -0
- long_term_memory-0.3.0/src/aimemory/mcp/__init__.py +5 -0
- long_term_memory-0.3.0/src/aimemory/mcp/__main__.py +5 -0
- long_term_memory-0.3.0/src/aimemory/mcp/bridge.py +533 -0
- long_term_memory-0.3.0/src/aimemory/mcp/server.py +416 -0
- long_term_memory-0.3.0/src/aimemory/memory/__init__.py +50 -0
- long_term_memory-0.3.0/src/aimemory/memory/composer.py +158 -0
- long_term_memory-0.3.0/src/aimemory/memory/consolidation.py +194 -0
- long_term_memory-0.3.0/src/aimemory/memory/forgetting.py +178 -0
- long_term_memory-0.3.0/src/aimemory/memory/graph_retriever.py +148 -0
- long_term_memory-0.3.0/src/aimemory/memory/graph_store.py +510 -0
- long_term_memory-0.3.0/src/aimemory/memory/knowledge_graph.py +188 -0
- long_term_memory-0.3.0/src/aimemory/memory/resolution.py +142 -0
- long_term_memory-0.3.0/src/aimemory/memory/sleep_cycle.py +283 -0
- long_term_memory-0.3.0/src/aimemory/online/__init__.py +35 -0
- long_term_memory-0.3.0/src/aimemory/online/ab_comparator.py +176 -0
- long_term_memory-0.3.0/src/aimemory/online/autonomy.py +119 -0
- long_term_memory-0.3.0/src/aimemory/online/enhanced_encoder.py +59 -0
- long_term_memory-0.3.0/src/aimemory/online/enhanced_policy.py +165 -0
- long_term_memory-0.3.0/src/aimemory/online/gossip.py +279 -0
- long_term_memory-0.3.0/src/aimemory/online/policy.py +440 -0
- long_term_memory-0.3.0/src/aimemory/online/replay_buffer.py +53 -0
- long_term_memory-0.3.0/src/aimemory/online/reranker.py +580 -0
- long_term_memory-0.3.0/src/aimemory/online/rule_verifier.py +57 -0
- long_term_memory-0.3.0/src/aimemory/online/transport.py +158 -0
- long_term_memory-0.3.0/src/aimemory/reward/__init__.py +31 -0
- long_term_memory-0.3.0/src/aimemory/reward/calculator.py +255 -0
- long_term_memory-0.3.0/src/aimemory/reward/feedback_detector.py +209 -0
- long_term_memory-0.3.0/src/aimemory/reward/implicit_detector.py +67 -0
- long_term_memory-0.3.0/src/aimemory/reward/korean_patterns.py +269 -0
- long_term_memory-0.3.0/src/aimemory/reward/signals.py +516 -0
- long_term_memory-0.3.0/src/aimemory/schemas.py +165 -0
- long_term_memory-0.3.0/src/aimemory/selfplay/__init__.py +34 -0
- long_term_memory-0.3.0/src/aimemory/selfplay/engine.py +426 -0
- long_term_memory-0.3.0/src/aimemory/selfplay/llm_client.py +172 -0
- long_term_memory-0.3.0/src/aimemory/selfplay/memory_agent.py +402 -0
- long_term_memory-0.3.0/src/aimemory/selfplay/scenarios.py +201 -0
- long_term_memory-0.3.0/src/aimemory/visualize.py +374 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.egg-info/
|
|
6
|
+
*.egg
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
|
|
10
|
+
# Virtual environment
|
|
11
|
+
.venv/
|
|
12
|
+
|
|
13
|
+
# Testing
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
htmlcov/
|
|
16
|
+
.coverage
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
*.swp
|
|
22
|
+
*.swo
|
|
23
|
+
|
|
24
|
+
# OS
|
|
25
|
+
.DS_Store
|
|
26
|
+
Thumbs.db
|
|
27
|
+
|
|
28
|
+
# AIMemory runtime data
|
|
29
|
+
memory_db/
|
|
30
|
+
checkpoints/
|
|
31
|
+
|
|
32
|
+
# Data artifacts (keep raw source files, ignore generated)
|
|
33
|
+
data/embeddings/
|
|
34
|
+
data/plots/
|
|
35
|
+
data/splits/
|
|
36
|
+
|
|
37
|
+
# Claude Code
|
|
38
|
+
.claude/plans/
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.3.0] - 2026-03-01
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Project renamed** from `mcp-memory-server` to `long-term-memory`. Python import name (`aimemory`) and CLI commands unchanged.
|
|
13
|
+
- **GitHub repository** renamed to `long-term-memory` (old URL auto-redirects)
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **Auto-linking** — New memories automatically link to similar existing ones (similarity ≥ 0.92) via bidirectional graph edges
|
|
18
|
+
- **Live graph visualization** (`aimemory-live`) — Real-time WebSocket-based memory graph in the browser
|
|
19
|
+
- Force-directed layout (vis.js ForceAtlas2) with category-based coloring
|
|
20
|
+
- Glow effects on save (green) and search (blue)
|
|
21
|
+
- Event log sidebar with hover-to-highlight related nodes
|
|
22
|
+
- Persistent event history across browser refreshes
|
|
23
|
+
- Cross-process event push (MCP → live server via WebSocket `/event` path)
|
|
24
|
+
- **`memory_visualize` tool** — Generate interactive static HTML graph (13th MCP tool)
|
|
25
|
+
- **`[live]` optional dependency** — `websockets>=12.0`
|
|
26
|
+
|
|
27
|
+
### Deprecated
|
|
28
|
+
|
|
29
|
+
- PyPI package `mcp-memory-server` — use `long-term-memory` instead
|
|
30
|
+
|
|
31
|
+
## [0.2.0] - 2026-02-28
|
|
32
|
+
|
|
33
|
+
First public release.
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- **MCP Server** with 12 tools: `auto_search`, `memory_save`, `memory_search`, `memory_update`, `memory_delete`, `memory_get_related`, `memory_pin`, `memory_unpin`, `memory_stats`, `sleep_cycle_run`, `policy_status`, `policy_decide`
|
|
38
|
+
- **RL Memory Policy** — Rule-based importance scoring + MLP contextual bandit (SAVE/SKIP/RETRIEVE)
|
|
39
|
+
- **Enhanced Policy** (opt-in) — 778d state encoder (SentenceTransformer 768d + 10d hand-crafted), experience replay buffer, progressive autonomy
|
|
40
|
+
- **Semantic Search** — ChromaDB vector store with `intfloat/multilingual-e5-small` embeddings
|
|
41
|
+
- **Knowledge Graph** — NetworkX-based entity-relation graph with multi-hop traversal
|
|
42
|
+
- **GraphRAG Hybrid Retrieval** (opt-in) — Vector similarity + graph traversal with RL re-ranker (11d features)
|
|
43
|
+
- **Multi-Resolution Text** — 3 levels (full text, keyword summary, entity triples) with token-budget-aware composition
|
|
44
|
+
- **Forgetting Pipeline** — Decay-based aging with compress → deactivate → delete stages
|
|
45
|
+
- **Sleep Cycle** — Periodic maintenance: consolidation, resolution regeneration, forgetting, checkpoint saving
|
|
46
|
+
- **Immutable Memories** — Protected from modification/deletion with SHA-256 rule hash verification
|
|
47
|
+
- **Pin/Unpin** — User-controlled forgetting protection
|
|
48
|
+
- **Multilingual Support** — Korean (ko) and English (en) i18n patterns
|
|
49
|
+
- **P2P Federated Learning** — Gossip protocol with differential privacy and Krum aggregation
|
|
50
|
+
- **A/B Comparison Framework** — Baseline vs re-ranked retrieval comparison
|
|
51
|
+
- **CI/CD** — GitHub Actions with Python 3.11/3.12/3.13 matrix
|
|
52
|
+
- **611 tests** passing across 31 test files
|
|
53
|
+
|
|
54
|
+
### Removed
|
|
55
|
+
|
|
56
|
+
- Deprecated DualHeadDQN offline training pipeline (replaced by online MLP bandit)
|
|
57
|
+
- `ExtractorConfig` (unused after DQN removal)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Long-Term Memory System
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Persistent, self-organizing long-term memory for AI assistants. MCP server with semantic search, knowledge graphs, RL-powered retrieval, and real-time graph visualization.
|
|
5
|
+
|
|
6
|
+
- PyPI package: `long-term-memory` (previously `mcp-memory-server`)
|
|
7
|
+
- Python import: `aimemory` (unchanged)
|
|
8
|
+
- CLI: `aimemory-mcp`, `aimemory-viz`, `aimemory-live`
|
|
9
|
+
|
|
10
|
+
## Conventions
|
|
11
|
+
- Use the `.claude/agents/` directory for custom agent definitions
|
|
12
|
+
- Agents are defined as markdown files describing their role, tools, and instructions
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AIMemory Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: long-term-memory
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Long-term memory system for AI assistants — persistent, searchable, self-organizing memory powered by semantic search, knowledge graphs, and reinforcement learning
|
|
5
|
+
Project-URL: Homepage, https://github.com/ihwooMil/long-term-memory
|
|
6
|
+
Project-URL: Repository, https://github.com/ihwooMil/long-term-memory
|
|
7
|
+
Project-URL: Issues, https://github.com/ihwooMil/long-term-memory/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/ihwooMil/long-term-memory/blob/main/CHANGELOG.md
|
|
9
|
+
Author: ihwoo
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,claude,knowledge-graph,llm,long-term-memory,mcp,memory,rag,reinforcement-learning
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: <3.14,>=3.11
|
|
22
|
+
Requires-Dist: chromadb>=0.5.0
|
|
23
|
+
Requires-Dist: mcp[cli]>=1.2.0
|
|
24
|
+
Requires-Dist: pydantic>=2.0
|
|
25
|
+
Requires-Dist: sentence-transformers>=3.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
29
|
+
Provides-Extra: ko
|
|
30
|
+
Requires-Dist: mecab-ko-dic>=1.0.0; extra == 'ko'
|
|
31
|
+
Requires-Dist: mecab-python3>=1.0.9; extra == 'ko'
|
|
32
|
+
Provides-Extra: live
|
|
33
|
+
Requires-Dist: websockets>=12.0; extra == 'live'
|
|
34
|
+
Provides-Extra: train
|
|
35
|
+
Requires-Dist: matplotlib>=3.8; extra == 'train'
|
|
36
|
+
Requires-Dist: ollama>=0.4.0; extra == 'train'
|
|
37
|
+
Requires-Dist: pandas>=2.0; extra == 'train'
|
|
38
|
+
Requires-Dist: pyarrow>=15.0; extra == 'train'
|
|
39
|
+
Requires-Dist: tqdm>=4.66; extra == 'train'
|
|
40
|
+
Provides-Extra: viz
|
|
41
|
+
Requires-Dist: pyvis>=0.3.2; extra == 'viz'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# Long-Term Memory
|
|
45
|
+
|
|
46
|
+
**Persistent, self-organizing memory for AI assistants.**
|
|
47
|
+
|
|
48
|
+
> Drop-in MCP server that gives Claude (and any MCP client) long-term memory — powered by semantic search, knowledge graphs, and reinforcement learning.
|
|
49
|
+
|
|
50
|
+
[](https://github.com/ihwooMil/long-term-memory/actions)
|
|
51
|
+
[](https://pypi.org/project/long-term-memory/)
|
|
52
|
+
[](https://pypi.org/project/long-term-memory/)
|
|
53
|
+
[](https://opensource.org/licenses/MIT)
|
|
54
|
+
|
|
55
|
+
> **Note:** This package was previously published as [`mcp-memory-server`](https://pypi.org/project/mcp-memory-server/). That package is deprecated — please use `long-term-memory` going forward.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Why Long-Term Memory?
|
|
60
|
+
|
|
61
|
+
Current AI memory tools have two critical problems:
|
|
62
|
+
|
|
63
|
+
| Problem | How we solve it |
|
|
64
|
+
|---------|----------------|
|
|
65
|
+
| **Manual retrieval** — you must ask "do you remember X?" | `auto_search` runs every turn, injecting relevant memories automatically |
|
|
66
|
+
| **Token waste** — entire memory dump inserted into context | Multi-resolution composer selects top-K memories within a token budget |
|
|
67
|
+
|
|
68
|
+
## Key Features
|
|
69
|
+
|
|
70
|
+
- **RL-powered policy** — Contextual bandit decides when to save, skip, or retrieve (not just keyword matching)
|
|
71
|
+
- **Semantic search** — ChromaDB + multilingual sentence-transformer embeddings (`intfloat/multilingual-e5-small`)
|
|
72
|
+
- **Knowledge graph** — Entity-relation graph (NetworkX) for multi-hop reasoning
|
|
73
|
+
- **GraphRAG hybrid retrieval** — Vector similarity + graph traversal, fused and re-ranked by an RL re-ranker
|
|
74
|
+
- **Auto-linking** — New memories automatically link to similar existing ones (similarity ≥ 0.92)
|
|
75
|
+
- **Multi-resolution text** — Full text → summary → entity triples, composed within token budget
|
|
76
|
+
- **Forgetting pipeline** — Decay-based aging with consolidation, pinning, and immutable protection
|
|
77
|
+
- **Sleep cycle** — Periodic maintenance: dedup, compress, forget, checkpoint
|
|
78
|
+
- **Live graph** — Real-time WebSocket visualization of the memory graph
|
|
79
|
+
- **Multilingual** — Korean and English pattern support out of the box
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Quick Start (2 minutes)
|
|
84
|
+
|
|
85
|
+
### 1. Install
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install long-term-memory
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Or with [uv](https://docs.astral.sh/uv/):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
uv pip install long-term-memory
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
<details>
|
|
98
|
+
<summary>Optional extras</summary>
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install long-term-memory[ko] # Korean NLP support
|
|
102
|
+
pip install long-term-memory[live] # Real-time graph visualization
|
|
103
|
+
pip install long-term-memory[viz] # Static graph visualization
|
|
104
|
+
```
|
|
105
|
+
</details>
|
|
106
|
+
|
|
107
|
+
### 2. Connect to OpenClaw
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
mcporter config add aimemory --command aimemory-mcp --scope home
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 3. Connect to Claude Desktop
|
|
114
|
+
|
|
115
|
+
Add to your `claude_desktop_config.json`:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"aimemory": {
|
|
121
|
+
"command": "aimemory-mcp"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
That's it. Claude now has persistent memory across all conversations.
|
|
128
|
+
|
|
129
|
+
<details>
|
|
130
|
+
<summary>With live graph visualization</summary>
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"mcpServers": {
|
|
135
|
+
"aimemory": {
|
|
136
|
+
"command": "aimemory-mcp",
|
|
137
|
+
"args": ["--with-live"]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Then open `http://127.0.0.1:8765` to see the live memory graph.
|
|
144
|
+
</details>
|
|
145
|
+
|
|
146
|
+
<details>
|
|
147
|
+
<summary>Advanced: custom data path or uv project mode</summary>
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"mcpServers": {
|
|
152
|
+
"aimemory": {
|
|
153
|
+
"command": "uv",
|
|
154
|
+
"args": ["run", "--project", "/path/to/long-term-memory", "aimemory-mcp", "--with-live"],
|
|
155
|
+
"env": {
|
|
156
|
+
"AIMEMORY_DB_PATH": "/path/to/memory_db"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
</details>
|
|
163
|
+
|
|
164
|
+
### 4. Connect to Claude Code
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
claude mcp add aimemory -- aimemory-mcp
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Or with live graph:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
claude mcp add aimemory -- aimemory-mcp --with-live
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Live Graph Visualization
|
|
179
|
+
|
|
180
|
+
Real-time WebSocket-based memory graph that updates as memories are saved, searched, or deleted.
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Option 1: auto-start with MCP server
|
|
184
|
+
aimemory-mcp --with-live
|
|
185
|
+
|
|
186
|
+
# Option 2: standalone server
|
|
187
|
+
aimemory-live --port 8765
|
|
188
|
+
|
|
189
|
+
# Option 3: via environment variable
|
|
190
|
+
AIMEMORY_LIVE=1 aimemory-mcp
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Open `http://127.0.0.1:8765` in a browser. Requires the `[live]` extra (`pip install long-term-memory[live]`). Features:
|
|
194
|
+
|
|
195
|
+
- Force-directed graph layout with category-based coloring
|
|
196
|
+
- New nodes glow green on save, blue on search
|
|
197
|
+
- Event log sidebar with hover-to-highlight (hover a log entry to highlight related nodes)
|
|
198
|
+
- Persistent event history across browser refreshes
|
|
199
|
+
- Cross-process events — MCP server pushes events to the live graph via WebSocket
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## MCP Tools (13)
|
|
204
|
+
|
|
205
|
+
| Tool | Description |
|
|
206
|
+
|------|-------------|
|
|
207
|
+
| `auto_search` | Auto-retrieve relevant memories at turn start (multi-resolution context) |
|
|
208
|
+
| `memory_save` | Save a new memory with keywords, category, and relations |
|
|
209
|
+
| `memory_search` | Semantic similarity search |
|
|
210
|
+
| `memory_update` | Update content or keywords of an existing memory |
|
|
211
|
+
| `memory_delete` | Delete a memory (respects immutability) |
|
|
212
|
+
| `memory_get_related` | BFS graph traversal for related memories |
|
|
213
|
+
| `memory_pin` / `memory_unpin` | Protect memories from forgetting |
|
|
214
|
+
| `memory_stats` | Total count and category breakdown |
|
|
215
|
+
| `memory_visualize` | Generate interactive graph HTML |
|
|
216
|
+
| `sleep_cycle_run` | Trigger maintenance (consolidation + forgetting + checkpoint) |
|
|
217
|
+
| `policy_status` | RL policy state (epsilon, action distribution, updates) |
|
|
218
|
+
| `policy_decide` | Ask the RL policy for a SAVE/SKIP/RETRIEVE decision with reasoning |
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Configuration
|
|
223
|
+
|
|
224
|
+
All settings via environment variables:
|
|
225
|
+
|
|
226
|
+
| Variable | Default | Description |
|
|
227
|
+
|----------|---------|-------------|
|
|
228
|
+
| `AIMEMORY_DB_PATH` | `./memory_db` | ChromaDB persistence directory |
|
|
229
|
+
| `AIMEMORY_LANGUAGE` | `ko` | Language for pattern matching (`ko` / `en`) |
|
|
230
|
+
| `AIMEMORY_EMBEDDING_MODEL` | `intfloat/multilingual-e5-small` | Sentence-transformer model |
|
|
231
|
+
| `AIMEMORY_LOG_LEVEL` | `INFO` | Logging level |
|
|
232
|
+
| `AIMEMORY_ENHANCED_POLICY` | `0` | Enable 778d enhanced RL policy (`1` to enable) |
|
|
233
|
+
| `AIMEMORY_GRAPH_RAG` | `0` | Enable GraphRAG hybrid retrieval (`1` to enable) |
|
|
234
|
+
| `AIMEMORY_LIVE_HOST` | `127.0.0.1` | Live graph server host (for event push) |
|
|
235
|
+
| `AIMEMORY_LIVE_PORT` | `8765` | Live graph server port (for event push) |
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Architecture
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
┌─────────────────────────────────────────────────┐
|
|
243
|
+
│ MCP Client │
|
|
244
|
+
│ (Claude Desktop / Claude Code) │
|
|
245
|
+
└────────────────────┬────────────────────────────┘
|
|
246
|
+
│ stdio (JSON-RPC)
|
|
247
|
+
┌────────────────────▼────────────────────────────┐
|
|
248
|
+
│ FastMCP Server (13 tools) │
|
|
249
|
+
├──────────────────────────────────────────────────┤
|
|
250
|
+
│ MemoryBridge (orchestrator) │
|
|
251
|
+
├──────────┬──────────┬──────────┬─────────────────┤
|
|
252
|
+
│ RL Policy│ Retrieval│ Storage │ Maintenance │
|
|
253
|
+
│ │ │ │ │
|
|
254
|
+
│ Rule- │ ChromaDB │ Graph │ Sleep Cycle │
|
|
255
|
+
│ Based + │ vector + │ Memory │ (consolidation, │
|
|
256
|
+
│ MLP │ Knowledge│ Store │ forgetting, │
|
|
257
|
+
│ Bandit │ Graph │ │ checkpoints) │
|
|
258
|
+
│ │ (GraphRAG)│ │ │
|
|
259
|
+
│ Re-ranker│ │ │ │
|
|
260
|
+
│ (11d MLP)│ │ │ │
|
|
261
|
+
└──────────┴──────────┴──────────┴─────────────────┘
|
|
262
|
+
↕ WebSocket (cross-process)
|
|
263
|
+
┌──────────────────────────────────────────────────┐
|
|
264
|
+
│ Live Graph Server (aimemory-live) │
|
|
265
|
+
│ vis.js force-directed graph + event log │
|
|
266
|
+
└──────────────────────────────────────────────────┘
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Development
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Clone and install dev dependencies
|
|
275
|
+
git clone https://github.com/ihwooMil/long-term-memory.git
|
|
276
|
+
cd long-term-memory
|
|
277
|
+
uv sync --extra dev
|
|
278
|
+
|
|
279
|
+
# Run tests (611+ tests)
|
|
280
|
+
uv run pytest tests/ -q
|
|
281
|
+
|
|
282
|
+
# Lint & format
|
|
283
|
+
uv run ruff check src/ tests/
|
|
284
|
+
uv run ruff format src/ tests/
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Migrating from mcp-memory-server
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
pip uninstall mcp-memory-server
|
|
293
|
+
pip install long-term-memory
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
No code changes needed — the Python import name (`aimemory`) and CLI commands (`aimemory-mcp`, `aimemory-viz`, `aimemory-live`) remain the same.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## License
|
|
301
|
+
|
|
302
|
+
MIT — see [LICENSE](LICENSE) for details.
|