prism-mcp-server 4.6.1 → 5.2.0

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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Prism MCP — The Mind Palace for AI Agents 🧠
1
+ # 🧠 Prism MCP — The Mind Palace for AI Agents
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/prism-mcp-server?color=cb0000&label=npm)](https://www.npmjs.com/package/prism-mcp-server)
4
4
  [![MCP Registry](https://img.shields.io/badge/MCP_Registry-listed-00ADD8?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyTDIgN2wxMCA1IDEwLTUtMTAtNXpNMiAxN2wxMCA1IDEwLTV2LTJMMTI0djJMMiA5djh6Ii8+PC9zdmc+)](https://registry.modelcontextprotocol.io)
@@ -8,289 +8,102 @@
8
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
9
9
  [![Node.js](https://img.shields.io/badge/Node.js-18+-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
10
10
 
11
- > **Your AI agent's memory that survives between sessions.** Prism MCP is a Model Context Protocol server that gives Claude Desktop, Cursor, Windsurf, and any MCP client **persistent memory**, **time travel**, **visual context**, **multi-agent sync**, **GDPR-compliant deletion**, **memory tracing**, and **LangChain integration** — all running locally with zero cloud dependencies.
12
- >
13
- > Built with **SQLite + F32_BLOB vector search**, **optimistic concurrency control**, **MCP Prompts & Resources**, **auto-compaction**, **Gemini-powered Morning Briefings**, **MemoryTrace explainability**, and optional **Supabase cloud sync**.
14
-
15
- ## Table of Contents
16
-
17
- - [What's New (v4.6.0)](#whats-new-in-v460--opentelemetry-observability-)
18
- - [Multi-Instance Support](#multi-instance-support)
19
- - [How Prism Compares](#how-prism-compares)
20
- - [Quick Start](#quick-start-zero-config--local-mode)
21
- - [Mind Palace Dashboard](#-the-mind-palace-dashboard)
22
- - [Integration Examples](#integration-examples)
23
- - [Claude Code Integration (Hooks)](#claude-code-integration-hooks)
24
- - [Gemini / Antigravity Integration](#gemini--antigravity-integration)
25
- - [Use Cases](#use-cases)
26
- - [Architecture](#architecture)
27
- - [Tool Reference](#tool-reference)
28
- - [Agent Hivemind — Role Usage](#agent-hivemind--role-usage)
29
- - [LangChain / LangGraph Integration](#langchain--langgraph-integration)
30
- - [Environment Variables](#environment-variables)
31
- - [Boot Settings (Restart Required)](#-boot-settings-restart-required)
32
- - [Progressive Context Loading](#progressive-context-loading)
33
- - [Time Travel](#time-travel-version-history)
34
- - [Agent Telepathy](#agent-telepathy-multi-client-sync)
35
- - [Knowledge Accumulation](#knowledge-accumulation)
36
- - [GDPR Compliance](#gdpr-compliance)
37
- - [Observability & Tracing](#observability--tracing)
38
- - [Supabase Setup](#supabase-setup-cloud-mode)
39
- - [Project Structure](#project-structure)
40
- - [Hybrid Search Pipeline](#hybrid-search-pipeline-brave--vertex-ai)
41
- - [🚀 Roadmap](#-roadmap)
11
+ **Your AI agent forgets everything between sessions. Prism fixes that.**
42
12
 
43
- ---
44
-
45
- ## What's New in v4.6.0 — OpenTelemetry Observability 🔭
46
-
47
- > **🔭 Full distributed tracing for every MCP tool call, LLM provider hop, and background AI worker.**
48
- > Configure in the new **🔭 Observability** tab in Mind Palace — no code changes required.
49
- > Activates a 4-tier span waterfall: `mcp.call_tool` → `worker.vlm_caption` → `llm.generate_image_description` / `llm.generate_embedding`.
50
-
51
- <a name="whats-new-in-v451--gdpr-export-"></a>
52
- <details>
53
- <summary><strong>What's in v4.5.1 — GDPR Export & Test Hardening 🔒</strong></summary>
54
-
55
- | Feature | Description |
56
- |---|---|
57
- | 📦 **`session_export_memory`** | Full ZIP export of project memory (JSON + Markdown). Satisfies GDPR Art. 20 Right to Portability. API keys redacted, embeddings stripped. |
58
- | 🧪 **270 Tests** | Concurrent export safety, redaction edge cases, MCP contract validation under load. |
59
-
60
- </details>
61
-
62
- <a name="whats-new-in-v450--vlm-multimodal-memory-"></a>
63
- <details>
64
- <summary><strong>What's in v4.5.0 — VLM Multimodal Memory 👁️</strong></summary>
65
-
66
- | Feature | Description |
67
- |---|---|
68
- | 👁️ **Visual Memory** | `session_save_image` → VLM auto-caption → ledger entry → vector embedding. Images become semantically searchable with zero schema changes. |
69
- | 🛡️ **Provider Size Guards** | Anthropic 5MB hard cap, Gemini/OpenAI 20MB. Pre-flight check before API call. |
70
-
71
- </details>
72
-
73
- <a name="whats-new-in-v440--pluggable-llm-adapters-"></a>
74
- <details>
75
- <summary><strong>What's in v4.4.0 — Pluggable LLM Adapters (BYOM) 🔌</strong></summary>
76
-
77
- | Feature | Description |
78
- |---|---|
79
- | 🔌 **BYOM** | OpenAI, Anthropic, Gemini, Ollama adapters. Text + embedding providers independently configurable. |
80
- | 🛡️ **Air-Gapped** | Full local mode via `http://127.0.0.1:11434` — zero cloud API keys required. |
81
-
82
- </details>
83
-
84
- <a name="whats-new-in-v430--the-bridge-"></a>
85
- <details>
86
- <summary><strong>What's in v4.3.0 — The Bridge: Knowledge Sync Rules 🌉</strong></summary>
87
-
88
- > **🧠 Active Behavioral Memory & IDE Sync**
89
- > Prism doesn't just log what happened—it learns. When an agent is corrected, the memory gains "Importance". Once an insight graduates (Importance >= 7), Prism automatically syncs it to `.cursorrules` / `.clauderules` — permanent, zero-token IDE enforcement.
90
-
91
- </details>
92
-
93
-
94
- <a name="whats-new-in-v420--project-repo-registry-"></a>
95
- <details>
96
- <summary><strong>What's in v4.2.0 — Project Repo Registry 🗂️</strong></summary>
97
-
98
- | Feature | Description |
99
- |---|---|
100
- | 🗂️ **Project Repo Paths** | Map each project to its repo directory in the dashboard. `session_save_ledger` validates `files_changed` paths and warns on mismatch — prevents cross-project contamination. |
101
- | 🔄 **Universal Auto-Load** | Auto-load projects via dynamic tool descriptions — works across all MCP clients (Claude, Cursor, Gemini, Antigravity) without lifecycle hooks. Dashboard is the sole source of truth. |
102
- | 🏠 **Dashboard-First Config** | Removed `PRISM_AUTOLOAD_PROJECTS` env var override. The Mind Palace dashboard is now the single source of truth for auto-load project configuration. |
103
-
104
- </details>
105
-
106
- <a name="whats-in-v410--auto-migration--multi-instance-"></a>
107
- <details>
108
- <summary><strong>What's in v4.1.0 — Auto-Migration & Multi-Instance 🔀</strong></summary>
109
-
110
- | Feature | Description |
111
- |---|---|
112
- | 🔄 **Auto-Migrations (Supabase)** | Zero-config schema upgrades — pending DDL migrations run automatically on server startup via `prism_apply_ddl` RPC. |
113
- | 🔀 **Multi-Instance Support** | `PRISM_INSTANCE` env var enables instance-aware PID locks — run multiple Prism servers side-by-side without conflicts. |
114
- | 🛡️ **Server Lifecycle Management** | Singleton PID lock with graceful shutdown and stale PID recovery. |
13
+ One command. Persistent memory. Zero cloud dependencies.
115
14
 
116
- </details>
117
-
118
- <a name="whats-in-v400--behavioral-memory-"></a>
119
- <details>
120
- <summary><strong>What's in v4.0.0 — Behavioral Memory 🧠</strong></summary>
121
-
122
- | Feature | Description |
123
- |---|---|
124
- | 🧠 **Behavioral Memory** | `session_save_experience` — log actions, outcomes, corrections with confidence scores. Auto-injects warnings into context so agents learn from mistakes. |
125
- | 🎯 **Dynamic Roles** | Role auto-resolves from dashboard settings. Set once in Mind Palace, applies everywhere. |
126
- | 📏 **Token Budget** | `max_tokens` on `session_load_context` — intelligently truncates to fit your budget. |
127
- | 📉 **Importance Decay** | Stale corrections auto-fade over time to keep context fresh. |
128
- | 🔧 **Claude Code Hooks** | Simplified SessionStart/Stop hooks that reliably trigger MCP tool calls. |
15
+ ```bash
16
+ npx -y prism-mcp-server
17
+ ```
129
18
 
130
- </details>
19
+ Works with **Claude Desktop · Claude Code · Cursor · Windsurf · Cline · Gemini · Antigravity** — any MCP client.
131
20
 
132
- <a name="whats-in-v310--memory-lifecycle-"></a>
133
- <details>
134
- <summary><strong>What's in v3.1.0 — Memory Lifecycle 🔄</strong></summary>
21
+ ---
135
22
 
136
- | Feature | Description |
137
- |---|---|
138
- | 📊 **Memory Analytics** | Dashboard sparkline chart, session counts, rollup savings, context richness metrics. |
139
- | ⏳ **Data Retention (TTL)** | Per-project TTL via `knowledge_set_retention` or dashboard. Auto-expires old entries every 12h. |
140
- | 🗜️ **Auto-Compaction** | Background health check after saves — auto-compacts when brain is degraded. |
141
- | 📦 **PKM Export** | Export project memory as ZIP of Markdown files for Obsidian/Logseq. |
142
- | 🧪 **95 Tests** | Analytics, TTL, rollup, compaction, type guards, and export coverage. |
23
+ ## Why Prism?
143
24
 
144
- </details>
25
+ Every time you start a new conversation with an AI coding assistant, it starts from scratch. You re-explain your architecture, re-describe your decisions, re-list your TODOs. Hours of context — gone.
145
26
 
146
- <details>
147
- <summary><strong>What's in v3.0.1 — Agent Identity & Brain Clean-up 🧹</strong></summary>
27
+ **Prism gives your agent a brain that persists.** Save what matters at the end of each session. Load it back instantly on the next one. Your agent remembers what it did, what it learned, and what's left to do.
148
28
 
149
- | Feature | Description |
150
- |---|---|
151
- | 🧹 **Brain Health Clean-up** | One-click **Fix Issues** button — detects and cleans orphaned handoffs, missing embeddings, stale rollups. |
152
- | 👤 **Agent Identity** | Set Default Role and Agent Name in dashboard — auto-applies as fallback in all tools. |
153
- | 📜 **Role-Scoped Skills** | Per-role persistent rules documents, auto-injected at `session_load_context`. |
154
- | 🔤 **Resource Formatting** | `memory://` resources render as formatted text instead of raw JSON. |
29
+ ---
155
30
 
156
- </details>
31
+ ## ✨ What Makes Prism Different
157
32
 
158
- <a name="whats-in-v300--agent-hivemind-"></a>
159
- <details>
160
- <summary><strong>What's in v3.0.0 — Agent Hivemind 🐝</strong></summary>
161
-
162
- | Feature | Description |
163
- |---|---|
164
- | 🐝 **Role-Scoped Memory** | Optional `role` param — each role gets isolated memory within a project. |
165
- | 👥 **Agent Registry** | `agent_register`, `agent_heartbeat`, `agent_list_team` — multi-agent discovery. |
166
- | 🎯 **Team Roster** | Auto-injected teammate awareness during context loading. |
167
- | ⚙️ **Dashboard Settings** | Runtime toggles backed by persistent key-value store. |
168
- | 📡 **Hivemind Radar** | Dashboard widget showing active agents, roles, and heartbeats. |
169
- | 🔒 **Conditional Tools** | `PRISM_ENABLE_HIVEMIND` gates multi-agent tools. |
170
- | ✅ **58 Tests** | Storage, tools, dashboard, concurrent writes, role isolation. |
33
+ ### 🧠 Your Agent Learns From Mistakes
34
+ When you correct your agent, Prism tracks it. Corrections accumulate **importance** over time. High-importance lessons auto-surface as warnings in future sessions — and can even sync to your `.cursorrules` file for permanent enforcement. Your agent literally gets smarter the more you use it.
171
35
 
172
- </details>
36
+ ### 🕰️ Time Travel
37
+ Every save creates a versioned snapshot. Made a mistake? `memory_checkout` reverts your agent's memory to any previous state — like `git revert` for your agent's brain. Full version history with optimistic concurrency control.
173
38
 
39
+ ### 🔮 Mind Palace Dashboard
40
+ A gorgeous glassmorphism UI at `localhost:3000` that lets you see exactly what your agent is thinking:
174
41
 
175
- <details>
176
- <summary><strong>What's in v2.5.1Version Sync & Embedding Safety</strong></summary>
42
+ - **Current State & TODOs** — the exact context injected into the LLM's prompt
43
+ - **Interactive Knowledge Graph** force-directed neural graph with click-to-filter, node renaming, and surgical keyword deletion *(v5.1)*
44
+ - **Deep Storage Manager** — preview and execute vector purge operations with dry-run safety *(v5.1)*
45
+ - **Session Ledger** — full audit trail of every decision your agent has made
46
+ - **Time Travel Timeline** — browse and revert any historical handoff version
47
+ - **Visual Memory Vault** — browse VLM-captioned screenshots and auto-captured HTML states
48
+ - **Hivemind Radar** — real-time active agent roster with role, task, and heartbeat
49
+ - **Morning Briefing** — AI-synthesized action plan after 4+ hours away
50
+ - **Brain Health** — memory integrity scan with one-click auto-repair
177
51
 
178
- | Feature | Description |
179
- |---|---|
180
- | 🔄 **Dynamic Versioning** | Version derived from `package.json` — MCP handshake, dashboard, and npm stay in sync. |
181
- | 🛡️ **Embedding Validation** | Validates 768-dimension vectors at runtime to catch model regressions. |
52
+ ![Mind Palace Dashboard](docs/mind-palace-dashboard.png)
182
53
 
183
- </details>
54
+ ### 🧬 10× Memory Compression
55
+ Powered by a pure TypeScript port of Google's TurboQuant (ICLR 2026), Prism compresses 768-dim embeddings from **3,072 bytes → ~400 bytes** — enabling decades of session history on a standard laptop. No native modules. No vector database required.
184
56
 
185
- <details>
186
- <summary><strong>What's in v2.5.0 Enterprise Memory 🏗️</strong></summary>
57
+ ### 🐝 Multi-Agent Hivemind
58
+ Multiple agents (dev, QA, PM) can work on the same project with **role-isolated memory**. Agents discover each other automatically, share context in real-time via Telepathy sync, and see a team roster during context loading.
187
59
 
188
- | Feature | Description |
189
- |---|---|
190
- | 🔍 **Memory Tracing** | `MemoryTrace` with latency breakdown and scoring metadata for LangSmith. |
191
- | 🛡️ **GDPR Deletion** | `session_forget_memory` with soft/hard delete and Article 17 justification. |
192
- | 🔗 **LangChain Integration** | `PrismMemoryRetriever` / `PrismKnowledgeRetriever` BaseRetriever adapters. |
193
- | 🧩 **LangGraph Agent** | 5-node research agent example with MCP bridge and hybrid search. |
60
+ ### 🖼️ Visual Memory
61
+ Save UI screenshots, architecture diagrams, and bug states to a searchable vault. Images are auto-captioned by a VLM (Claude Vision / GPT-4V / Gemini) and become semantically searchable across sessions.
194
62
 
195
- </details>
63
+ ### 🔭 Full Observability
64
+ OpenTelemetry spans for every MCP tool call, LLM hop, and background worker. Route to Jaeger, Grafana, or any OTLP collector. Configure in the dashboard — zero code changes.
196
65
 
197
- <details>
198
- <summary><strong>What's in v2.3.12 Stability & Fixes</strong></summary>
66
+ ### 🔒 GDPR Compliant
67
+ Soft/hard delete (Art. 17), full ZIP export (Art. 20), API key redaction, per-project TTL retention, and audit trail. Enterprise-ready out of the box.
199
68
 
200
- | Feature | Description |
201
- |---|---|
202
- | 🪲 **Windows Black Screen Fix** | Fixed Python `subprocess.Popen` spawning visible Node.js terminal windows on Windows. |
203
- | 📝 **Debug Logging** | Gated verbose startup logs behind `PRISM_DEBUG_LOGGING` for a cleaner default experience. |
204
- | ⚡ **Excess Loading Fixes** | Performance improvements to resolve excess loading loops. |
69
+ ---
205
70
 
206
- </details>
71
+ ## 🎯 Use Cases
207
72
 
208
- <details>
209
- <summary><strong>What's in v2.3.8 — LangGraph Research Agent</strong></summary>
73
+ **Long-running feature work** — Save state at end of day, restore full context next morning. No re-explaining.
210
74
 
211
- | Feature | Description |
212
- |---|---|
213
- | 🤖 **LangGraph Agent** | 5-node research agent with autonomous looping, MCP integration, persistent memory. |
214
- | 🧠 **Agentic Memory** | `save_session` node persists findings to ledger — agents don't just answer and forget. |
215
- | 🔌 **MCP Client Bridge** | JSON-RPC 2.0 client wraps Prism tools as LangChain `StructuredTool` objects. |
216
- | 🔧 **Storage Fix** | Resource/Prompt handlers route through `getStorage()` — eliminates EOF crashes. |
217
- | 🛡️ **Error Boundaries** | Graceful error handling with proper MCP error responses. |
75
+ **Multi-agent collaboration** Dev, QA, and PM agents share real-time context without stepping on each other's memory.
218
76
 
219
- </details>
77
+ **Consulting / multi-project** — Switch between client projects with progressive loading: `quick` (~50 tokens), `standard` (~200), or `deep` (~1000+).
220
78
 
221
- <details>
222
- <summary><strong>What's in v2.2.0</strong></summary>
79
+ **Visual debugging** — Save UI screenshots to searchable memory. Find that CSS bug from last week by description.
223
80
 
224
- | Feature | Description |
225
- |---|---|
226
- | 🩺 **Brain Health Check** | `session_health_check` — like Unix `fsck` for your agent's memory. Detects missing embeddings, duplicate entries, orphaned handoffs, and stale rollups. Use `auto_fix: true` to repair automatically. |
227
- | 📊 **Mind Palace Health** | Brain health indicator on the Mind Palace Dashboard — see your memory integrity at a glance. **🧹 Fix Issues** button auto-deletes orphaned handoffs in one click. |
81
+ **Team onboarding** New team member's agent loads the full project history instantly.
228
82
 
229
- </details>
83
+ **Behavior enforcement** — Agent corrections auto-graduate into permanent `.cursorrules` / `.clauderules` rules.
230
84
 
231
- <details>
232
- <summary><strong>What's in v2.0 "Mind Palace"</strong></summary>
233
-
234
- | Feature | Description |
235
- |---|---|
236
- | 🏠 **Local-First SQLite** | Run Prism entirely locally with zero cloud dependencies. Full vector search (libSQL F32_BLOB) and FTS5 included. |
237
- | 🔮 **Mind Palace UI** | A beautiful glassmorphism dashboard at `localhost:3000` to inspect your agent's memory, visual vault, and Git drift. |
238
- | 🕰️ **Time Travel** | `memory_history` and `memory_checkout` act like `git revert` for your agent's brain — full version history with OCC. |
239
- | 🖼️ **Visual Memory** | Agents can save screenshots to a local media vault. Auto-capture mode snapshots your local dev server on every handoff save. |
240
- | 📡 **Agent Telepathy** | Multi-client sync: if your agent in Cursor saves state, Claude Desktop gets a live notification instantly. |
241
- | 🌅 **Morning Briefing** | Gemini auto-synthesizes a 3-bullet action plan if it's been >4 hours since your last session. |
242
- | 📝 **Code Mode Templates** | 8 pre-built QuickJS extraction templates for GitHub, Jira, OpenAPI, Slack, CSV, and DOM parsing — zero reasoning tokens. |
243
- | 🔍 **Reality Drift Detection** | Prism captures Git state on save and warns if files changed outside the agent's view. |
85
+ **Offline / air-gapped** — Full SQLite local mode + Ollama LLM adapter. Zero internet dependency.
244
86
 
245
- </details>
87
+ **Morning Briefings** — After 4+ hours away, Prism auto-synthesizes a 3-bullet action plan from your last sessions.
246
88
 
247
89
  ---
248
90
 
249
- > 💡 **TL;DR:** Prism MCP gives your AI agent persistent memory using a local SQLite database. No cloud accounts, no API keys, and no Postgres/Qdrant containers required. Just `npx -y prism-mcp-server` and you're running.
91
+ ## 🆕 What's New in v5.2
250
92
 
251
- ## How Prism Compares
93
+ - 🧠 **Cognitive Memory** — Ebbinghaus importance decay computes `effective_importance = base × 0.95^days` at retrieval time. Frequently accessed memories stay prominent; neglected ones naturally fade. Tracks `last_accessed_at` per entry.
94
+ - 🎯 **Context-Weighted Retrieval** — New `context_boost` parameter on `session_search_memory` prepends your active project's context to the query before embedding, biasing results toward what matters right now.
95
+ - 🔄 **Universal History Migration** — Import years of Claude Code, Gemini, and ChatGPT sessions on day one. Strategy Pattern adapters with OOM-safe streaming, content-hash dedup, and `--dry-run` support.
96
+ - 🧹 **Smart Consolidation** — Enhanced compaction extracts recurring principles alongside summaries for richer rollups.
97
+ - 🛡️ **SQL Injection Prevention** — 17-column allowlist on `patchLedger()` hardens all dynamic SQL paths.
98
+ - 🧪 **352 Tests** — Zero regressions across 15 suites.
252
99
 
253
- | Feature | **Prism MCP** | [MCP Memory](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) | [Mem0](https://github.com/mem0ai/mem0) | [Mnemory](https://github.com/fpytloun/mnemory) | [Basic Memory](https://github.com/basicmachines-co/basic-memory) |
254
- |---|---|---|---|---|---|
255
- | **Pricing** | ✅ Free / MIT | ✅ Free / MIT | Freemium | ✅ Free / OSS | Freemium |
256
- | **Storage** | SQLite + Supabase | JSON file | Postgres + Qdrant | Qdrant + S3 | Markdown files |
257
- | **Zero Config** | ✅ npx one-liner | ✅ | ❌ Qdrant/Postgres | ✅ uvx | ✅ pip |
258
- | **Behavioral Memory** | ✅ Importance tracking | ❌ | ❌ | ❌ | ❌ |
259
- | **Dynamic Roles** | ✅ Dashboard auto-resolve | ❌ | ❌ | ❌ | ❌ |
260
- | **Token Budget** | ✅ max_tokens param | ❌ | ❌ | ❌ | ❌ |
261
- | **Importance Decay** | ✅ Auto-fade stale data | ❌ | ❌ | ❌ | ❌ |
262
- | **Semantic Search** | ✅ Vectors + FTS5 | ❌ | ✅ pgvector | ✅ Qdrant | ❌ Text only |
263
- | **Knowledge Graph** | ✅ Neural Graph | ✅ Entity model | ❌ | ✅ Graph | ✅ MD links |
264
- | **Time Travel** | ✅ History + checkout | ❌ | ❌ | ❌ | ❌ |
265
- | **Fact Merging** | ✅ Gemini async | ❌ | ✅ Built-in | ✅ Contradiction | ❌ |
266
- | **Security Scan** | ✅ Injection detection | ❌ | ❌ | ✅ Anti-injection | ❌ |
267
- | **Health Check** | ✅ fsck tool | ❌ | ❌ | ✅ 3-phase fsck | ❌ |
268
- | **Visual Dashboard** | ✅ Mind Palace | ❌ | ✅ Cloud UI | ✅ Mgmt UI | ❌ |
269
- | **Multi-Agent Sync** | ✅ Real-time | ❌ | ❌ | ❌ Per-user | ❌ |
270
- | **Visual Memory** | ✅ Screenshot vault | ❌ | ❌ | ✅ Artifacts | ❌ |
271
- | **Auto-Compaction** | ✅ Gemini rollups | ❌ | ❌ | ❌ | ❌ |
272
- | **Morning Briefing** | ✅ Gemini synthesis | ❌ | ❌ | ❌ | ❌ |
273
- | **OCC (Concurrency)** | ✅ Version-based | ❌ | ❌ | ❌ | ❌ |
274
- | **GDPR Compliance** | ✅ Soft/hard delete + ZIP export | ❌ | ❌ | ❌ | ❌ |
275
- | **Memory Tracing** | ✅ Latency breakdown | ❌ | ❌ | ❌ | ❌ |
276
- | **OpenTelemetry** | ✅ OTLP spans (v4.6) | ❌ | ❌ | ❌ | ❌ |
277
- | **VLM Image Captions** | ✅ Auto-caption vault (v4.5) | ❌ | ❌ | ❌ | ❌ |
278
- | **Pluggable LLM Adapters** | ✅ OpenAI/Anthropic/Gemini/Ollama | ❌ | ✅ Multi-provider | ❌ | ❌ |
279
- | **LangChain** | ✅ BaseRetriever | ❌ | ❌ | ❌ | ❌ |
280
- | **MCP Native** | ✅ stdio | ✅ stdio | ❌ Python SDK | ✅ HTTP + MCP | ✅ stdio |
281
- | **Language** | TypeScript | TypeScript | Python | Python | Python |
282
-
283
- > **When to choose Prism MCP:** You want MCP-native memory with zero infrastructure overhead, progressive context loading, and enterprise features (OCC, compaction, time travel, security scanning) that work directly in Claude Desktop — without running Qdrant, Postgres, or cloud services.
100
+ > [Full CHANGELOG ](CHANGELOG.md)
284
101
 
285
102
  ---
286
103
 
287
- ## Quick Start (Zero Config — Local Mode)
288
-
289
- Get the MCP server running with Claude Desktop or Cursor in **under 60 seconds**. No API keys required for basic local memory!
290
-
291
- ### Option A: npx (Fastest)
104
+ ## 🚀 Quick Start
292
105
 
293
- Add this to your `claude_desktop_config.json` or `.cursor/mcp.json`:
106
+ Add to your MCP client config (`claude_desktop_config.json`, `.cursor/mcp.json`, etc.):
294
107
 
295
108
  ```json
296
109
  {
@@ -303,100 +116,25 @@ Add this to your `claude_desktop_config.json` or `.cursor/mcp.json`:
303
116
  }
304
117
  ```
305
118
 
306
- That's it **zero env vars needed** for local memory, Mind Palace dashboard, Time Travel, and Telepathy.
119
+ **That's it.** Restart your client. All 30+ tools are available. Dashboard at `http://localhost:3000`.
307
120
 
308
- > **Optional API keys:** Add `BRAVE_API_KEY` for web search, `GOOGLE_API_KEY` for semantic search + Morning Briefings + paper analysis. See [Environment Variables](#environment-variables) for the full list.
309
-
310
- ### Option B: Cloud Sync Mode (Supabase)
311
-
312
- To share memory across multiple machines or teams, switch to Supabase:
313
-
314
- ```json
315
- {
316
- "mcpServers": {
317
- "prism-mcp": {
318
- "command": "npx",
319
- "args": ["-y", "prism-mcp-server"],
320
- "env": {
321
- "PRISM_STORAGE": "supabase",
322
- "SUPABASE_URL": "https://your-project.supabase.co",
323
- "SUPABASE_KEY": "your-supabase-anon-key"
324
- }
325
- }
326
- }
327
- }
328
- ```
329
-
330
- ### Option C: Clone & Build (Full Control)
331
-
332
- ```bash
333
- git clone https://github.com/dcostenco/prism-mcp.git
334
- cd prism-mcp
335
- npm install
336
- npm run build
337
- ```
338
-
339
- Then add to your MCP config:
340
-
341
- ```json
342
- {
343
- "mcpServers": {
344
- "prism-mcp": {
345
- "command": "node",
346
- "args": ["/absolute/path/to/prism-mcp/dist/server.js"],
347
- "env": {
348
- "BRAVE_API_KEY": "your-brave-api-key",
349
- "GOOGLE_API_KEY": "your-google-gemini-key"
350
- }
351
- }
352
- }
353
- }
354
- ```
355
-
356
- **Restart your MCP client. That's it — all tools are now available.**
357
-
358
- ---
359
-
360
- ## 🔮 The Mind Palace Dashboard
361
-
362
- Prism MCP spins up a lightweight, zero-dependency HTTP server alongside the MCP stdio process. No frameworks, no build step — just pure glassmorphism CSS served as a template literal.
363
-
364
- Open **`http://localhost:3000`** in your browser to see exactly what your AI agent is thinking:
365
-
366
- ![Mind Palace Dashboard](docs/mind-palace-dashboard.png)
367
-
368
- - **Current State & TODOs** — See the exact context injected into the LLM's prompt
369
- - **Agent Identity Chip** — Header shows your active role + name (e.g. `🛠️ dev · Antigravity`); click to open Settings
370
- - **Project Repo Paths** — Map each project to its repo directory for save validation
371
- - **Brain Health 🩺** — Memory integrity status at a glance; **🧹 Fix Issues** button auto-cleans orphaned handoffs in one click
372
- - **Git Drift Detection** — Alerts you if you've modified code outside the agent's view
373
- - **Morning Briefing** — AI-synthesized action plan from your last sessions
374
- - **Time Travel Timeline** — Browse historical handoff states and revert any version
375
- - **Visual Memory Vault** — Browse UI screenshots and auto-captured HTML states
376
- - **Session Ledger** — Full audit trail of every decision your agent has made
377
- - **Neural Graph** — Force-directed visualization of project ↔ keyword associations
378
- - **Hivemind Radar** — Real-time active agent roster with role, task, and heartbeat
379
-
380
- The dashboard auto-discovers all your projects and updates in real time.
121
+ > **Optional API keys:** `GOOGLE_API_KEY` for semantic search + Morning Briefings, `BRAVE_API_KEY` for web search. See [Environment Variables](#environment-variables).
381
122
 
382
123
  ---
383
124
 
384
- ## Integration Examples
385
-
386
- Copy-paste configs for popular MCP clients. All configs use the `npx` method.
125
+ ## 📖 Setup Guides
387
126
 
388
127
  <details>
389
128
  <summary><strong>Claude Desktop</strong></summary>
390
129
 
391
- Add to your `claude_desktop_config.json`:
130
+ Add to `claude_desktop_config.json`:
392
131
 
393
132
  ```json
394
133
  {
395
134
  "mcpServers": {
396
135
  "prism-mcp": {
397
136
  "command": "npx",
398
- "args": ["-y", "prism-mcp-server"],
399
- "env": {}
137
+ "args": ["-y", "prism-mcp-server"]
400
138
  }
401
139
  }
402
140
  }
@@ -407,15 +145,14 @@ Add to your `claude_desktop_config.json`:
407
145
  <details>
408
146
  <summary><strong>Cursor</strong></summary>
409
147
 
410
- Add to `.cursor/mcp.json` in your project root (or `~/.cursor/mcp.json` for global):
148
+ Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
411
149
 
412
150
  ```json
413
151
  {
414
152
  "mcpServers": {
415
153
  "prism-mcp": {
416
154
  "command": "npx",
417
- "args": ["-y", "prism-mcp-server"],
418
- "env": {}
155
+ "args": ["-y", "prism-mcp-server"]
419
156
  }
420
157
  }
421
158
  }
@@ -433,8 +170,7 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
433
170
  "mcpServers": {
434
171
  "prism-mcp": {
435
172
  "command": "npx",
436
- "args": ["-y", "prism-mcp-server"],
437
- "env": {}
173
+ "args": ["-y", "prism-mcp-server"]
438
174
  }
439
175
  }
440
176
  }
@@ -464,15 +200,63 @@ Add to your Continue `config.json` or Cline MCP settings:
464
200
 
465
201
  </details>
466
202
 
467
- ---
203
+ <details>
204
+ <summary><strong>Migrating Existing History (Claude, Gemini, OpenAI)</strong></summary>
205
+
206
+ Prism can ingest months of historical sessions from other tools to give your Mind Palace a massive head start.
207
+
208
+ ### Supported Formats
209
+ * **Claude Code** (`.jsonl` logs) — Automatically handles streaming chunk deduplication and `requestId` normalization.
210
+ * **Gemini** (JSON history arrays) — Supports large-file streaming for 100MB+ exports.
211
+ * **OpenAI** (JSON chat completion history) — Normalizes disparate tool-call structures into the unified Ledger schema.
212
+
213
+ ### How to Run
214
+ Use the `universal-import` command:
215
+
216
+ ```bash
217
+ # Ingest Claude Code history
218
+ npx -y prism-mcp-server universal-import --format claude --path ~/path/to/claude_log.jsonl --project my-project
219
+
220
+ # Dry run (verify mapping without saving)
221
+ npx -y prism-mcp-server universal-import --format gemini --path ./gemini_history.json --dry-run
222
+ ```
223
+
224
+ ### Key Features
225
+ * **OOM-Safe Streaming:** Processes massive log files line-by-line using `stream-json`.
226
+ * **Chronological Integrity:** Uses timestamp fallbacks and `requestId` sorting to ensure your memory timeline is accurate.
227
+ * **Smart Context Mapping:** Extracts `cwd`, `gitBranch`, and tool usage patterns into searchable metadata.
468
228
 
469
- ## Claude Code Integration (Hooks)
229
+ </details>
230
+
231
+ <details>
232
+ <summary><strong>Claude Code — Lifecycle Hooks (Auto-Load & Auto-Save)</strong></summary>
233
+
234
+ Claude Code supports `SessionStart` and `Stop` hooks that force the agent to load/save Prism context automatically.
235
+
236
+ ### 1. Create the Hook Script
237
+
238
+ Save as `~/.claude/mcp_autoload_hook.py`:
239
+
240
+ ```python
241
+ #!/usr/bin/env python3
242
+ import json, sys
470
243
 
471
- Claude Code supports **lifecycle hooks** in `~/.claude/settings.json` that fire automatically at session start and end. Use these to auto-hydrate and persist Prism memory without manual prompting.
244
+ def main():
245
+ print(json.dumps({
246
+ "continue": True,
247
+ "suppressOutput": True,
248
+ "systemMessage": (
249
+ "## First Action\n"
250
+ "Call `mcp__prism-mcp__session_load_context(project='my-project', level='deep')` "
251
+ "before responding to the user. Do not generate any text before calling this tool."
252
+ )
253
+ }))
472
254
 
473
- ### SessionStart Hook
255
+ if __name__ == "__main__":
256
+ main()
257
+ ```
474
258
 
475
- Automatically loads context when a new session begins:
259
+ ### 2. Configure `settings.json`
476
260
 
477
261
  ```json
478
262
  {
@@ -483,1137 +267,455 @@ Automatically loads context when a new session begins:
483
267
  "hooks": [
484
268
  {
485
269
  "type": "command",
486
- "command": "python3 -c \"import json; print(json.dumps({'continue': True, 'suppressOutput': False, 'systemMessage': 'You MUST call mcp__prism-mcp__session_load_context twice before responding to the user: first with project=my-project level=standard, then with project=my-other-project level=standard. Do not skip this.'}))\"",
270
+ "command": "python3 /Users/you/.claude/mcp_autoload_hook.py",
487
271
  "timeout": 10
488
272
  }
489
273
  ]
490
274
  }
491
- ]
492
- }
493
- }
494
- ```
495
-
496
- ### Stop Hook
497
-
498
- Automatically saves session memory when a session ends:
499
-
500
- ```json
501
- {
502
- "hooks": {
275
+ ],
503
276
  "Stop": [
504
277
  {
505
278
  "matcher": "*",
506
279
  "hooks": [
507
280
  {
508
281
  "type": "command",
509
- "command": "python3 -c \"import json; print(json.dumps({'continue': True, 'suppressOutput': False, 'systemMessage': 'MANDATORY END WORKFLOW: 1) Call mcp__prism-mcp__session_save_ledger with project and summary. 2) Call mcp__prism-mcp__session_save_handoff with expected_version set to the loaded version.'}))\"",
510
- "timeout": 10
282
+ "command": "python3 -c \"import json; print(json.dumps({'continue': True, 'suppressOutput': True, 'systemMessage': 'MANDATORY END WORKFLOW: 1) Call mcp__prism-mcp__session_save_ledger with project and summary. 2) Call mcp__prism-mcp__session_save_handoff with expected_version set to the loaded version.'}))\""
511
283
  }
512
284
  ]
513
285
  }
514
286
  ]
287
+ },
288
+ "permissions": {
289
+ "allow": [
290
+ "mcp__prism-mcp__session_load_context",
291
+ "mcp__prism-mcp__session_save_ledger",
292
+ "mcp__prism-mcp__session_save_handoff",
293
+ "mcp__prism-mcp__knowledge_search",
294
+ "mcp__prism-mcp__session_search_memory"
295
+ ]
515
296
  }
516
297
  }
517
298
  ```
518
299
 
519
- ### How the Hooks Work
520
-
521
- The hook `command` runs a Python one-liner that returns a JSON object to Claude Code:
522
-
523
- | Field | Purpose |
524
- |---|---|
525
- | `continue: true` | Tell Claude Code to proceed (don't abort the session) |
526
- | `suppressOutput: false` | Show the hook result to the agent |
527
- | `systemMessage` | Instruction injected as a system message — the agent follows it |
528
-
529
- The agent receives the `systemMessage` as an instruction and executes the tool calls. The server resolves the agent's **role** and **name** automatically from the dashboard — no need to specify them in the hook.
530
-
531
- ### Role Resolution — No Hardcoding Needed
532
-
533
- Prism resolves the agent role dynamically using a priority chain:
534
-
535
- ```
536
- explicit tool argument → dashboard setting → "global" (default)
537
- ```
538
-
539
- 1. **Explicit arg wins** — if `role` is passed in the tool call, it's used directly.
540
- 2. **Dashboard fallback** — if `role` is omitted, the server calls `getSetting("default_role")` and uses whatever role you configured in the **Mind Palace Dashboard ⚙️ Settings → Agent Identity**.
541
- 3. **Final default** — if no dashboard setting exists, falls back to `"global"`.
300
+ ### Troubleshooting
542
301
 
543
- Change your role once in the dashboard, and it automatically applies to every session — CLI, extension, and all MCP clients.
302
+ - **Hook not firing?** Check `timeout` if your script takes too long, Claude ignores it.
303
+ - **"Tool not available"?** This is a hallucination. Ensure `permissions.allow` exactly matches the double-underscore format.
544
304
 
545
- ### Verification
305
+ </details>
546
306
 
547
- If hydration ran successfully, the agent's output will include:
548
- - A `[👤 AGENT IDENTITY]` block showing your dashboard-configured role and name
549
- - `PRISM_CONTEXT_LOADED` marker text
307
+ <details>
308
+ <summary><strong>Gemini / Antigravity Auto-Load Rules (Battle-Tested)</strong></summary>
550
309
 
551
- If the marker is missing, the hook did not fire or the MCP server is not connected.
310
+ Gemini-based agents (including Google's Antigravity IDE) require a fundamentally different approach to auto-load. This guide was refined over **14 iterations** of real-world prompt engineering.
552
311
 
553
- ---
312
+ ### The Core Problem
554
313
 
555
- ## Gemini / Antigravity Integration
314
+ When given verbose instructions with many constraints, Gemini models hallucinate that MCP tools "don't exist" or "aren't available" — even when they are. This is adversarial reasoning triggered by long rule lists, not a configuration issue.
556
315
 
557
- Gemini-based clients (like Antigravity) use `GEMINI.md` global rules or user rules for startup behavior. The server resolves the role from the dashboard automatically.
316
+ ### The 2-Line Rule (Proven Fix)
558
317
 
559
- ### Global Rules (`~/.gemini/GEMINI.md`)
318
+ Create `~/.gemini/GEMINI.md`:
560
319
 
561
320
  ```markdown
562
- ## Prism MCP Memory Auto-Load (CRITICAL)
563
- At the start of every new session, call `mcp__prism-mcp__session_load_context`
564
- for these projects:
565
- - `my-project` (level=standard)
566
- - `my-other-project` (level=standard)
567
-
568
- After both succeed, print PRISM_CONTEXT_LOADED.
321
+ ## First Action
322
+ Call `mcp_prism-mcp_session_load_context(project="my-project", level="deep")` before responding.
569
323
  ```
570
324
 
571
- ### User Rules (Antigravity Settings)
572
-
573
- If your Gemini client supports user rules, add the same instructions there. The key points:
325
+ **Why this works:**
326
+ - Gemini uses **single underscores** for MCP tools (`mcp_prism-mcp_...`) vs Claude's **double underscores** (`mcp__prism-mcp__...`)
327
+ - Keeping the instruction to 2 lines avoids triggering the model's adversarial "tool not found" reasoning
328
+ - Framing as a positive "First Action" directive outperforms negative constraint lists
574
329
 
575
- 1. **Call `session_load_context` as a tool** — not `read_resource`. Only the tool returns the `[👤 AGENT IDENTITY]` block.
576
- 2. **Verify** — confirm the response includes `version` and `last_summary`.
330
+ ### Antigravity UI Caveat
577
331
 
578
- ### Session End
579
-
580
- At the end of each session, save state:
332
+ Antigravity **does not visually render MCP tool output blocks** in the chat UI. The tool executes successfully, but the user sees nothing. Fix this by adding an echo rule:
581
333
 
582
334
  ```markdown
583
- ## Session End Protocol
584
- 1) Call `mcp__prism-mcp__session_save_ledger` with project and summary.
585
- 2) Call `mcp__prism-mcp__session_save_handoff` with expected_version from the loaded version.
335
+ ## Echo Context
336
+ After loading context, include in your text reply:
337
+ - Agent identity (role + name)
338
+ - Last session summary
339
+ - Open TODOs
340
+ - Session version number
586
341
  ```
587
342
 
588
- ---
589
-
590
- ## Use Cases
591
-
592
- | Scenario | How Prism MCP Helps | Live Sample |
593
- |----------|---------------------|-------------|
594
- | **Long-running feature work** | Save session state at end of day, restore full context next morning — no re-explaining | `session_save_handoff(project, last_summary, open_todos)` |
595
- | **Multi-agent collaboration** | Hivemind Telepathy lets multiple agents share real-time context across clients | `session_load_context(project, role="qa")` |
596
- | **Consulting / multi-project** | Switch between client projects with progressive context loading | `session_load_context(project, level="quick")` |
597
- | **Research & analysis** | Multi-engine search with 94% context reduction via sandboxed code transforms | `brave_web_search` + `code_mode_transform(template="api_endpoints")` |
598
- | **Team onboarding** | New team member's agent loads full project history instantly | `session_load_context(project, level="deep")` |
599
- | **Visual debugging** | Save UI screenshots to visual memory — searchable by description | `session_save_image(project, path, description)` → `session_view_image(id)` |
600
- | **Offline / air-gapped** | Full SQLite local mode, Ollama LLM adapter — zero internet dependency | `PRISM_LLM_PROVIDER=ollama` in MCP config env |
601
- | **Behavior enforcement** | Agent corrections auto-graduate into permanent `.cursorrules` | `session_save_experience(event_type="correction")` → `knowledge_sync_rules(project)` |
602
- | **Infrastructure observability** | OTel spans to Jaeger/Grafana for every MCP tool call fanout | Enable in Dashboard → Settings → 🔭 Observability |
603
- | **GDPR / audit export** | ZIP export of all memory as JSON + Markdown, sensitive fields redacted | `session_export_memory(project, format="zip")` |
343
+ This ensures the user sees their project context even though the raw MCP output is invisible.
604
344
 
605
- ---
345
+ ### Session End Workflow
606
346
 
607
- ## New in v4.6.0 Feature Setup Guide
347
+ Tell the agent: *"Wrap up the session."* It should execute:
608
348
 
609
- ### 🔭 OpenTelemetry Distributed Tracing
349
+ 1. `session_save_ledger` append immutable work log (summary, decisions, files changed)
350
+ 2. `session_save_handoff` — upsert project state with `expected_version` for OCC
610
351
 
611
- **Why:** Every `session_save_ledger` call can silently fan out into a synchronous DB write, an async VLM caption, and a vector embedding backfill. Without tracing, these are invisible. OTel makes the full call tree visible in Jaeger, Grafana Tempo, or any OTLP-compatible collector.
352
+ > **Tip:** Include the session-end instructions in your `GEMINI.md` or ask the agent to save when you're done.
612
353
 
613
- **Setup:**
614
- 1. Open Mind Palace Dashboard → ⚙️ Settings → 🔭 Observability
615
- 2. Toggle **Enable OpenTelemetry** → set your OTLP endpoint (default: `http://localhost:4318`)
616
- 3. Restart the MCP server
617
- 4. Run Jaeger locally:
618
- ```bash
619
- docker run -d --name jaeger \
620
- -p 16686:16686 -p 4318:4318 \
621
- jaegertracing/all-in-one:latest
622
- ```
623
- 5. Open http://localhost:16686 — select service `prism-mcp` to see span waterfalls.
354
+ ### Key Findings from 14 Iterations
624
355
 
625
- **Span hierarchy:**
626
- ```
627
- mcp.call_tool [session_save_ledger]
628
- ├── storage.write_ledger ~2ms
629
- ├── llm.generate_embedding ~180ms
630
- └── worker.vlm_caption (async) ~1.2s
631
- ```
356
+ | Iteration | What We Tried | Result |
357
+ |-----------|---------------|--------|
358
+ | 1–6 | Verbose "Banned Behaviors" blocks, negative constraints | ❌ Model hallucinated tools were unavailable |
359
+ | 7–9 | `always_on` trigger rules, multi-file configs | ❌ Redundant configs caused race conditions |
360
+ | 10–11 | Emergency-style `🚨 MANDATORY` headers | ⚠️ Inconsistent — worked sometimes |
361
+ | 12–13 | Positive-only framing, progressively shorter | ⚠️ Better but still intermittent |
362
+ | 14 | **2-line "First Action" directive** | ✅ Reliable across sessions |
632
363
 
633
- > GDPR note: Span attributes contain only metadata — no prompt content, embeddings, or image data.
364
+ ### Platform Gotchas
634
365
 
635
- ---
366
+ - **`replace_file_content` silently fails** on `~/.gemini/GEMINI.md` in some environments — use `write_to_file` with overwrite instead
367
+ - **Multiple GEMINI.md locations** can conflict: global (`~/.gemini/`), workspace, and User Rules in the Antigravity UI. Keep them synchronized
368
+ - **Camoufox/browser tools** called at startup spawn visible black windows — never call browser tools during greeting handlers
636
369
 
637
- ### 🖼️ VLM Multimodal Memory
370
+ </details>
638
371
 
639
- **Why:** Agents lose visual context between sessions. UI screenshots, architecture diagrams, and bug states all become searchable memory.
372
+ <details>
373
+ <summary><strong>Supabase Cloud Sync</strong></summary>
640
374
 
641
- **Setup:** Requires `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` (vision-capable model).
375
+ To sync memory across machines or teams:
642
376
 
643
- **Usage:**
644
- ```
645
- session_save_image(project="my-app", file_path="/path/to/screenshot.png", description="Login page broken layout after CSS refactor")
646
- ```
647
- The image is auto-captioned by a VLM and stored in the media vault. Retrieve later:
648
- ```
649
- session_view_image(project="my-app", image_id="8f2a1b3c")
377
+ ```json
378
+ {
379
+ "mcpServers": {
380
+ "prism-mcp": {
381
+ "command": "npx",
382
+ "args": ["-y", "prism-mcp-server"],
383
+ "env": {
384
+ "PRISM_STORAGE": "supabase",
385
+ "SUPABASE_URL": "https://your-project.supabase.co",
386
+ "SUPABASE_KEY": "your-supabase-anon-key"
387
+ }
388
+ }
389
+ }
390
+ }
650
391
  ```
651
392
 
652
- ---
393
+ See the **Supabase Setup** section below for schema migration instructions.
394
+
395
+ </details>
653
396
 
654
- ### 🔌 Pluggable LLM Adapters
397
+ <details>
398
+ <summary><strong>Clone & Build (Full Control)</strong></summary>
655
399
 
656
- **Why:** Run fully local/air-gapped with Ollama, or switch providers without changing tool logic.
400
+ ```bash
401
+ git clone https://github.com/dcostenco/prism-mcp.git
402
+ cd prism-mcp && npm install && npm run build
403
+ ```
657
404
 
658
- **Setup:** Set in MCP config `env`:
405
+ Then add to your MCP config:
659
406
 
660
407
  ```json
661
408
  {
662
- "env": {
663
- "PRISM_LLM_PROVIDER": "ollama",
664
- "PRISM_LLM_MODEL": "llama3.2",
665
- "PRISM_LLM_BASE_URL": "http://localhost:11434"
409
+ "mcpServers": {
410
+ "prism-mcp": {
411
+ "command": "node",
412
+ "args": ["/path/to/prism-mcp/dist/server.js"],
413
+ "env": {
414
+ "BRAVE_API_KEY": "your-key",
415
+ "GOOGLE_API_KEY": "your-gemini-key"
416
+ }
417
+ }
666
418
  }
667
419
  }
668
420
  ```
669
421
 
670
- | Provider | Env Var | Notes |
671
- |----------|---------|-------|
672
- | `gemini` (default) | `GOOGLE_API_KEY` | Best for Morning Briefings |
673
- | `openai` | `OPENAI_API_KEY` | GPT-4o supports VLM |
674
- | `anthropic` | `ANTHROPIC_API_KEY` | Claude 3.5 supports VLM |
675
- | `ollama` | none | Full local/air-gapped mode |
422
+ </details>
676
423
 
677
424
  ---
678
425
 
679
- ### 📦 GDPR Memory Export
680
-
681
- ```
682
- session_export_memory(project="my-app", format="zip")
683
- ```
684
-
685
- Outputs a ZIP containing:
686
- - `ledger.json` — all session entries
687
- - `handoffs.json` — all project state snapshots
688
- - `knowledge.md` — graduated insights in Markdown
689
- - Sensitive fields (API keys, tokens) automatically redacted
426
+ ## How Prism Compares
690
427
 
691
- ---
428
+ **Prism MCP** vs [MCP Memory](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) · [Mem0](https://github.com/mem0ai/mem0) · [Mnemory](https://github.com/fpytloun/mnemory) · [Basic Memory](https://github.com/basicmachines-co/basic-memory)
692
429
 
693
- ## Architecture
430
+ **Only Prism has all of these:**
431
+ - ✅ Zero config — one `npx` command, no Qdrant/Postgres containers
432
+ - ✅ Time Travel — versioned snapshots with `memory_checkout`
433
+ - ✅ Behavioral memory — importance tracking, auto-decay, mistake learning
434
+ - ✅ Visual dashboard — Mind Palace at localhost:3000
435
+ - ✅ Multi-agent sync — role-isolated Hivemind with real-time Telepathy
436
+ - ✅ Visual memory — VLM-captioned screenshot vault
437
+ - ✅ Token budgeting — `max_tokens` param on context loading
438
+ - ✅ 10× vector compression — TurboQuant, no external vector DB
439
+ - ✅ GDPR compliance — soft/hard delete, ZIP export, TTL retention
440
+ - ✅ OpenTelemetry — full span tracing to Jaeger/Grafana
441
+ - ✅ LangChain adapters — `BaseRetriever` integration + LangGraph examples
442
+ - ✅ Morning Briefings — AI-synthesized action plans after breaks
443
+ - ✅ Auto-compaction — Gemini-powered rollups to prevent unbounded growth
444
+ - ✅ IDE rules sync — graduated insights → `.cursorrules` / `.clauderules`
445
+ - ✅ Air-gapped mode — SQLite + Ollama, zero internet needed
694
446
 
695
- ```mermaid
696
- graph TB
697
- Client["AI Client<br/>(Claude Desktop / Cursor / Windsurf)"]
698
- LangChain["LangChain / LangGraph<br/>(Python Retrievers)"]
699
- MCP["Prism MCP Server<br/>(TypeScript)"]
700
-
701
- Client -- "MCP Protocol (stdio)" --> MCP
702
- LangChain -- "JSON-RPC via MCP Bridge" --> MCP
703
-
704
- MCP --> Tracing["MemoryTrace Engine<br/>Latency + Strategy + Scoring"]
705
- MCP --> Dashboard["Mind Palace Dashboard<br/>localhost:3000"]
706
- MCP --> Brave["Brave Search API<br/>Web + Local + AI Answers"]
707
- MCP --> Gemini["Google Gemini API<br/>Analysis + Briefings"]
708
- MCP --> Sandbox["QuickJS Sandbox<br/>Code-Mode Templates"]
709
- MCP --> SyncBus["SyncBus<br/>Agent Telepathy"]
710
- MCP --> GDPR["GDPR Engine<br/>Soft/Hard Delete + Audit"]
711
-
712
- MCP --> Storage{"Storage Backend"}
713
- Storage --> SQLite["SQLite (Local)<br/>libSQL + F32_BLOB vectors"]
714
- Storage --> Supabase["Supabase (Cloud)<br/>PostgreSQL + pgvector"]
715
-
716
- SQLite --> Ledger["session_ledger<br/>(+ deleted_at tombstoning)"]
717
- SQLite --> Handoffs["session_handoffs"]
718
- SQLite --> History["history_snapshots<br/>(Time Travel)"]
719
- SQLite --> Media["media vault<br/>(Visual Memory)"]
720
-
721
- style Client fill:#4A90D9,color:#fff
722
- style LangChain fill:#1C3D5A,color:#fff
723
- style MCP fill:#2D3748,color:#fff
724
- style Tracing fill:#D69E2E,color:#fff
725
- style Dashboard fill:#9F7AEA,color:#fff
726
- style Brave fill:#FB542B,color:#fff
727
- style Gemini fill:#4285F4,color:#fff
728
- style Sandbox fill:#805AD5,color:#fff
729
- style SyncBus fill:#ED64A6,color:#fff
730
- style GDPR fill:#E53E3E,color:#fff
731
- style Storage fill:#2D3748,color:#fff
732
- style SQLite fill:#38B2AC,color:#fff
733
- style Supabase fill:#3ECF8E,color:#fff
734
- ```
447
+ > **TL;DR:** Prism is the only MCP memory server with time travel, behavioral learning, visual memory, multi-agent sync, and 10× compression — all from a single `npx` command.
735
448
 
736
449
  ---
737
450
 
738
- ## Tool Reference
739
-
740
- ### Search & Analysis Tools
741
-
742
- | Tool | Purpose |
743
- |------|---------|
744
- | `brave_web_search` | Real-time internet search |
745
- | `brave_local_search` | Location-based POI discovery |
746
- | `brave_web_search_code_mode` | JS extraction over web search results |
747
- | `brave_local_search_code_mode` | JS extraction over local search results |
748
- | `code_mode_transform` | Universal post-processing with **8 built-in templates** |
749
- | `gemini_research_paper_analysis` | Academic paper analysis via Gemini |
750
- | `brave_answers` | AI-grounded answers from Brave |
451
+ ## 🔧 Tool Reference
751
452
 
752
- ### Session Memory & Knowledge Tools
453
+ <details>
454
+ <summary><strong>Session Memory & Knowledge (12 tools)</strong></summary>
753
455
 
754
456
  | Tool | Purpose |
755
457
  |------|---------|
756
458
  | `session_save_ledger` | Append immutable session log (summary, TODOs, decisions) |
757
459
  | `session_save_handoff` | Upsert latest project state with OCC version tracking |
758
460
  | `session_load_context` | Progressive context loading (quick / standard / deep) |
759
- | `knowledge_search` | Semantic search across accumulated knowledge |
461
+ | `knowledge_search` | Full-text keyword search across accumulated knowledge |
760
462
  | `knowledge_forget` | Prune outdated or incorrect memories (4 modes + dry_run) |
463
+ | `knowledge_set_retention` | Set per-project TTL retention policy |
761
464
  | `session_search_memory` | Vector similarity search across all sessions |
762
- | `session_compact_ledger` | Auto-compact old ledger entries via Gemini-powered summarization |
465
+ | `session_compact_ledger` | Auto-compact old entries via Gemini summarization |
466
+ | `session_forget_memory` | GDPR-compliant deletion (soft/hard + Art. 17 reason) |
467
+ | `session_export_memory` | Full ZIP export (JSON + Markdown) for portability |
468
+ | `session_health_check` | Brain integrity scan + auto-repair (`fsck`) |
469
+ | `deep_storage_purge` | Reclaim ~90% vector storage (v5.1) |
470
+
471
+ </details>
763
472
 
764
- ### v3.1 Lifecycle Tools
473
+ <details>
474
+ <summary><strong>Behavioral Memory & Knowledge Graph (5 tools)</strong></summary>
765
475
 
766
476
  | Tool | Purpose |
767
477
  |------|---------|
768
- | `knowledge_set_retention` | Set a per-project TTL retention policy (0 = disabled, min 7 days). Immediately expires overdue entries. |
478
+ | `session_save_experience` | Record corrections, successes, failures, learnings |
479
+ | `knowledge_upvote` | Increase entry importance (+1) |
480
+ | `knowledge_downvote` | Decrease entry importance (-1) |
481
+ | `knowledge_sync_rules` | Sync graduated insights to `.cursorrules` / `.clauderules` |
482
+ | `session_save_image` / `session_view_image` | Visual memory vault |
483
+
484
+ </details>
769
485
 
770
- ### v2.0 Advanced Memory Tools
486
+ <details>
487
+ <summary><strong>Time Travel & History (2 tools)</strong></summary>
771
488
 
772
489
  | Tool | Purpose |
773
490
  |------|---------|
774
491
  | `memory_history` | Browse all historical versions of a project's handoff state |
775
- | `memory_checkout` | Revert to any previous version (non-destructive, like `git revert`) |
776
- | `session_save_image` | Save a screenshot/image to the visual memory vault |
777
- | `session_view_image` | Retrieve and display a saved image from the vault |
778
-
779
- ### v2.2 Brain Health Tools
780
-
781
- | Tool | Purpose | Key Args | Returns |
782
- |------|---------|----------|---------|
783
- | `session_health_check` | Scan brain for integrity issues (`fsck`) | `project`, `auto_fix` (boolean) | Health report & auto-repairs |
784
-
785
- The **Mind Palace Dashboard** also shows a live **Brain Health 🩺** card for every project:
786
-
787
- - **Status indicator** — `✅ Healthy` or `⚠️ Issues detected` with entry/handoff/rollup counts
788
- - **🧹 Fix Issues button** — appears automatically when issues are detected; click to clean up orphaned handoffs and stale rollups in one click, no MCP tool call required
789
- - **No issues found** — shown in green when memory integrity is confirmed
790
-
791
- The tool and dashboard button both call the same repair logic — the dashboard button is simply a zero-friction shortcut for common maintenance.
792
-
793
- ### v2.5 Enterprise Memory Tools
794
-
795
- | Tool | Purpose | Key Args | Returns |
796
- |------|---------|----------|---------|
797
- | `session_forget_memory` | GDPR-compliant deletion (soft/hard) | `memory_id`, `hard_delete`, `reason` | Deletion confirmation + audit |
798
- | `session_search_memory` | Semantic search with `enable_trace` | `query`, `enable_trace` | Results + `MemoryTrace` in `content[1]` |
799
- | `knowledge_search` | Knowledge search with `enable_trace` | `query`, `enable_trace` | Results + `MemoryTrace` in `content[1]` |
800
-
801
- ### v4.0 Behavioral Memory Tools
802
-
803
- | Tool | Purpose | Key Args |
804
- |------|---------|----------|
805
- | `session_save_experience` | Record behavioral events with importance tracking | `project`, `event_type`, `context`, `action`, `outcome` |
806
-
807
- **Dynamic Roles (v4.0):** `role` is now *optional* on all tools. Set your **Default Role** once in the dashboard (⚙️ Settings → Agent Identity) and it auto-applies everywhere — no need to pass it per call.
808
-
809
- **Token Budget (v4.0):** Set a default in the dashboard (⚙️ Settings → Token Budget) or pass `max_tokens` per call to override:
810
-
811
- ```json
812
- { "name": "session_load_context", "arguments": {
813
- "project": "my-app", "level": "standard", "max_tokens": 2000
814
- }}
815
- ```
816
-
817
- > 💡 Set Token Budget to `0` in the dashboard for unlimited (default). Per-call `max_tokens` always takes priority.
818
-
819
- **Recording experiences:**
820
-
821
- ```json
822
- { "name": "session_save_experience", "arguments": {
823
- "project": "my-app",
824
- "event_type": "correction",
825
- "context": "User asked to add a database migration",
826
- "action": "Ran ALTER TABLE directly in production",
827
- "outcome": "Data was corrupted",
828
- "correction": "Always create a migration file and test in staging first",
829
- "confidence_score": 95
830
- }}
831
- ```
832
-
833
- **Event types:** `correction` (user corrected the agent), `success` (task went well), `failure` (task failed), `learning` (new knowledge acquired).
834
-
835
- **How behavioral memory works:**
836
- 1. Agent records experiences via `session_save_experience`
837
- 2. Prism assigns an **importance score** based on event type + confidence
838
- 3. Stale entries **auto-decay** in importance over time
839
- 4. On `session_load_context`, high-importance corrections auto-surface as `[⚠️ BEHAVIORAL WARNINGS]`
840
- 5. Agent sees warnings and avoids repeating past mistakes
841
-
842
- ### v4.3.0 Knowledge Sync Rules — "The Bridge"
843
-
844
- Bridges **v4.0 Behavioral Memory** (graduated insights) with **v4.2.0 Project Registry** (repo paths) to physically write agent learnings into your project's IDE rules file.
845
-
846
- | Feature | Without Sync Rules | With `knowledge_sync_rules` |
847
- |---------|-------------------|----------------------------|
848
- | **Insight Visibility** | Only in Prism context injection | Persisted as static IDE context (`.cursorrules` / `.clauderules`) |
849
- | **Cross-Session** | Loaded per-session via tool call | Always-on — IDE reads rules file on every prompt |
850
- | **Agent Learning Loop** | Behavioral warnings during context load | Rules enforced even without Prism connected |
851
- | **Idempotency** | N/A | Sentinel markers ensure safe re-runs |
852
- | **User Control** | View in dashboard | User-maintained rules preserved; only sentinel block updated |
492
+ | `memory_checkout` | Revert to any previous version (non-destructive) |
853
493
 
854
- **Syncing graduated insights:**
855
-
856
- ```json
857
- { "name": "knowledge_sync_rules", "arguments": {
858
- "project": "my-app",
859
- "target_file": ".cursorrules",
860
- "dry_run": true
861
- }}
862
- ```
863
-
864
- **How it works:**
865
- 1. Fetches graduated insights (`importance >= 7`) from the ledger
866
- 2. Formats them as markdown rules inside `<!-- PRISM:AUTO-RULES:START/END -->` sentinel markers
867
- 3. Idempotently writes them into the target file at the project's configured `repo_path`
868
-
869
- | Tool | Purpose | Key Args |
870
- |------|---------|----------|
871
- | `knowledge_sync_rules` | Sync graduated insights to IDE rules file | `project`, `target_file`, `dry_run` |
872
- | `knowledge_upvote` | Increase entry importance (+1) | `id` |
873
- | `knowledge_downvote` | Decrease entry importance (-1) | `id` |
874
-
875
- > 💡 **Prerequisite:** Set a `repo_path` for your project in the Mind Palace dashboard (⚙️ Settings → Project Repo Paths) before syncing.
876
-
877
- ### Code Mode Templates (v2.1)
878
-
879
- Instead of writing custom JavaScript, pass a `template` name for instant extraction:
880
-
881
- | Template | Source Data | What It Extracts |
882
- |----------|-----------|-----------------|
883
- | `github_issues` | GitHub REST API | `#number [state] title (@author) {labels}` |
884
- | `github_prs` | GitHub REST API | `#number [state] title (base ← head)` |
885
- | `jira_tickets` | Jira REST API | `[KEY] summary - Status - Priority - Assignee` |
886
- | `dom_links` | Raw HTML | All `<a>` links as markdown |
887
- | `dom_headings` | Raw HTML | H1-H6 hierarchy with indentation |
888
- | `api_endpoints` | OpenAPI/Swagger JSON | `[METHOD] /path - summary` |
889
- | `slack_messages` | Slack Web API | `[timestamp] @user: message` |
890
- | `csv_summary` | CSV text | Column names, row count, sample rows |
891
-
892
- **Tool Arguments:** `{ "data": "<raw JSON>", "template": "github_issues" }` — no custom code needed.
893
-
894
- ---
895
-
896
- ## Agent Hivemind — Role Usage
897
-
898
- Role-scoped memory lets multiple agents work on the same project without stepping on each other's memory. Each role gets its own isolated memory lane. Defaults to `global` for full backward compatibility.
494
+ </details>
899
495
 
900
- ### Available Roles
496
+ <details>
497
+ <summary><strong>Search & Analysis (7 tools)</strong></summary>
901
498
 
902
- | Role | Use for |
499
+ | Tool | Purpose |
903
500
  |------|---------|
904
- | `dev` | Development agent |
905
- | `qa` | Testing / QA agent |
906
- | `pm` | Product management |
907
- | `lead` | Tech lead / orchestrator |
908
- | `security` | Security review |
909
- | `ux` | Design / UX |
910
- | `global` | Default shared, no isolation |
911
-
912
- Custom role strings are also supported (e.g. `"docs"`, `"ml"`).
913
-
914
- ### Using Roles with Memory Tools
915
-
916
- Just add `"role"` to any of the core memory tools:
917
-
918
- ```json
919
- // Save a ledger entry as the "dev" agent
920
- { "name": "session_save_ledger", "arguments": {
921
- "project": "my-app",
922
- "role": "dev",
923
- "conversation_id": "abc123",
924
- "summary": "Fixed the auth race condition"
925
- }}
926
-
927
- // Load context scoped to your role
928
- // Also injects a Team Roster showing active teammates
929
- { "name": "session_load_context", "arguments": {
930
- "project": "my-app",
931
- "role": "dev",
932
- "level": "standard"
933
- }}
934
-
935
- // Save handoff as the "qa" agent
936
- { "name": "session_save_handoff", "arguments": {
937
- "project": "my-app",
938
- "role": "qa",
939
- "last_summary": "Ran regression suite — 2 failures in auth module"
940
- }}
941
- ```
942
-
943
- ### Hivemind Coordination Tools
944
-
945
- > **Requires:** `PRISM_ENABLE_HIVEMIND=true` (Boot Setting — restart required)
946
-
947
- ```json
948
- // Announce yourself to the team at session start
949
- { "name": "agent_register", "arguments": {
950
- "project": "my-app",
951
- "role": "dev",
952
- "agent_name": "Dev Agent #1",
953
- "current_task": "Refactoring auth module"
954
- }}
955
-
956
- // Pulse every ~5 min to stay visible (agents pruned after 30 min)
957
- { "name": "agent_heartbeat", "arguments": {
958
- "project": "my-app",
959
- "role": "dev",
960
- "current_task": "Now writing tests"
961
- }}
962
-
963
- // See everyone on the team
964
- { "name": "agent_list_team", "arguments": {
965
- "project": "my-app"
966
- }}
967
- ```
968
-
969
- ### How Role Isolation Works
970
-
971
- - `session_load_context` with `role: "dev"` only sees entries saved with `role: "dev"`
972
- - The `global` role is a shared pool — anything saved without a role goes here
973
- - When loading *with* a role, Prism auto-injects a **Team Roster** block listing active teammates, roles, and tasks — no extra tool call needed
974
- - The Hivemind Radar widget in the Mind Palace dashboard shows agent activity in real time
975
-
976
- ### Setting Your Agent Identity
977
-
978
- The easiest way to configure your role and name is via the **Mind Palace Dashboard ⚙️ Settings → Agent Identity**:
979
-
980
- - **Default Role** — dropdown to select `dev`, `qa`, `pm`, `lead`, `security`, `ux`, or `global`
981
- - **Agent Name** — free text for your display name (e.g. `Dmitri`, `Dev Alex`, `QA Bot`)
982
-
983
- Once set, **all memory and Hivemind tools automatically use these values** as fallbacks — no need to pass `role` or `agent_name` in every tool call.
984
-
985
- > **Priority order:** explicit tool arg → dashboard setting → `"global"` (default)
986
-
987
- **Alternative — hardcode in your startup rules** (if you prefer prompt-level config):
988
-
989
- ```markdown
990
- ## Prism MCP Memory Auto-Load (CRITICAL)
991
- At the start of every new session, call session_load_context with:
992
- - project: "my-app", role: "dev"
993
- - project: "my-other-project", role: "dev"
994
- ```
995
-
996
- > **Tip:** For true multi-agent setups, each AI instance has its own Mind Palace dashboard — set a different identity per agent there rather than managing it in prompts.
997
-
998
- ---
999
-
1000
- ## LangChain / LangGraph Integration
1001
-
1002
- Prism MCP includes first-class Python adapters for the LangChain ecosystem, located in `examples/langgraph-agent/`:
1003
-
1004
- | Component | File | Purpose |
1005
- |-----------|------|---------|
1006
- | **MCP Bridge** | `mcp_client.py` | JSON-RPC 2.0 client with `call_tool()` and `call_tool_raw()` (preserves `MemoryTrace`) |
1007
- | **Semantic Retriever** | `prism_retriever.py` | `PrismMemoryRetriever(BaseRetriever)` — async-first vector search |
1008
- | **Keyword Retriever** | `prism_retriever.py` | `PrismKnowledgeRetriever(BaseRetriever)` — FTS5 keyword search |
1009
- | **Forget Tool** | `tools.py` | `forget_memory()` — GDPR deletion bridge |
1010
- | **Research Agent** | `agent.py` | 5-node LangGraph agent (plan→search→analyze→decide→answer→save) |
1011
-
1012
- ### Hybrid Search with EnsembleRetriever
1013
-
1014
- Combine both retrievers for hybrid (semantic + keyword) search with a single line:
1015
-
1016
- ```python
1017
- from langchain.retrievers import EnsembleRetriever
1018
- from prism_retriever import PrismMemoryRetriever, PrismKnowledgeRetriever
1019
-
1020
- retriever = EnsembleRetriever(
1021
- retrievers=[PrismMemoryRetriever(...), PrismKnowledgeRetriever(...)],
1022
- weights=[0.7, 0.3], # 70% semantic, 30% keyword
1023
- )
1024
- ```
1025
-
1026
- ### MemoryTrace in LangSmith
501
+ | `brave_web_search` | Real-time internet search |
502
+ | `brave_local_search` | Location-based POI discovery |
503
+ | `brave_web_search_code_mode` | JS extraction over web search results |
504
+ | `brave_local_search_code_mode` | JS extraction over local search results |
505
+ | `code_mode_transform` | Universal post-processing with 8 built-in templates |
506
+ | `gemini_research_paper_analysis` | Academic paper analysis via Gemini |
507
+ | `brave_answers` | AI-grounded answers from Brave |
1027
508
 
1028
- When `enable_trace=True`, each `Document.metadata["trace"]` contains:
509
+ </details>
1029
510
 
1030
- ```json
1031
- {
1032
- "strategy": "vector_cosine_similarity",
1033
- "latency": { "embedding_ms": 45, "storage_ms": 12, "total_ms": 57 },
1034
- "result_count": 5,
1035
- "threshold": 0.7
1036
- }
1037
- ```
511
+ <details>
512
+ <summary><strong>Multi-Agent Hivemind (3 tools)</strong></summary>
1038
513
 
1039
- This metadata flows automatically into LangSmith traces for observability.
514
+ Requires `PRISM_ENABLE_HIVEMIND=true`.
1040
515
 
1041
- ### Async Architecture
516
+ | Tool | Purpose |
517
+ |------|---------|
518
+ | `agent_register` | Announce yourself to the team |
519
+ | `agent_heartbeat` | Pulse every ~5 min to stay visible |
520
+ | `agent_list_team` | See all active teammates |
1042
521
 
1043
- The retrievers use `_aget_relevant_documents` as the primary path with `asyncio.to_thread()` to wrap the synchronous MCP bridge. This prevents the `RuntimeError: This event loop is already running` crash that plagues most LangGraph deployments.
522
+ </details>
1044
523
 
1045
524
  ---
1046
525
 
1047
526
  ## Environment Variables
1048
527
 
528
+ <details>
529
+ <summary><strong>Full variable reference</strong></summary>
530
+
1049
531
  | Variable | Required | Description |
1050
532
  |----------|----------|-------------|
1051
- | `BRAVE_API_KEY` | No | Brave Search Pro API key (enables web/local search tools) |
1052
- | `PRISM_STORAGE` | No | `"local"` (default) or `"supabase"` — **requires restart** |
1053
- | `PRISM_ENABLE_HIVEMIND` | No | Set `"true"` to enable multi-agent Hivemind tools — **requires restart** |
1054
- | `PRISM_INSTANCE` | No | Instance name for PID lock isolation (e.g. `"athena"`, `"prism-dev"`). Enables [multi-instance support](#multi-instance-support). Default: `"default"` |
1055
- | `GOOGLE_API_KEY` | No | Google AI / Gemini — enables paper analysis, Morning Briefings, compaction |
1056
- | `BRAVE_ANSWERS_API_KEY` | No | Separate Brave Answers key for AI-grounded answers |
1057
- | `SUPABASE_URL` | If cloud mode | Supabase project URL |
1058
- | `SUPABASE_KEY` | If cloud mode | Supabase anon/service key |
533
+ | `BRAVE_API_KEY` | No | Brave Search Pro API key |
534
+ | `PRISM_STORAGE` | No | `"local"` (default) or `"supabase"` — restart required |
535
+ | `PRISM_ENABLE_HIVEMIND` | No | `"true"` to enable multi-agent tools — restart required |
536
+ | `PRISM_INSTANCE` | No | Instance name for multi-server PID isolation |
537
+ | `GOOGLE_API_KEY` | No | Gemini — enables semantic search, Briefings, compaction |
538
+ | `BRAVE_ANSWERS_API_KEY` | No | Separate Brave Answers key |
539
+ | `SUPABASE_URL` | If cloud | Supabase project URL |
540
+ | `SUPABASE_KEY` | If cloud | Supabase anon/service key |
1059
541
  | `PRISM_USER_ID` | No | Multi-tenant user isolation (default: `"default"`) |
1060
- | `PRISM_AUTO_CAPTURE` | No | Set `"true"` to auto-capture HTML snapshots of dev servers |
1061
- | `PRISM_CAPTURE_PORTS` | No | Comma-separated ports to scan (default: `3000,3001,5173,8080`) |
1062
- | `PRISM_DEBUG_LOGGING` | No | Set `"true"` to enable verbose debug logs (default: quiet) |
1063
-
1064
- ---
1065
-
1066
- ## ⚡ Boot Settings (Restart Required)
1067
-
1068
- Some settings affect how Prism **initializes at startup** and cannot be changed at runtime. Prism stores these in a lightweight, dedicated SQLite database (`~/.prism-mcp/prism-config.db`) that is read **before** the main storage backend is selected — solving the chicken-and-egg problem of needing config before the config store is ready.
1069
-
1070
- > **⚠️ You must restart the Prism MCP server after changing any Boot Setting.** The Mind Palace dashboard labels these with a **"Restart Required"** badge.
1071
-
1072
- | Setting | Dashboard Control | Environment Override | Description |
1073
- |---------|------------------|---------------------|-------------|
1074
- | `PRISM_STORAGE` | ⚙️ Storage Backend dropdown | `PRISM_STORAGE=supabase` | Switch between `local` (SQLite) and `supabase` (cloud) |
1075
- | `PRISM_ENABLE_HIVEMIND` | ⚙️ Hivemind Mode toggle | `PRISM_ENABLE_HIVEMIND=true` | Enable/disable multi-agent coordination tools |
1076
-
1077
- ### How Boot Settings Work
1078
-
1079
- 1. **Dashboard saves the setting** → written to `~/.prism-mcp/prism-config.db` immediately
1080
- 2. **You restart the MCP server** → server reads the config DB at startup, selects backend/features
1081
- 3. **Environment variables always win** → if `PRISM_STORAGE` is set in your MCP config JSON, it overrides the dashboard value
1082
-
1083
- ```
1084
- Priority: env var in MCP config JSON > Dashboard (prism-config.db) > default (local)
1085
- ```
1086
-
1087
- ### Runtime Settings (no restart needed)
1088
-
1089
- These settings take effect immediately without a restart:
1090
-
1091
- | Setting | Description |
1092
- |---------|-------------|
1093
- | Dashboard Theme | Visual theme for the Mind Palace (`dark`, `midnight`, `purple`) |
1094
- | Context Depth | Default level for `session_load_context` (`quick`, `standard`, `deep`) |
1095
- | Auto-Capture HTML | Snapshot local dev server HTML on every handoff save |
1096
-
1097
- ---
1098
-
1099
- ## Progressive Context Loading
1100
-
1101
- Load only what you need — saves tokens and speeds up boot:
1102
-
1103
- | Level | What You Get | Size | When to Use |
1104
- |-------|-------------|------|-------------|
1105
- | **quick** | Open TODOs + keywords | ~50 tokens | Fast check-in: "what was I working on?" |
1106
- | **standard** | Above + summary + recent decisions + knowledge cache + Git drift | ~200 tokens | **Recommended default** |
1107
- | **deep** | Above + full logs (last 5 sessions) + cross-project knowledge | ~1000+ tokens | After a long break or when you need complete history |
1108
-
1109
- ### Morning Briefing (Automatic)
1110
-
1111
- If it's been more than 4 hours since your last session, Prism automatically:
1112
- 1. Fetches the 10 most recent uncompacted ledger entries
1113
- 2. Sends a notification: *"🌅 Brewing your Morning Briefing..."*
1114
- 3. Uses Gemini to synthesize a 3-bullet action plan
1115
- 4. Injects the briefing into the `session_load_context` response
1116
-
1117
- The agent boots up knowing exactly what to do — zero prompting needed.
1118
-
1119
- ### Auto-Load on Session Start (Recommended)
1120
-
1121
- For the best experience, ensure your agent boots with full project memory on every new session. There are three approaches — use whichever fits your workflow:
1122
-
1123
- #### Option A: Dashboard Setting (Easiest)
1124
-
1125
- Open the **Mind Palace Dashboard** (⚙️ Settings) and type your project names into the **Auto-Load Projects** field under Boot Settings:
1126
-
1127
- ```
1128
- prism-mcp, my-app
1129
- ```
1130
-
1131
- That's it. Restart your AI client and Prism auto-pushes context for each listed project on next boot.
1132
-
1133
- #### Option B: Client-Side Hooks / Rules
1134
-
1135
- For clients that support lifecycle hooks or startup rules, instruct the AI to **call `session_load_context` as a tool** at session start:
1136
-
1137
- - **[Claude Code Integration (Hooks)](#claude-code-integration-hooks)** — `SessionStart` and `Stop` hook JSON samples for `~/.claude/settings.json`
1138
- - **[Gemini / Antigravity Integration](#gemini--antigravity-integration)** — global rules for `~/.gemini/GEMINI.md` or user rules
1139
-
1140
- > **You can use both approaches together.** The dashboard auto-load (A) injects project names into the `session_load_context` tool description — works universally across all MCP clients. Client-side hooks (B) give the AI full structured access to the context response (including version numbers for OCC).
1141
-
1142
- > **Key principle:** Never hardcode a `role` in your hooks or rules. Set your role once in the **Mind Palace Dashboard ⚙️ Settings → Agent Identity**, and Prism automatically resolves it for every tool call across all clients. See [Role Resolution](#role-resolution--no-hardcoding-needed).
1143
-
1144
- > **Tip:** Replace `my-project` with your actual project identifiers. You can list as many projects as you need — each one gets its own independent memory timeline.
1145
-
1146
- ---
1147
-
1148
- ## Time Travel (Version History)
1149
-
1150
- Every successful handoff save creates a snapshot. You can browse and revert any version:
1151
-
1152
- ```
1153
- v1 → v2 → v3 → v4 (current)
1154
-
1155
- memory_checkout(v2) → creates v5 with v2's content
1156
- ```
1157
-
1158
- This is a **non-destructive revert** — like `git revert`, not `git reset`. No history is ever lost.
1159
-
1160
- ### Usage
1161
-
1162
- ```json
1163
- // Browse all versions
1164
- { "name": "memory_history", "arguments": { "project": "my-app" } }
1165
-
1166
- // Revert to version 2
1167
- { "name": "memory_checkout", "arguments": { "project": "my-app", "version": 2 } }
1168
- ```
1169
-
1170
- ---
1171
-
1172
- ## Agent Telepathy (Multi-Client Sync)
542
+ | `PRISM_AUTO_CAPTURE` | No | `"true"` to auto-snapshot dev servers |
543
+ | `PRISM_CAPTURE_PORTS` | No | Comma-separated ports (default: `3000,3001,5173,8080`) |
544
+ | `PRISM_DEBUG_LOGGING` | No | `"true"` for verbose logs |
545
+ | `PRISM_DASHBOARD_PORT` | No | Dashboard port (default: `3000`) |
1173
546
 
1174
- When Agent A (Cursor) saves a handoff, Agent B (Claude Desktop) gets notified instantly:
1175
-
1176
- - **Local Mode:** File-based IPC via SQLite polling
1177
- - **Cloud Mode:** Supabase Realtime (Postgres CDC)
1178
-
1179
- No configuration needed — it just works.
547
+ </details>
1180
548
 
1181
549
  ---
1182
550
 
1183
- ## Reality Drift Detection
551
+ ## Architecture
1184
552
 
1185
- Prism captures Git state (branch + commit SHA) on every handoff save. When the agent loads context, it compares the saved state against the current working directory:
553
+ <details>
554
+ <summary><strong>Three-Tier Memory Architecture</strong></summary>
1186
555
 
1187
556
  ```
1188
- ⚠️ REALITY DRIFT DETECTED for "my-app":
1189
- Branch changed: feature/auth → main
1190
- Commit changed: abc1234 → def5678
1191
-
1192
- The codebase has been modified since your last session.
1193
- Re-examine before making assumptions.
1194
- ```
1195
-
1196
- This prevents the agent from writing code based on stale context.
1197
-
1198
- ---
1199
-
1200
- ## Visual Memory & Auto-Capture
557
+ searchMemory() flow:
1201
558
 
1202
- ### Manual: Save Screenshots
559
+ Tier 0: FTS5 keywords → Full-text search (knowledge_search)
560
+ Tier 1: float32 (3072B) → sqlite-vec cosine similarity (native)
561
+ Tier 2: turbo4 (400B) → JS asymmetricCosineSimilarity (fallback)
1203
562
 
1204
- ```json
1205
- { "name": "session_save_image", "arguments": {
1206
- "project": "my-app",
1207
- "image_path": "/path/to/screenshot.png",
1208
- "description": "Login page after CSS fix"
1209
- }}
563
+ → Tier 1 success → return results
564
+ Tier 1 fail → Tier 2 success → return results
565
+ Tier 2 fail → return []
1210
566
  ```
1211
567
 
1212
- ### Automatic: HTML Snapshots
1213
-
1214
- Set `PRISM_AUTO_CAPTURE=true` and Prism silently captures your local dev server's HTML on every handoff save. Supported formats: PNG, JPG, WebP, GIF, SVG, HTML.
1215
-
1216
- ---
1217
-
1218
- ## Knowledge Accumulation
1219
-
1220
- Every `session_save_ledger` and `session_save_handoff` automatically extracts keywords using lightweight, in-process NLP (~0.020ms/call). No LLM calls, no external dependencies.
568
+ Every `session_save_ledger` call generates both tiers automatically:
569
+ 1. Gemini generates float32 embedding (3,072 bytes)
570
+ 2. TurboQuant compresses to turbo4 blob (~400 bytes)
571
+ 3. Single atomic write stores both to the database
1221
572
 
1222
- **Example:** Saving *"Fixed Stripe webhook race condition using database-backed idempotency keys"* auto-extracts:
1223
- - **Keywords:** `stripe`, `webhook`, `race`, `condition`, `database`, `idempotency`
1224
- - **Categories:** `cat:debugging`, `cat:api-integration`
573
+ | Metric | Before v5.0 | After v5.0 |
574
+ |--------|------------|------------|
575
+ | Storage per embedding | 3,072 bytes | ~400 bytes |
576
+ | Compression ratio | 1:1 | ~7.7:1 (4-bit) |
577
+ | Entries per GB | ~330K | ~2.5M |
1225
578
 
1226
- ### Search Knowledge
1227
-
1228
- ```json
1229
- { "name": "knowledge_search", "arguments": {
1230
- "project": "ecommerce-api",
1231
- "category": "debugging",
1232
- "query": "Stripe webhook"
1233
- }}
1234
- ```
579
+ </details>
1235
580
 
1236
- ### Forget Bad Memories
581
+ <details>
582
+ <summary><strong>Progressive Context Loading</strong></summary>
1237
583
 
1238
- | Mode | Example | Effect |
1239
- |------|---------|--------|
1240
- | **By project** | `project: "old-app"` | Clear all knowledge |
1241
- | **By category** | `category: "debugging"` | Forget debugging entries only |
1242
- | **By age** | `older_than_days: 30` | Forget entries older than 30 days |
1243
- | **Dry run** | `dry_run: true` | Preview what would be deleted |
584
+ | Level | What You Get | Size | When to Use |
585
+ |-------|-------------|------|-------------|
586
+ | **quick** | Open TODOs + keywords | ~50 tokens | Fast check-in |
587
+ | **standard** | + summary + recent decisions + Git drift | ~200 tokens | **Recommended** |
588
+ | **deep** | + full logs (last 5 sessions) + cross-project knowledge | ~1000+ tokens | After a long break |
1244
589
 
1245
- ## GDPR Compliance
590
+ </details>
1246
591
 
1247
- ### GDPR-Compliant Deletion
592
+ <details>
593
+ <summary><strong>Role Resolution</strong></summary>
1248
594
 
1249
- Prism supports surgical, per-entry deletion for GDPR Article 17 compliance:
595
+ Prism resolves agent roles using a priority chain:
1250
596
 
1251
- ```json
1252
- // Soft delete (tombstone — reversible, keeps audit trail)
1253
- { "name": "session_forget_memory", "arguments": {
1254
- "memory_id": "abc123",
1255
- "reason": "User requested data deletion"
1256
- }}
1257
-
1258
- // Hard delete (permanent — irreversible)
1259
- { "name": "session_forget_memory", "arguments": {
1260
- "memory_id": "abc123",
1261
- "hard_delete": true
1262
- }}
1263
597
  ```
1264
-
1265
- **How it works:**
1266
- - **Soft delete** sets `deleted_at = NOW()` + `deleted_reason`. The entry stays in the DB for audit but is excluded from ALL search results (vector, FTS5, and context loading).
1267
- - **Hard delete** physically removes the row. FTS5 triggers auto-clean the full-text index.
1268
- - **Top-K Hole Prevention**: `deleted_at IS NULL` filtering happens INSIDE the SQL query, BEFORE the `LIMIT` clause — so `LIMIT 5` always returns 5 live results, never fewer. *(A "Top-K Hole" occurs when deleted entries are filtered out after the vector search, causing fewer than K results to be returned. Prism avoids this by filtering inside SQL before the LIMIT.)*
1269
-
1270
- ### Article 17 — Right to Erasure ("Right to be Forgotten")
1271
-
1272
- | Requirement | How Prism Satisfies It |
1273
- |-------------|----------------------|
1274
- | **Individual deletion** | `session_forget_memory` operates on a single `memory_id` — the data subject can request deletion of *specific* memories, not just bulk wipes. |
1275
- | **Soft delete (audit trail)** | `deleted_at` + `deleted_reason` columns prove *when* and *why* data was deleted — required for SOC2 audit logs. |
1276
- | **Hard delete (full erasure)** | `hard_delete: true` physically removes the row from the database. No tombstone, no trace. True erasure as required by Article 17(1). |
1277
- | **Justification logging** | The `reason` parameter captures the GDPR justification (e.g., `"User requested data deletion"`, `"Data retention policy expired"`). |
1278
-
1279
- ### Article 25 — Data Protection by Design and by Default
1280
-
1281
- | Requirement | How Prism Satisfies It |
1282
- |-------------|----------------------|
1283
- | **Ownership guards** | `softDeleteLedger()` and `hardDeleteLedger()` verify `user_id` before executing. User A cannot delete User B's data. |
1284
- | **Database-level filtering** | `deleted_at IS NULL` is inside the SQL `WHERE` clause, *before* `LIMIT`. Soft-deleted data never leaks into search results — not even accidentally. |
1285
- | **Default = safe** | The system defaults to soft delete (reversible). Hard delete requires an explicit `hard_delete: true` flag — preventing accidental permanent data loss. |
1286
- | **Multi-tenant isolation** | `PRISM_USER_ID` environment variable ensures all operations are scoped to a single tenant. |
1287
-
1288
- ### Coverage Summary
1289
-
1290
- | GDPR Right | Status | Implementation |
1291
- |-----------|--------|----------------|
1292
- | Right to Erasure (Art. 17) | ✅ Implemented | `session_forget_memory` (soft + hard delete) |
1293
- | Data Protection by Design (Art. 25) | ✅ Implemented | Ownership guards, DB-level filtering, safe defaults |
1294
- | Audit Trail | ✅ Implemented | `deleted_at` + `deleted_reason` columns |
1295
- | User Isolation | ✅ Implemented | `user_id` verification on all delete operations |
1296
- | Right to Portability (Art. 20) | ✅ Implemented | `session_export_memory` — ZIP export of JSON + Markdown, API keys redacted |
1297
- | Consent Management | ➖ Out of scope | Application-layer responsibility |
1298
-
1299
- > **Note:** No software is "GDPR certified" on its own — GDPR is an organizational compliance framework. Prism provides the technical controls that a DPO (Data Protection Officer) needs to satisfy the data deletion and privacy-by-design requirements.
1300
-
1301
- ---
1302
-
1303
- ## Observability & Tracing
1304
-
1305
- Prism MCP ships **two complementary tracing systems** serving different audiences:
1306
-
1307
- | | MemoryTrace | OpenTelemetry (OTel) |
1308
- |---|---|---|
1309
- | **Question answered** | Why was this memory returned? | What was the end-to-end latency? |
1310
- | **Output** | `content[1]` in MCP response | OTLP → Jaeger / Tempo / Zipkin |
1311
- | **Trigger** | `enable_trace: true` parameter | Every tool call, automatically |
1312
- | **Audience** | LLM / LangSmith orchestration | Developers debugging infrastructure |
1313
-
1314
- ### MemoryTrace (Phase 1 — LLM Explainability)
1315
-
1316
- A zero-dependency tracing system built for MCP. Returns per-query latency breakdowns and result scoring metadata as a second `content` block — keeping structured telemetry out of the LLM's context window.
1317
-
1318
- ```json
1319
- { "trace": { "strategy": "semantic", "latency": { "embedding_ms": 45, "storage_ms": 12, "total_ms": 57 }, "result_count": 3 } }
598
+ explicit tool argument → dashboard setting → "global" (default)
1320
599
  ```
1321
600
 
1322
- ### OpenTelemetry (Phase 2 Infrastructure Observability)
601
+ Set your role once in the Mind Palace Dashboard (⚙️ Settings Agent Identity) and it auto-applies to every session.
1323
602
 
1324
- Every MCP tool call emits a **4-tier span waterfall** to any OTLP-compatible collector:
603
+ Available roles: `dev`, `qa`, `pm`, `lead`, `security`, `ux`, `global`, or any custom string.
1325
604
 
1326
- ```
1327
- mcp.call_tool [e.g. session_save_image, ~50 ms]
1328
- └─ worker.vlm_caption [~2–5 s, outlives parent ✓]
1329
- └─ llm.generate_image_description [~1–4 s]
1330
- └─ llm.generate_embedding [~200 ms]
1331
- ```
1332
-
1333
- **Quick-start with Jaeger:**
605
+ </details>
1334
606
 
1335
- ```bash
1336
- docker run -d -p 4318:4318 -p 16686:16686 jaegertracing/all-in-one
607
+ <details>
608
+ <summary><strong>Project Structure</strong></summary>
609
+
610
+ ```
611
+ src/
612
+ ├── server.ts # MCP server core + tool routing
613
+ ├── config.ts # Environment management
614
+ ├── storage/
615
+ │ ├── interface.ts # StorageBackend abstraction
616
+ │ ├── sqlite.ts # SQLite local (libSQL + F32_BLOB)
617
+ │ ├── supabase.ts # Supabase cloud storage
618
+ │ └── configStorage.ts # Boot config micro-DB
619
+ ├── dashboard/
620
+ │ ├── server.ts # Dashboard HTTP server
621
+ │ └── ui.ts # Mind Palace glassmorphism UI
622
+ ├── tools/
623
+ │ ├── definitions.ts # Search & analysis schemas
624
+ │ ├── handlers.ts # Search & analysis handlers
625
+ │ ├── sessionMemoryDefinitions.ts
626
+ │ └── sessionMemoryHandlers.ts
627
+ └── utils/
628
+ ├── telemetry.ts # OTel singleton
629
+ ├── turboquant.ts # TurboQuant math core
630
+ ├── universalImporter.ts # Universal migration orchestrator
631
+ ├── migration/ # Format-specific adapters (Claude/Gemini/OpenAI)
632
+ ├── imageCaptioner.ts # VLM auto-caption pipeline
633
+ └── llm/adapters/ # Gemini, OpenAI, Anthropic, Ollama
1337
634
  ```
1338
635
 
1339
- Then open **Mind Palace Dashboard → ⚙️ Settings → 🔭 Observability**, toggle OTel on, and restart. Open [localhost:16686](http://localhost:16686) to see traces.
1340
-
1341
- **GDPR-safe by design:** Span attributes capture only character counts and byte sizes — never prompt content, vector embeddings, or base64 image data.
1342
-
1343
- | Setting | Default | Description |
1344
- |---------|---------|-------------|
1345
- | `otel_enabled` | `false` | Toggle OTel pipeline on/off (restart required) |
1346
- | `otel_endpoint` | `http://localhost:4318/v1/traces` | OTLP HTTP collector URL |
1347
- | `otel_service_name` | `prism-mcp-server` | Service label in trace UI |
1348
-
1349
-
1350
- ---
1351
-
1352
- ## Supabase Setup (Cloud Mode)
636
+ </details>
1353
637
 
1354
638
  <details>
1355
- <summary><strong>Step-by-step Supabase configuration</strong></summary>
1356
-
1357
- ### 1. Create a Supabase Project
1358
-
1359
- 1. Go to [supabase.com](https://supabase.com) and sign in (free tier works)
1360
- 2. Click **New Project** → choose a name and password → select a region
1361
- 3. Wait for provisioning (~30 seconds)
1362
-
1363
- ### 2. Apply Migrations
639
+ <summary><strong>Supabase Setup</strong></summary>
1364
640
 
1365
- In the SQL Editor, run the **bootstrap migration** first:
1366
- 1. [`supabase/migrations/015_session_memory.sql`](supabase/migrations/015_session_memory.sql)
1367
- 2. [`supabase/migrations/016_knowledge_accumulation.sql`](supabase/migrations/016_knowledge_accumulation.sql)
1368
- 3. [`supabase/migrations/027_auto_migration_infra.sql`](supabase/migrations/027_auto_migration_infra.sql) **enables auto-migrations** (see below)
641
+ 1. Create a Supabase project at [supabase.com](https://supabase.com)
642
+ 2. Run the migration SQL files from `supabase/migrations/` in order
643
+ 3. Set `PRISM_STORAGE=supabase`, `SUPABASE_URL`, and `SUPABASE_KEY` in your MCP config
644
+ 4. Prism auto-applies pending DDL migrations on startup via `prism_apply_ddl` RPC
1369
645
 
1370
- > **After applying migration 027**, all future schema changes are applied automatically on server startup — no manual SQL required.
1371
-
1372
- ### 3. Get Credentials
646
+ </details>
1373
647
 
1374
- Go to **Settings → API** and copy:
1375
- - **Project URL** (e.g. `https://abcdefg.supabase.co`)
1376
- - **anon public** key (starts with `eyJ...`)
648
+ <details>
649
+ <summary><strong>LangChain / LangGraph Integration</strong></summary>
1377
650
 
1378
- ### 4. Configure
651
+ Prism includes Python adapters in `examples/langgraph-agent/`:
1379
652
 
1380
- Add these to your MCP client's configuration file (e.g., `claude_desktop_config.json` under `"env"`), or export them if running the server manually:
653
+ ```python
654
+ from langchain.retrievers import EnsembleRetriever
655
+ from prism_retriever import PrismMemoryRetriever, PrismKnowledgeRetriever
1381
656
 
1382
- ```bash
1383
- export SUPABASE_URL="https://your-project.supabase.co"
1384
- export SUPABASE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
1385
- export PRISM_STORAGE="supabase"
657
+ # Hybrid search: 70% semantic, 30% keyword
658
+ retriever = EnsembleRetriever(
659
+ retrievers=[PrismMemoryRetriever(...), PrismKnowledgeRetriever(...)],
660
+ weights=[0.7, 0.3],
661
+ )
1386
662
  ```
1387
663
 
1388
- > **Note:** Claude Desktop, Cursor, and other MCP clients spawn isolated processes — terminal `export` commands won't be inherited. Always set env vars in the client's config JSON.
1389
-
1390
- ### Security
1391
-
1392
- 1. **Use the anon key** for MCP server config
1393
- 2. **Enable RLS** on both tables
1394
- 3. **Never commit** your `SUPABASE_KEY` to version control
664
+ Includes a full 5-node LangGraph research agent with MCP bridge and persistent memory.
1395
665
 
1396
666
  </details>
1397
667
 
1398
- ### Auto-Migrations (Supabase Cloud)
1399
-
1400
- Prism includes a zero-config auto-migration system for Supabase. Once the bootstrap migration (`027_auto_migration_infra.sql`) is applied, all future schema changes are applied automatically on server startup.
1401
-
1402
- **How it works:**
1403
-
1404
- 1. On startup, the migration runner checks each entry in `MIGRATIONS[]` (defined in `supabaseMigrations.ts`)
1405
- 2. For each migration, it calls `prism_apply_ddl(version, name, sql)` — a `SECURITY DEFINER` RPC function
1406
- 3. The function checks `prism_schema_versions` — if the version is already recorded, it's silently skipped (idempotent)
1407
- 4. If not applied, it executes the DDL and records the version number
1408
-
1409
- **Graceful degradation:** If `prism_apply_ddl()` doesn't exist (you haven't applied migration 027 yet), the runner logs a warning and continues — the server still starts, but newer schema features may not be available.
1410
-
1411
- **Adding new migrations** — just append to the `MIGRATIONS[]` array in `src/storage/supabaseMigrations.ts`:
1412
-
1413
- ```typescript
1414
- {
1415
- version: 28,
1416
- name: "my_new_feature",
1417
- sql: `ALTER TABLE session_ledger ADD COLUMN IF NOT EXISTS my_col TEXT;`,
1418
- }
1419
- ```
1420
-
1421
- All SQL must be idempotent (`IF NOT EXISTS` / `IF EXISTS` guards).
1422
-
1423
668
  ---
1424
669
 
1425
- ## Multi-Instance Support
670
+ ## Research Roadmap
1426
671
 
1427
- Run multiple Prism MCP servers side-by-side on the same machine without PID lock conflicts. This is useful when you have different MCP configurations (e.g., one for web search + memory, another for memory-only) running in different clients simultaneously.
672
+ Prism is evolving from smart session logging toward a **cognitive memory architecture** grounded in real research, not marketing.
1428
673
 
1429
- ### Configuration
674
+ | Phase | Feature | Inspired By | Status |
675
+ |-------|---------|-------------|--------|
676
+ | **v5.2** | Smart Consolidation — extract principles, not just summaries | Neuroscience sleep consolidation | ✅ Shipped |
677
+ | **v5.2** | Ebbinghaus Importance Decay — memories fade unless reinforced | Ebbinghaus forgetting curve | ✅ Shipped |
678
+ | **v5.2** | Context-Weighted Retrieval — current work biases what surfaces | Contextual memory in cognitive science | ✅ Shipped |
679
+ | **v6.x** | Superposed Memory (SDM) — O(1) retrieval via correlation | Kanerva's Sparse Distributed Memory (1988) | 🔬 Research |
680
+ | **v6.x** | Affect-Tagged Memory — sentiment shapes what gets recalled | Affect-modulated retrieval (neuroscience) | 🔬 Research |
681
+ | **v7+** | Zero-Search Retrieval — no index, no ANN, just ask the vector | Holographic Reduced Representations | 🔭 Horizon |
1430
682
 
1431
- Set `PRISM_INSTANCE` to a unique name per server instance:
1432
-
1433
- ```json
1434
- {
1435
- "mcpServers": {
1436
- "prism-search": {
1437
- "command": "node",
1438
- "args": ["/path/to/prism/dist/server.js"],
1439
- "env": {
1440
- "PRISM_INSTANCE": "prism-search",
1441
- "BRAVE_API_KEY": "your-key"
1442
- }
1443
- },
1444
- "prism-memory": {
1445
- "command": "node",
1446
- "args": ["/path/to/prism/dist/server.js"],
1447
- "env": {
1448
- "PRISM_INSTANCE": "prism-memory"
1449
- }
1450
- }
1451
- }
1452
- }
1453
- ```
1454
-
1455
- ### How it works
1456
-
1457
- - Each instance gets its own PID file: `/tmp/prism-{PRISM_INSTANCE}.pid`
1458
- - Default instance name is `"default"` (backward compatible)
1459
- - Instances share the same SQLite database and Supabase backend — only the process lock is isolated
1460
- - Graceful shutdown cleans up the instance's PID file
683
+ > Informed by LeCun's "Why AI Systems Don't Learn" (Dupoux, LeCun, Malik — March 2026) and Kanerva's SDM.
1461
684
 
1462
685
  ---
1463
686
 
1464
- ## Hybrid Search Pipeline (Brave + Vertex AI)
687
+ ## Version History
1465
688
 
1466
689
  <details>
1467
- <summary><strong>Enterprise search with Vertex AI Discovery Engine</strong></summary>
1468
-
1469
- Prism can combine **real-time web search** (Brave) with **enterprise-curated search** (Vertex AI Discovery Engine) for a hybrid pipeline achieving **94% context reduction** and **~17K tokens saved per query**.
1470
-
1471
- | Metric | Brave (Web) | Discovery Engine | Hybrid |
1472
- |--------|------------|-----------------|--------|
1473
- | Avg latency | 220ms | 1,193ms | ~1.4s |
1474
- | Raw payload | 42.4 KB | 28.9 KB | 71.3 KB |
1475
- | Reduced payload | 3.0 KB | 1.2 KB | **4.2 KB** (94% reduction) |
1476
- | Token savings | ~10,103 | ~7,097 | **~17,200 / query** |
1477
-
1478
- See [`vertex-ai/`](vertex-ai/) for setup and benchmarks.
690
+ <summary><strong>Previous releases (v3.0 v5.0)</strong></summary>
691
+
692
+ - **v5.1** Knowledge Graph Editor, Deep Storage purge
693
+ - **v5.0** — TurboQuant 10× embedding compression, three-tier search architecture
694
+ - **v4.6** OpenTelemetry distributed tracing (Jaeger, Grafana)
695
+ - **v4.5** — VLM multimodal memory + GDPR Art. 20 ZIP export
696
+ - **v4.4** Pluggable LLM adapters (OpenAI, Anthropic, Gemini, Ollama)
697
+ - **v4.3** Knowledge Sync Rules (behavioral insights IDE rules)
698
+ - **v4.2** Project repo registry + universal auto-load
699
+ - **v4.1** Auto-migration + multi-instance support
700
+ - **v4.0** — Behavioral memory (corrections, importance, auto-decay)
701
+ - **v3.1** — Memory lifecycle (TTL, auto-compaction, PKM export)
702
+ - **v3.0** — Agent Hivemind (role-scoped memory, Telepathy sync)
703
+
704
+ See [CHANGELOG.md](CHANGELOG.md) for full details.
1479
705
 
1480
706
  </details>
1481
707
 
1482
708
  ---
1483
709
 
1484
- ## Project Structure
1485
-
1486
- ```
1487
- ├── src/
1488
- │ ├── server.ts # MCP server core + tool routing + lifecycle
1489
- │ ├── config.ts # Environment management
1490
- │ ├── storage/
1491
- │ │ ├── interface.ts # StorageBackend abstraction (+ GDPR delete methods)
1492
- │ │ ├── sqlite.ts # SQLite local storage (libSQL + F32_BLOB + deleted_at migration)
1493
- │ │ ├── supabase.ts # Supabase cloud storage (+ soft/hard delete)
1494
- │ │ ├── supabaseMigrations.ts # Auto-migration runner for Supabase DDL
1495
- │ │ ├── configStorage.ts # Boot config micro-DB (~/.prism-mcp/prism-config.db)
1496
- │ │ └── index.ts # Backend factory (auto-selects based on PRISM_STORAGE)
1497
- │ ├── sync/
1498
- │ │ ├── interface.ts # SyncBus abstraction (Telepathy)
1499
- │ │ ├── localSync.ts # File-based IPC for local mode
1500
- │ │ ├── supabaseSync.ts # Supabase Realtime CDC for cloud mode
1501
- │ │ └── factory.ts # Auto-selects sync backend
1502
- │ ├── dashboard/
1503
- │ │ ├── server.ts # Dashboard HTTP server with port recovery
1504
- │ │ └── ui.ts # Mind Palace glassmorphism HTML template
1505
- │ ├── templates/
1506
- │ │ └── codeMode.ts # 8 pre-built QuickJS extraction templates
1507
- │ ├── tools/
1508
- │ │ ├── definitions.ts # Search & analysis tool schemas
1509
- │ │ ├── handlers.ts # Search & analysis handlers
1510
- │ │ ├── sessionMemoryDefinitions.ts # Memory tools + GDPR + tracing schemas
1511
- │ │ ├── sessionMemoryHandlers.ts # Memory handlers (OCC, GDPR, Tracing, Time Travel)
1512
- │ │ ├── compactionHandler.ts # Gemini-powered ledger compaction
1513
- │ │ └── index.ts # Tool registration & re-exports
1514
- │ └── utils/
1515
- │ └── utils/
1516
- │ ├── telemetry.ts # OTel singleton — NodeTracerProvider, BatchSpanProcessor, no-op mode
1517
- │ ├── tracing.ts # MemoryTrace types + factory (Phase 1 — LLM explainability)
1518
- │ ├── imageCaptioner.ts # VLM auto-caption pipeline (v4.5) + worker.vlm_caption OTel span
1519
- │ ├── logger.ts # Debug logging (gated by PRISM_DEBUG_LOGGING)
1520
- │ ├── braveApi.ts # Brave Search REST client
1521
- │ ├── googleAi.ts # Gemini SDK wrapper
1522
- │ ├── executor.ts # QuickJS sandbox executor
1523
- │ ├── autoCapture.ts # Dev server HTML snapshot utility
1524
- │ ├── healthCheck.ts # Brain integrity engine + security scanner
1525
- │ ├── factMerger.ts # Async LLM contradiction resolution
1526
- │ ├── git.ts # Git state capture + drift detection
1527
- │ ├── embeddingApi.ts # Embedding generation
1528
- │ ├── keywordExtractor.ts # Zero-dependency NLP keyword extraction
1529
- │ └── llm/
1530
- │ ├── provider.ts # LLMProvider interface
1531
- │ ├── factory.ts # Provider factory — composes + wraps in TracingLLMProvider
1532
- │ └── adapters/
1533
- │ ├── gemini.ts # Google Gemini adapter
1534
- │ ├── openai.ts # OpenAI adapter
1535
- │ ├── anthropic.ts # Anthropic Claude adapter
1536
- │ ├── ollama.ts # Ollama (local) adapter
1537
- │ └── traced.ts # TracingLLMProvider decorator (v4.6 OTel)
1538
- ├── examples/langgraph-agent/ # LangChain/LangGraph integration
1539
- │ ├── agent.py # 5-node LangGraph research agent
1540
- │ ├── mcp_client.py # MCP Bridge (call_tool + call_tool_raw)
1541
- │ ├── prism_retriever.py # PrismMemoryRetriever + PrismKnowledgeRetriever
1542
- │ ├── tools.py # Agent tools + GDPR forget_memory
1543
- │ └── demo_retriever.py # Standalone retriever demo
1544
- ├── supabase/migrations/ # Cloud mode SQL schemas + auto-migration bootstrap
1545
- │ └── 027_auto_migration_infra.sql # prism_apply_ddl() RPC + schema version tracking
1546
- ├── vertex-ai/ # Vertex AI hybrid search pipeline
1547
- ├── index.ts # Server entry point
1548
- └── package.json
1549
- ```
1550
-
1551
- ---
1552
-
1553
710
  ## 🚀 Roadmap
1554
711
 
1555
- > **[View the full project board →](https://github.com/users/dcostenco/projects/1/views/1)** | **[Full ROADMAP.md →](ROADMAP.md)**
1556
-
1557
- ### ✅ v4.6 — OpenTelemetry Observability (Shipped!)
1558
-
1559
- | Feature | Description |
1560
- |---|---|
1561
- | 🔭 **OTel Root Span** | Every MCP tool call wrapped in `mcp.call_tool` span — propagated to all child async operations via AsyncLocalStorage. |
1562
- | 🎨 **TracingLLMProvider** | Decorator pattern wraps the composed LLM factory. Zero changes to vendor adapters. Instruments `generate_text`, `generate_embedding`, `generate_image_description`. |
1563
- | ⚙️ **Worker Spans** | `worker.vlm_caption` span in `imageCaptioner` correctly parents fire-and-forget async tasks to the root span. |
1564
- | 🔒 **Shutdown Flush** | `shutdownTelemetry()` wired as step-0 in `lifecycle.ts` — flushes `BatchSpanProcessor` before DB closes on SIGTERM. |
1565
- | 🖥️ **Dashboard UI** | New 🔭 Observability tab with enable toggle, OTLP endpoint, service name, inline Jaeger docker command, and ASCII waterfall diagram. |
1566
-
1567
- ### ✅ v4.5 — VLM Multimodal Memory & GDPR Export (Shipped!)
1568
-
1569
- | Feature | Description |
1570
- |---|---|
1571
- | 👁️ **Auto-Captioning** | `session_save_image` → VLM → ledger entry → vector embedding. Images become semantically searchable with zero schema changes. |
1572
- | 📦 **GDPR Art. 20** | `session_export_memory` — full ZIP export (JSON + Markdown), API keys redacted, embeddings stripped. |
1573
- | 🧪 **270 tests** | Full regression coverage including concurrent safety, redaction edge cases, and MCP contract validation. |
1574
-
1575
- ### ✅ v4.4 — Pluggable LLM Adapters (Shipped!)
1576
-
1577
- | Feature | Description |
1578
- |---|---|
1579
- | 🔌 **BYOM** | OpenAI, Anthropic, Gemini, Ollama adapters. Text + embedding providers independently configurable. |
1580
- | 🛡️ **Air-Gapped** | Full local mode via Ollama — zero cloud API keys required. |
1581
-
1582
- ### ✅ v4.3 — The Bridge: Knowledge Sync Rules (Shipped!)
1583
-
1584
- See [What's in v4.3.0](#whats-new-in-v430--the-bridge-) above — syncing dynamic behavioral insights to static IDE rules files.
1585
-
1586
- ### ✅ v4.2 — Project Repo Registry (Shipped!)
1587
-
1588
- | Feature | Description |
1589
- |---|---|
1590
- | 🗂️ **Project Repo Paths** | Dashboard UI to map projects to repo directories + `session_save_ledger` path validation. |
1591
- | 🔄 **Universal Auto-Load** | Dynamic tool descriptions replace env var — dashboard is sole source of truth. |
1592
-
1593
- ### ✅ v4.1 — Auto-Migration & Multi-Instance (Shipped!)
1594
-
1595
- See [What's in v4.1.0](#whats-in-v410--auto-migration--multi-instance-) above.
1596
-
1597
- ### ✅ v4.0 — Behavioral Memory (Shipped!)
1598
-
1599
- See [What's in v4.0.0](#whats-in-v400--behavioral-memory-) above.
1600
-
1601
- ### ✅ v3.x — Memory Lifecycle & Agent Hivemind (Shipped!)
1602
-
1603
- See [v3.1.0](#whats-in-v310--memory-lifecycle-) and [v3.0.0](#whats-in-v300--agent-hivemind-) above.
1604
-
1605
- ---
1606
-
1607
- ### 🗺️ Next on the Horizon
712
+ > **[Full ROADMAP.md →](ROADMAP.md)**
1608
713
 
1609
- | Priority | Feature | Description |
1610
- |----------|---------|-------------|
1611
- | 🥇 | **Documentation & Architecture Guide** | Full README overhaul with architecture diagrams, "How to build a self-improving agent" walkthrough, and v4.x feature matrix. |
1612
- | 🥈 | **Knowledge Graph Editor** | Visual graph in Mind Palace showing nodes for projects, agents, sessions, and graduated rules. |
1613
- | 🥉 | **Autonomous Web Scholar** | Agent-driven learning pipeline using Brave Search + VLM to autonomously build project context while the developer sleeps. |
1614
- | — | **Dashboard Auth** | Optional basic auth for remote Mind Palace access. |
1615
- | — | **TypeScript LangGraph Examples** | Reference implementations alongside the existing Python agent. |
1616
- | — | **CRDT Conflict Resolution** | Conflict-free types for concurrent multi-agent edits on the same handoff. |
714
+ **Next (v5.3):**
715
+ - 🔄 CRDT Handoff Merging — conflict-free concurrent multi-agent edits
716
+ - Background Purge Scheduler automated storage reclamation
717
+ - 📱 Mind Palace Mobile PWA offline-first responsive dashboard
718
+ - 🌐 Autonomous Web Scholar agent-driven research pipeline
1617
719
 
1618
720
  ---
1619
721
 
@@ -1623,4 +725,4 @@ MIT
1623
725
 
1624
726
  ---
1625
727
 
1626
- <sub>**Keywords:** MCP server, Model Context Protocol, Claude Desktop memory, persistent session memory, AI agent memory, local-first, SQLite MCP, Mind Palace, time travel, visual memory, VLM image captioning, OpenTelemetry OTel tracing, Jaeger distributed traces, GDPR export portability, agent telepathy, multi-agent sync, behavioral memory, IDE rules sync, cursorrules, pluggable LLM, Ollama MCP, Anthropic Claude MCP, OpenAI MCP, reality drift detection, morning briefing, code mode templates, cursor MCP server, windsurf MCP server, cline MCP server, pgvector semantic search, progressive context loading, MCP Prompts, MCP Resources, knowledge management AI, Brave Search MCP, Gemini analysis, optimistic concurrency control, zero config, memory tracing, LangChain retriever, LangGraph agent, soft delete, memory lineage, explainability, enterprise AI memory</sub>
728
+ <sub>**Keywords:** MCP server, Model Context Protocol, Claude Desktop memory, persistent session memory, AI agent memory, local-first, SQLite MCP, Mind Palace, time travel, visual memory, VLM image captioning, OpenTelemetry, GDPR, agent telepathy, multi-agent sync, behavioral memory, cursorrules, Ollama MCP, Brave Search MCP, TurboQuant, progressive context loading, knowledge management, LangChain retriever, LangGraph agent</sub>