Living Memory
README.md
# dsh-living-memory-mcp
[中文说明 (README.zh-CN.md)](./README.zh-CN.md)
Zero-dependency SQLite **Living Memory** MCP bridge — share one WAL-safe `memory.sqlite3` ledger (facts, lessons, decisions, todos) across **DeepSeek Harness (DSH)**, **Mistral Vibe CLI**, **Claude Code**, **Codex**, and **Cursor**.
- **Zero dependencies**: Python 3.9+ standard library only (optional `numpy` + OpenAI-compatible embeddings endpoint for hybrid vector retrieval).
- **DSH native schema parity**: Registers the `legion_bigram` SQLite UDF so `memories_fts` triggers, `checksum`, `source` tags, and `memories_vec` stay 100% compatible with DSH's `dsh-living-memory` ledger.
- **Dual-ecosystem package**: Ships both DSH plugin manifests (`package.json`, `cordis.patch.yml`, `dsh-plugin.json`, `index.js`) and **Agent Plugins 1.0** manifests (`plugin.json`, `mcp.json`, `skills/living-memory/SKILL.md`).
```text
DeepSeek Harness (dsh-living-memory) ──┐
Mistral Vibe CLI (Agent Plugin / MCP) ─┼──► ~/.dsh/dsh-living-memory/memory.sqlite3
Claude Code / Codex / Cursor (MCP) ────┘ (SQLite WAL · FTS5 + LIKE RRF · Optional Vectors)
```
---
## Install
### 1. DeepSeek Harness (DSH Plugin)
```bash
dsh plugin --profile desktop add github:Potato-AI0815/dsh-living-memory-mcp
# or for web profile:
dsh plugin --profile web add github:Potato-AI0815/dsh-living-memory-mcp
```
Generate ready-to-paste configs for your external CLI clients (Vibe / Claude / Codex / Cursor):
```bash
node bin/dsh-living-memory-mcp.mjs --print-config
```
### 2. Mistral Vibe CLI (Agent Plugins 1.0)
Clone or copy this repository into `~/.vibe/plugins/dsh-living-memory-mcp/`, then run `/reload`. Tools appear under the `livingMemory` namespace.
> **Windows note**: `mcp.json` uses `python3` (POSIX default). On Windows, Microsoft Store's `WindowsApps/python3.exe` stub often intercepts `python3` — replace `mcp.json` with `mcp.windows.example.json` (uses `python`), or launch via `node bin/dsh-living-memory-mcp.mjs` which auto-detects a real Python 3 interpreter.
### 3. Any MCP Client (Claude Code / Codex / Cursor)
```json
{
"mcpServers": {
"living-memory": {
"command": "python3",
"args": ["/absolute/path/to/dsh-living-memory-mcp/server/mcp_living_memory.py"],
"env": {
"PYTHONUTF8": "1",
"PYTHONIOENCODING": "utf-8",
"DSH_LIVING_MEMORY_DB": "~/.dsh/dsh-living-memory/memory.sqlite3"
}
}
}
}
```
### Bootstrap a Fresh Ledger (No DSH Required)
```bash
python3 server/mcp_living_memory.py --init --db ~/memory.sqlite3
python3 server/mcp_living_memory.py --version
```
---
## Tools
| Tool | Purpose |
|---|---|
| `memory_search` | Hybrid FTS5 + raw-text `LIKE` + optional vector RRF retrieval (`space` / `type` filters) |
| `memory_recent` | Most recent active memories (descending by ID) |
| `memory_todos` | Active (open) todos only |
| `memory_write` | Write a `fact`, `lesson`, `decision`, or `todo` (24h exact-duplicate guard) |
| `memory_close_todo` | Mark an open todo `done` with `closed_at` timestamp and optional note |
| `memory_stats` | Read-only counts by type, space, FTS/vector index coverage |
---
## Configuration
| Variable | Default | Meaning |
|---|---|---|
| `DSH_LIVING_MEMORY_DB` | `~/.dsh/dsh-living-memory/memory.sqlite3` | Ledger path (`~` and env vars expand) |
| `DSH_LIVING_MEMORY_AUTOCREATE` | `0` | Set `1` to create the minimal schema automatically when missing |
| `DSH_LIVING_MEMORY_TZ_OFFSET` | `8` | UTC offset in hours written into `ts` |
| `DSH_LIVING_MEMORY_SOURCE` | `manual:mcp` | `source` tag written on inserts |
| `DSH_LIVING_MEMORY_LIKE_FALLBACK` | `1` | Always fuse a raw-text `LIKE` pass with FTS (set `0` to disable on huge ledgers) |
| `DSH_EMBED_URL` | *(empty)* | OpenAI-compatible embeddings endpoint; enables hybrid vector retrieval |
| `DSH_EMBED_TIMEOUT` | `2.5` | Embedding HTTP timeout in seconds |
| `LEGION_VEC_MODEL` | `local:qwen3-embedding-0.6b` | `model_version` partition tag in `memories_vec` |
Vector search is off until `DSH_EMBED_URL` is configured. Everything else runs 100% offline.
---
## CJK & Host Compatibility Note
DSH's built-in `dsh-living-memory` may index `memories_fts` using a host CJK word segmenter, whereas this zero-dependency server registers a deterministic CJK-bigram + word + date-normalizer `legion_bigram` UDF. To eliminate silent Chinese recall misses on mixed ledgers, `memory_search` always fuses a raw-text `LIKE` ranking pass with FTS5 (and optional vectors) via RRF (`k=40`), and degrades gracefully whenever `numpy`, `memories_vec`, `memories_fts`, or the embeddings endpoint is absent.
---
## Test
```bash
python3 tests/smoke_test.py # 45/45 write + FTS + protocol checks (temp ledger)
python3 tests/smoke_test.py --db ~/memory.sqlite3 --read-only # 20/20 non-mutating checks against an existing ledger
```
## License
MIT — see [LICENSE](./LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues