@kolivri/memoreal-mcp 1.0.2 → 1.1.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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "memoreal",
3
+ "version": "1.1.0",
4
+ "description": "Memoreal long-term memory and 32-tool polyglot code intelligence for Claude Code, OpenCode, Codex, Cursor, and 17 AI coding harnesses.",
5
+ "author": {
6
+ "name": "Kolivri",
7
+ "url": "https://memoreal.kolivri.com"
8
+ }
9
+ }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "memoreal",
3
3
  "displayName": "Memoreal — Deterministic AI Memory & Code Intelligence",
4
- "version": "1.0.2",
5
- "description": "Deterministic long-term memory and code intelligence MCP plugin for Cursor (100% on LongMemEval in 12.9 ms, 0 LLM write tokens, 14 Cloud MCP tools, rules, skills, agents, and session hooks).",
4
+ "version": "1.1.0",
5
+ "description": "Deterministic long-term memory and code intelligence MCP plugin for Cursor (100% on LongMemEval in 12.9 ms, 0 LLM write tokens, 32 Cloud MCP tools, rules, skills, agents, and session hooks).",
6
6
  "author": {
7
7
  "name": "Kolivri",
8
8
  "email": "stas@kolivri.com"
package/CLAUDE.md CHANGED
@@ -1,26 +1,28 @@
1
1
  <!-- memoreal:start -->
2
- ## Memoreal Long-Term Memory
2
+ ## Memoreal Long-Term Memory (32 MCP Tools)
3
3
 
4
- This session has Memoreal MCP tools available. Use them to access long-term memory across sessions.
4
+ This session has Memoreal MCP tools available. Use them to access deterministic long-term memory, cross-session recall, and code intelligence across sessions.
5
5
 
6
6
  ### Always Try Memoreal First
7
7
 
8
- - **Finding context**: Call `build_context` with the current namespace and a query describing what you need. This returns token-budgeted context from all previous sessions, tasks, plans, and decisions.
9
- - **Recalling past work**: Use `recall_memories` before assuming you don't have context. Previous conversations, decisions, and knowledge are indexed.
10
- - **Exploring code**: Try `search_code` and `explain_code` before reading files directly — they return indexed, ranked results with less token overhead.
11
- - **Before changing a shared symbol**: call `find_references` (not `grep -rn`) to get every call-site scoped to the indexed project; `explain_code`'s "Used by:" uses the same scan.
12
- - **Locating a file**: use `find_file` (not `find -name`/`ls`) to resolve a file or directory by name/path.
13
- - **Orienting in a large corpus**: Use `navigate` to walk the hierarchical map (project → directory → file → definition) instead of issuing repeated searches. Zoom coarse-to-fine and pull only the slice you need into context.
14
- - **Placing an item in context**: Use `get_hierarchy` on a node id to get every layer connected to it in one call — all ancestors (project → directory → file → …) and its full descendant subtree, each with its note.
15
- - **Understanding changes**: Use `explain_diff` for change analysis and `explain_error` for error diagnosis.
16
- - **Storing knowledge**: Use `encode_memory` to persist important decisions, task outcomes, and learnings.
8
+ - **Turn-1 Cold Start**: Call `bootstrap_project` on Turn 1 of an unindexed repository to extract docs (`CLAUDE.md`, `AGENTS.md`, `README.md`) and up to 150 code symbols into Memoreal Cloud.
9
+ - **Finding context**: Call `build_context` with the canonical namespace and a query describing what you need. This returns token-budgeted context from all previous sessions, tasks, plans, and decisions.
10
+ - **Recalling past work**: Use `recall_memories` before assuming you don't have context.
11
+ - **Exploring code & symbols**: Try `search_code`, `explain_code`, and `find_file` before reading files directly.
12
+ - **Before changing a shared symbol**: Call `find_references` to get every workspace call-site, `impact` for blast radius, and `call_tree` (`direction: 'in' | 'out'`) to trace call paths.
13
+ - **Orienting in a project**: Use `navigate` (zoom/peek cursor walk) and `get_hierarchy` (ancestor & descendant tree) to inspect project structure coarse-to-fine before bulk file reads.
14
+ - **Architecture & quality**: Use `implementors` to locate interface implementations, `dead_code` to detect unreferenced code, and `test_gaps` to uncover missing coverage.
15
+ - **Changes, risk & diagnostics**: Use `diff_risk` to evaluate change risk, `downstream_effects` for cascading impacts, `root_cause` for error traces, `trace_provenance` for symbol evolution, `explain_diff` for git diff review, and `explain_error` for runtime/compiler diagnostics.
16
+ - **Safe refactoring**: Use `rename` to compute a comprehensive, safe symbol rename plan across all definitions and call-sites.
17
+ - **Multi-agent collaboration**: Use `list_agent_wings` and `handoff_to_agent` for structured handoffs between specialized wings (`architect`, `reviewer`, `qa`, `security`, `ops`).
18
+ - **Account & setup**: Use `connect_account` for in-chat 3-click authentication setup.
19
+ - **Storing & pruning knowledge**: Use `encode_memory` or `batch_encode` for durable decisions and bug root causes, `feedback` to adjust salience, and `forget_memory` or `delete_by_context` to remove obsolete memories.
17
20
 
18
21
  ### Hierarchical Navigation — use it before bulk file reads
19
22
 
20
23
  Indexed namespaces (e.g. `code/{project}`) are a containment map: **project → directory → file → definition → chunk**, every node carrying a one-line note (a directory rolls up its files/defs; a function carries its signature + doc). When you need to understand structure — "how is this project laid out", "what's in this module", "where does this function sit", "what does it contain" — reach for the map *first*, not a pile of `Read`s.
21
24
 
22
25
  **`navigate`** — stateless cursor walk over the map:
23
-
24
26
  1. **Orient**: call `navigate` with just `namespace` → the root view: cursor, child summaries, legal `moves`.
25
27
  2. **Zoom**: pass `cursor` (current node id) + `move`: `{"ZoomIn": {"child": "<id>"}}` to descend, `"ZoomOut"` to ascend, `"Next"`/`"Prev"` for siblings, `{"Expand": {"levels": N}}` to see N levels at once.
26
28
  3. **Peek**: `{"Peek": {"node": "<id>"}}` returns a node's full content without moving the cursor.
@@ -28,27 +30,25 @@ Indexed namespaces (e.g. `code/{project}`) are a containment map: **project →
28
30
 
29
31
  **`get_hierarchy`** — one shot, all layers around an item: `{namespace, node}` returns `ancestors` (every layer above), the `node`, and `descendants` (the whole subtree below), with `descendants_total` flagging truncation. Use it to answer "what is this item's full place in the system" without a manual climb.
30
32
 
31
- **Pick the layer by intent**: strategic / "what is this" questions read near the top (project, directory, file notes); "how exactly does this work" reads the bottom (definition, chunk). You choose depth by where you stop zooming; the node's `kind` tells you which layer you're on.
32
-
33
- **Prefer the map over re-searching**: a `navigate`/`get_hierarchy` move is a few graph reads; a fresh `search_code` re-pays full ranking and returns a flat list with no position. Use `search_code` to find an *entry point*, then `navigate`/`get_hierarchy` from there. Prefer both over reading whole files when you only need structure or one definition.
34
-
35
- ### Session Start
36
-
37
- On every new session, load context by calling `build_context` with:
38
- - `namespace`: derived from pwd (replace `/` with `-` in the working directory path)
39
- - `query`: "previous tasks, plans, pending work, key decisions, progress, recent context"
40
- - `token_budget`: 4096
33
+ ### Session Start & Turn-1 Cold-Start Indexing
41
34
 
42
- This loads all prior tasks, plans, decisions, and context from previous sessions automatically.
35
+ 1. **Turn-1 Indexing**: If working on an unindexed repository or fresh clone, call `bootstrap_project` with `{ project_dir }` to index markdown guidance and top-level code symbols.
36
+ 2. **Context Load**: On every new session, load context by calling `build_context` with:
37
+ - `namespace`: canonical project namespace (optional; auto-resolves when omitted, see below)
38
+ - `query`: "previous tasks, plans, pending work, key decisions, progress, recent context"
39
+ - `token_budget`: 4096
40
+ 3. **Engine Health**: Call `health` in parallel to verify Cloud engine connectivity.
43
41
 
44
- ### Namespace
42
+ ### Namespace Derivation
45
43
 
46
- All Memoreal operations require a namespace. Derive it from the current working directory by replacing `/` with `-`.
47
- Example: `/Users/alice/projects/myapp` becomes `-Users-alice-projects-myapp`
44
+ All Memoreal operations require a namespace. The Memoreal MCP plugin automatically resolves the canonical project namespace from repository manifests (`package.json`, `Cargo.toml`, `pyproject.toml`, `go.mod`, `pom.xml`, etc., across 32 ecosystems), `.memoreal-namespace`, git remotes, and git worktrees — so agents can either omit `namespace` to let the MCP server resolve it automatically or pass the canonical project slug from `memoreal-ns`.
45
+ - **Worktree Stripping**: Always strip any worktree path components (`/.worktrees/*`, `/.claude/worktrees/*`, `/.opencode/worktrees/*`, `/.codex/worktrees/*`, `/.cursor/worktrees/*`).
46
+ - **No `org:` Prefix**: Never prepend an `org:` prefix to the namespace.
47
+ - **Worktree Consistency**: Git worktrees automatically resolve to the canonical repository project namespace, guaranteeing all worktrees share the exact same persistent memory namespace as the base repo.
48
48
 
49
49
  ### Memory Hygiene
50
50
 
51
- - Search before encoding to avoid duplicates
52
- - Give `feedback` on recalled memories to improve retrieval quality
53
- - Run `consolidate` periodically to merge duplicates and detect contradictions
51
+ - Search before encoding (`recall_memories`, `search_code`) to avoid duplicates.
52
+ - Give `feedback` on recalled memories (`useful: true | false`) to adjust retrieval salience.
53
+ - Run `consolidate` (and check `stats`) periodically to merge duplicates and promote high-salience memories.
54
54
  <!-- memoreal:end -->
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # `@kolivri/memoreal-mcp` — Deterministic AI Memory & Code Intelligence MCP for Claude Code, OpenCode, Cursor & Claude Desktop
1
+ # `@kolivri/memoreal-mcp` — Deterministic AI Memory & Code Intelligence MCP for Claude Code, OpenCode, Cursor, Codex & 17 AI Harnesses
2
2
 
3
3
  [![kolivritech/memoreal-mcp MCP server](https://glama.ai/mcp/servers/kolivritech/memoreal-mcp/badges/score.svg)](https://glama.ai/mcp/servers/kolivritech/memoreal-mcp)
4
4
  [![Node.js >= 18](https://img.shields.io/badge/node-%3E%3D18.0.0-339933)](./package.json)
5
5
 
6
- `@kolivri/memoreal-mcp` is the official zero-dependency Node.js ESM **Model Context Protocol (MCP)** connector (`stdio` & HTTP) for **[Memoreal Cloud](https://memoreal.kolivri.com)** — giving AI coding and operator agents (**Claude Code, OpenCode, Cursor, Windsurf, VS Code, Cline, Roo Code, Zed, Goose, and Claude Desktop**) deterministic long-term memory, cross-session recall, and code intelligence powered by `memoreal.kolivri.com`.
6
+ `@kolivri/memoreal-mcp` is the official zero-dependency Node.js ESM **Model Context Protocol (MCP)** connector (`stdio` & HTTP) for **[Memoreal Cloud](https://memoreal.kolivri.com)** — giving AI coding and operator agents across 17 local AI agent harnesses (**Claude Code, Claude Desktop, Cursor, OpenCode, OpenAI Codex, Windsurf, VS Code / GitHub Copilot, Zed, Gemini CLI, Cline, Roo Code, Kilo Code, Continue, Block Goose, Sourcegraph Amp, AWS Kiro & Amazon Q, Trae, and Aider**) deterministic long-term memory, cross-session recall, and polyglot code intelligence powered by `memoreal.kolivri.com`.
7
7
 
8
8
  - **Memoreal Cloud Portal & API Keys**: [https://memoreal.kolivri.com](https://memoreal.kolivri.com) ([Get API Key](https://memoreal.kolivri.com/register) — includes **1,000 free API calls/memories**; paid tiers: **Developer $19/mo**, **Startup $79/mo**, **Business $299/mo**)
9
9
  - **Documentation & Benchmarks**: [https://memoreal.kolivri.com/docs](https://memoreal.kolivri.com/docs) (`500/500 = 100.0%` LongMemEval at `12.9 ms` p50, `102/102 = 100.0%` Hebrew LongMemEval across 15 languages)
@@ -16,16 +16,122 @@
16
16
  | Variable | Required | Default | Description |
17
17
  | --- | --- | --- | --- |
18
18
  | `MEMOREAL_API_KEY` | **Yes** | — | Your Memoreal Cloud API key (`mem_dev_...`, `mem_start_...`, or `mem_biz_...`) from [memoreal.kolivri.com/register](https://memoreal.kolivri.com/register) |
19
- | `MEMOREAL_API_URL` | Optional | `https://memoria.kolivri.com` | Memoreal Cloud base URL (or `https://memoreal.kolivri.com`) |
19
+ | `MEMOREAL_API_URL` | Optional | `https://memoreal.kolivri.com` | Memoreal Cloud base URL |
20
20
  | `MEMOREAL_NAMESPACE` | Optional | `default` | Default project/workspace namespace when omitted from tool arguments |
21
21
 
22
22
  > **Backward Compatibility**: Legacy `MEMORIA_API_KEY`, `MEMORIA_API_URL`, and `MEMORIA_NAMESPACE` environment variables remain 100% supported as automatic fallbacks across all transports.
23
23
 
24
24
  ---
25
25
 
26
+ ## The 5 Market Tracks & Automated Feature Showcases
27
+
28
+ Memoreal Cloud provides deterministic, high-speed memory architectures tailored to 5 primary market tracks. Each track leverages a dedicated context mode, domain-specific hooks, and live automated feature showcases:
29
+
30
+ ### 1. Software Developers & Engineering Teams (`mode: "organizational"`)
31
+ - **Stack & Installation**: `npx -y @kolivri/memoreal-mcp setup` across Windows, Linux/WSL, and macOS supporting all 17 local AI agent harnesses.
32
+ - **Polyglot Code Intelligence**: Cold-start `bootstrap_project` parses instructions (`CLAUDE.md`, `AGENTS.md`, `README.md`) and indexes symbols across 15+ programming languages.
33
+ - **Belief Revision & Evolution**: `Supersedes` graph edges dynamically deprecate killed-RFC architectural decisions when new patterns are accepted.
34
+ - **Architectural Tools**: Deep caller/callee trees (`call_tree`), blast radius assessment (`impact`), and gap detection (`test_gaps`).
35
+ - **Compaction-Proof Hooks**: Session lifecycle hooks provide `70%+` prompt token savings through automated memory recall and compaction survival.
36
+ - **CI/CD Integration**: Seamless integration with GitHub via `/v1/webhooks/github` for automatic memory syncing on branch merges.
37
+
38
+ ### 2. Automated Call & Customer Support Centers (`mode: "support"`)
39
+ - **Telephony & Helpdesk Connectors**: Native voice and support webhooks/SDKs for Kolivri Voice, Twilio, Vapi, LiveKit, WhatsApp, and Zendesk.
40
+ - **Sub-First-Ring Recall**: `12.9 ms*` p50 returning-caller memory recall eliminates dead air ($0 LLM dead air delay) before the first phone ring.
41
+ - **Multilingual Support**: Verified across 15 natural languages, including `102/102 = 100.0%` on Hebrew LongMemEval benchmark tests.
42
+ - **Dynamic Customer State**: `Supersedes` edges track live ticket status, address updates, and preference changes over time.
43
+ - **Privacy & Safety**: Pre-storage PII redaction ensures caller identity data and payment information are protected.
44
+
45
+ ### 3. Autonomous & Multi-Agent Builders (`mode: "operational"`)
46
+ - **Agent Frameworks**: Streamable HTTP `/v1/mcp` transport and REST SDK integrations for LangGraph, CrewAI, OpenAI Agents SDK, AutoGen, and Mastra.
47
+ - **5 Specialist Agent Wings**: Multi-agent coordination across `architect`, `reviewer`, `qa`, `security`, and `ops` wings via `handoff_to_agent` and `/v1/rooms/handoff`.
48
+ - **Memory Tiering**: Isolation between scratchpad ideation in `Buffer` tier vs immutable production invariants in `Core` tier.
49
+ - **Causal Reasoning**: Graph-powered dependency tracking via `downstream_effects` and `root_cause` diagnostics for runtime failure recovery.
50
+
51
+ ### 4. Sales, CRM & Revenue Operations AI (`mode: "sales"`)
52
+ - **RevOps Integrations**: Native connectors and webhooks for AI SDRs, HubSpot, Salesforce, Gong, n8n, and Make.
53
+ - **Deterministic Math**: Strict numeric reasoning and signed deal arithmetic (e.g. `$25k + $15k = $40k`) without LLM hallucination.
54
+ - **Entity Separation**: Strict graph boundary separation between first-party customer facts and competitor/vendor intelligence.
55
+ - **Pre-Call Briefs**: Automated account synthesis using `/v1/extract` and `/v1/reflect` to assemble instant executive briefing documents.
56
+
57
+ ### 5. Security- & Compliance-First Organizations (`mode: "research"`)
58
+ - **Cryptographic Access Control**: Role-scoped API keys with explicit `Write` vs `Read`-only auditor access.
59
+ - **Enterprise Team RBAC**: Granular role-based access control supporting `owner`, `admin`, `manager`, and `member` tiers.
60
+ - **Zero-Trust Data Protection**: Pre-storage PII/secret scrubbing and prompt-injection quarantine prevent memory poisoning.
61
+ - **Auditability & Provenance**: Full memory trust chains via `trace_provenance`, immutable audit trails via `/v1/trace/recent`, and GDPR compliance via `/v1/export` and right-to-forget endpoints.
62
+
63
+ ---
64
+
65
+ ## Cross-OS Support (Windows · Linux / WSL · macOS)
66
+
67
+ `@kolivri/memoreal-mcp` runs natively across all major operating systems with zero external shell dependencies:
68
+
69
+ - **Windows (`win32`)**:
70
+ - Full support for `PowerShell` and `cmd.exe`.
71
+ - Config paths resolved to `%APPDATA%` (Roaming) and `%LOCALAPPDATA%` with `%USERPROFILE%`.
72
+ - Lifecycle hooks run via pure Node.js (`bin/memoreal-hook.mjs`) and Windows batch wrappers (`bin/memoreal-ns.cmd`), requiring zero `/bin/sh` or `jq`.
73
+ - Safe OAuth browser launching via `rundll32` (`url.dll,FileProtocolHandler`), preventing URL query parameters (`&`) from breaking.
74
+ - **Linux & WSL (`linux`)**:
75
+ - Compliant with `$XDG_CONFIG_HOME` (defaulting to `~/.config`).
76
+ - Seamless WSL integration: automatically detects WSL environments (`WSL_DISTRO_NAME` / `WSL_INTEROP`) and opens the host Windows browser via `rundll32.exe`.
77
+ - **macOS (`darwin`)**:
78
+ - Idiomatic macOS application paths under `~/Library/Application Support` and `~/.config`.
79
+ - Works out of the box with standard Apple Silicon (`arm64`) and Intel (`x64`) architectures.
80
+
81
+ ---
82
+
83
+ ## Supported Local AI Agent Harnesses (17 Harnesses)
84
+
85
+ `@kolivri/memoreal-mcp` automatically detects and provisions MCP configurations, skills, and lifecycle hooks across **17 local AI agent harnesses**:
86
+
87
+ 1. **Claude Code** (`~/.claude/settings.json`, `.claude.json`, hooks)
88
+ 2. **Claude Desktop** (`claude_desktop_config.json` on macOS / Windows `%APPDATA%` / Linux)
89
+ 3. **Cursor** (`~/.cursor/mcp.json`, `.cursor/rules/`)
90
+ 4. **OpenCode** (`${XDG_CONFIG_HOME:-~/.config}/opencode/opencode.json`, plugins, hooks)
91
+ 5. **OpenAI Codex** (`~/.codex/config.toml`, `.codex/skills/`, `.codex/AGENTS.md`)
92
+ 6. **Windsurf** (`~/.codeium/windsurf/mcp_config.json`, `memories/global_rules.md`)
93
+ 7. **VS Code / GitHub Copilot** (`~/.vscode/mcp.json`, `Code/User/mcp.json`, `.github/copilot-instructions.md`)
94
+ 8. **Zed** (`~/.config/zed/settings.json` via `context_servers.memoreal`)
95
+ 9. **Gemini CLI** (`~/.gemini/settings.json`, `.gemini/GEMINI.md`)
96
+ 10. **Cline** (`cline_mcp_settings.json` in globalStorage / stdio with `cmd /c npx` on Windows)
97
+ 11. **Roo Code** (`mcp_settings.json` in globalStorage / stdio)
98
+ 12. **Kilo Code** (`mcp_settings.json` in globalStorage / stdio)
99
+ 13. **Continue** (`~/.continue/mcpServers/memoreal.json`)
100
+ 14. **Block Goose** (`~/.config/goose/config.yaml` via `extensions.memoreal`)
101
+ 15. **Sourcegraph Amp** (`~/.config/amp/settings.json` via `amp.mcpServers`)
102
+ 16. **AWS Kiro & Amazon Q** (`~/.kiro/settings/mcp.json`, `~/.aws/amazonq/mcp.json`, `.kiro/steering/memoreal.md`)
103
+ 17. **Trae** (`Trae/User/mcp.json`)
104
+ *(Also supports conventions for **Aider** via `CONVENTIONS.md`)*
105
+
106
+ ---
107
+
26
108
  ## Installation
27
109
 
28
- ### 1. One-Line Auto-Installer (15 AI Clients + Claude Code Lifecycle Hooks)
110
+ ### 1. Interactive CLI Setup & Auto-Hook Provisioning (Recommended)
111
+
112
+ Run the zero-dependency interactive setup wizard to configure your API key, auto-provision client lifecycle hooks and skills, and index your repository:
113
+
114
+ ```bash
115
+ # Interactive setup with automatic client detection
116
+ npx -y @kolivri/memoreal-mcp setup
117
+
118
+ # Or alias
119
+ npx -y @kolivri/memoreal-mcp init
120
+
121
+ # Setup with direct API key and target specific client
122
+ npx -y @kolivri/memoreal-mcp setup --key "mem_..." --tool opencode
123
+
124
+ # Setup without cold-start repository indexing
125
+ npx -y @kolivri/memoreal-mcp setup --no-bootstrap
126
+ ```
127
+
128
+ **What the setup wizard auto-provisions:**
129
+ - **Automated Client Detection**: Configures Claude Code, Cursor, OpenCode, Codex, Windsurf, and VS Code MCP configs.
130
+ - **Agent Lifecycle Hooks & Skills**: Copies plugins/skills and configures lifecycle hooks (`SessionStart`, `PreCompact`, `PostCompact`, `UserPromptSubmit`, `PostToolUse`, `TaskCompleted`, `Stop`) with `.bak` safety backups.
131
+ - **Canonical Worktree Resolver**: Installs `~/.memoreal/bin/memoreal-ns` (`0o755`) to ensure git worktrees share canonical repository memory namespaces without `org:` prefixes.
132
+ - **Turn-1 Cold-Start Indexing**: Automatically indexes repository guidance (`CLAUDE.md`, `AGENTS.md`, `README.md`) and code symbols into Memoreal Cloud (unless `--no-bootstrap` is passed).
133
+
134
+ ### 2. One-Line Auto-Installer (15 AI Clients + Claude Code Lifecycle Hooks)
29
135
 
30
136
  Automatically configures Claude Code, Cursor, Windsurf, VS Code, Claude Desktop, OpenCode, Cline, Roo Code, Continue, Zed, Goose, PearAI, Trae, Void, and Melty:
31
137
 
@@ -39,7 +145,7 @@ curl -fsSL --proto '=https' --tlsv1.2 https://memoreal.kolivri.com/downloads/ins
39
145
  $env:MEMOREAL_KEY="YOUR_MEMOREAL_API_KEY"; irm https://memoreal.kolivri.com/downloads/install.ps1 | iex
40
146
  ```
41
147
 
42
- ### 2. Claude Code (`claude mcp add`)
148
+ ### 3. Claude Code (`claude mcp add`)
43
149
 
44
150
  ```bash
45
151
  claude mcp add memoreal \
@@ -47,7 +153,7 @@ claude mcp add memoreal \
47
153
  -- npx -y @kolivri/memoreal-mcp
48
154
  ```
49
155
 
50
- ### 3. Cursor (`~/.cursor/mcp.json`) & Claude Desktop (`claude_desktop_config.json`)
156
+ ### 4. Cursor (`~/.cursor/mcp.json`) & Claude Desktop (`claude_desktop_config.json`)
51
157
 
52
158
  ```json
53
159
  {
@@ -64,7 +170,7 @@ claude mcp add memoreal \
64
170
  }
65
171
  ```
66
172
 
67
- ### 4. OpenCode (`~/.config/opencode/opencode.json`)
173
+ ### 5. OpenCode (`~/.config/opencode/opencode.json`)
68
174
 
69
175
  ```json
70
176
  {
@@ -82,7 +188,26 @@ claude mcp add memoreal \
82
188
  }
83
189
  ```
84
190
 
85
- ### 5. Docker
191
+ ### 6. OpenAI Codex (`~/.codex/config.toml`)
192
+
193
+ OpenAI Codex uses native TOML configuration (`~/.codex/config.toml`). Running `npx -y @kolivri/memoreal-mcp setup` automatically provisions the Streamable HTTP MCP server:
194
+
195
+ ```toml
196
+ [mcp_servers.memoreal]
197
+ url = "https://memoreal.kolivri.com/v1/mcp"
198
+ http_headers = { "Authorization" = "Bearer your-memoreal-api-key" }
199
+ ```
200
+
201
+ Alternatively, you can configure local `stdio` execution:
202
+
203
+ ```toml
204
+ [mcp_servers.memoreal]
205
+ command = "npx"
206
+ args = ["-y", "@kolivri/memoreal-mcp"]
207
+ env = { MEMOREAL_API_KEY = "your-memoreal-api-key", MEMOREAL_NAMESPACE = "my-project" }
208
+ ```
209
+
210
+ ### 7. Docker
86
211
 
87
212
  ```bash
88
213
  docker build -t memoreal-mcp .
@@ -94,24 +219,76 @@ docker run -i --rm \
94
219
 
95
220
  ---
96
221
 
97
- ## 14 MCP Tools (`https://memoreal.kolivri.com/v1/mcp`)
222
+ ## 32 MCP Tools (`https://memoreal.kolivri.com/v1/mcp`)
223
+
224
+ ### Core Memory & Context (10 Tools)
98
225
 
99
226
  | Tool | Required Args | Description |
100
227
  | --- | --- | --- |
228
+ | `build_context` | `query` | Assemble a token-budgeted `<memory_context>` block grouped into Core Rules, Established Facts, and Recent Context. |
229
+ | `recall_memories` | `query` | Retrieve top memories ranked deterministically by Memoreal Cloud within `token_budget`. |
101
230
  | `encode_memory` | `content` | Store a new memory in Memoreal Cloud with tier (`episodic`, `semantic`, `buffer`, `core`), `salience` (`0.0–1.0`), `namespace`, and `context` pairs. |
102
231
  | `batch_encode` | `memories` | Atomically encode an array of memories in a single call. |
103
- | `recall_memories` | `query` | Retrieve top memories ranked deterministically by Memoreal Cloud within `token_budget`. |
104
- | `build_context` | `query` | Assemble a token-budgeted `<memory_context>` block grouped into Core Rules, Established Facts, and Recent Context. |
105
232
  | `forget_memory` | `id` | Delete a specific memory and its incident graph edges by ID. |
106
233
  | `delete_by_context` | `key`, `value` | Delete all memories matching a specific `[key, value]` context metadata pair. |
107
234
  | `feedback` | `id`, `useful` | Record positive/negative utility feedback on a memory and adjust its salience score. |
108
235
  | `consolidate` | `namespace` | Deduplicate memories within a namespace and promote recurring high-salience episodic memories to `Semantic` tier. |
109
236
  | `health` | *(none)* | Return Memoreal Cloud engine health, active memory/edge counts, and tier distribution. |
110
237
  | `stats` | `namespace` | Return per-namespace memory count, edge count, and tier distribution. |
238
+
239
+ ### Code Intelligence & Navigation (9 Tools)
240
+
241
+ | Tool | Required Args | Description |
242
+ | --- | --- | --- |
243
+ | `bootstrap_project` | *(optional: `project_dir`, `namespace`)* | Turn-1 cold-start project indexing: parses instructions (`CLAUDE.md`, `AGENTS.md`, `README.md`) and indexes top-level code symbols into Memoreal Cloud. |
111
244
  | `search_code` | `query` | Search indexed code symbol definitions and references with file paths and line numbers. |
112
245
  | `explain_code` | `target` | Explain a symbol: definitions, workspace references, related tests, and associated architectural memories. |
246
+ | `find_file` | `pattern` | Resolve file or directory paths matching a pattern or name across the workspace. |
247
+ | `find_references` | `symbol` | Find all call-sites and symbol references across the indexed workspace. |
248
+ | `call_tree` | `symbol` | Generate caller/callee hierarchy trees (`direction: "in" \| "out"`, `max_depth`). |
249
+ | `navigate` | *(optional: `namespace`, `cursor`, `move`)* | Stateless hierarchical cursor walk across project, directory, file, and definition layers. |
250
+ | `get_hierarchy` | `node` | Single-shot retrieval of all ancestor layers and full descendant subtree around a node. |
251
+ | `implementors` | `interface_name` | List concrete implementations and classes implementing an interface, trait, or abstract type. |
252
+
253
+ #### 15+ Supported Programming Languages
254
+
255
+ The 16 code-intelligence tools natively parse definitions, references, and hierarchies across:
256
+ - **TypeScript & JavaScript** (`.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, `.cjs`)
257
+ - **Python** (`.py`)
258
+ - **Go** (`.go`)
259
+ - **Rust** (`.rs`)
260
+ - **Java** (`.java`)
261
+ - **C#** (`.cs`)
262
+ - **C & C++** (`.c`, `.cc`, `.cpp`, `.h`, `.hpp`)
263
+ - **PHP** (`.php`)
264
+ - **Ruby** (`.rb`)
265
+ - **Kotlin** (`.kt`, `.kts`)
266
+ - **Swift** (`.swift`)
267
+ - **Scala** (`.scala`)
268
+ - **Shell / Bash** (`.sh`, `.bash`)
269
+
270
+ ### Architecture, Quality & Diagnostics (10 Tools)
271
+
272
+ | Tool | Required Args | Description |
273
+ | --- | --- | --- |
274
+ | `impact` | `target` | Compute blast radius, affected call-sites, and test dependencies before changing a symbol or file. |
275
+ | `dead_code` | *(optional: `path`)* | Detect unreferenced symbols, orphan functions, and unreachable code paths across workspace. |
276
+ | `test_gaps` | *(optional: `path`)* | Identify untested symbols, uncovered edge cases, and missing test suites. |
277
+ | `diff_risk` | *(optional: `diff`, `path`)* | Compute deterministic risk score, hotspot warnings, and reviewer checklists for code diffs. |
278
+ | `downstream_effects` | `target` | Evaluate cascading architectural impact and downstream service dependencies. |
279
+ | `root_cause` | `error` | Trace error logs, crash signatures, and stack traces back to root cause symbols. |
280
+ | `trace_provenance` | `symbol` | Trace symbol origin, commit history, architectural decisions, and original rationale. |
281
+ | `explain_diff` | *(optional: `diff`, `path`)* | Provide structured code review explanations and risk highlights for git changes. |
282
+ | `explain_error` | `error` | Diagnose runtime exceptions, compiler errors, and stack traces with targeted fix advice. |
283
+ | `rename` | `old_name`, `new_name` | Calculate a complete, safe symbol rename plan across all call-sites and definitions. |
284
+
285
+ ### Multi-Agent Coordination & Setup (3 Tools)
286
+
287
+ | Tool | Required Args | Description |
288
+ | --- | --- | --- |
113
289
  | `list_agent_wings` | *(none)* | List specialist multi-agent wings (`architect`, `reviewer`, `qa`, `security`, `ops`) and active memory counts. |
114
290
  | `handoff_to_agent` | `from_wing`, `to_wing`, `summary`, `task` | Record a structured context handoff between specialist agent wings. |
291
+ | `connect_account` | *(optional: `action`, `device_code`)* | Interactive 3-click in-chat setup wizard for Memoreal credentials and client configuration. |
115
292
 
116
293
  ---
117
294
 
@@ -9,10 +9,19 @@ You are the Memoreal memory assistant integrated into this AI session.
9
9
 
10
10
  Memoreal hooks fire automatically on key events. When you see these signals, act on them:
11
11
 
12
- **`[memoreal-session-start]`** (or legacy `[memoria-session-start]`) — New session. The hook provides the namespace (pwd with `/` replaced by `-`). You MUST act on this before responding to the user:
13
- 1. Fetch MCP tool schemas: `ToolSearch` with query `select:mcp__memoreal__health,mcp__memoreal__build_context` (or `memoria` server prefix)
14
- 2. Call `health` (no params) and `build_context` with the namespace and query from the hook — run both in parallel
15
- 3. Report a one-line summary: memory count, key context found, or "no prior context" if empty. Then proceed to the user's message.
12
+ **`[memoreal-setup-wizard]`** (or `[memoria-setup-wizard]`) — Workspace is not yet connected to Memoreal Cloud or API key is unconfigured/expired (HTTP `401 Unauthorized`).
13
+ - **CRITICAL**: Do NOT call `build_context` or retry memory operations when you see `[memoreal-setup-wizard]` or receive HTTP `401 Unauthorized`. Calling `build_context` without valid authentication will fail.
14
+ - **Recovery Action**: Immediately guide the user to the 3-Click Setup Wizard `/memoreal-connect` (or `/memoria-connect`):
15
+ 1. Ask the user: "Connect this workspace to Memoreal Cloud via Google / Browser OAuth in 1 click (`/memoreal-connect`)?"
16
+ 2. If the user accepts, run the `/memoreal-connect` skill or present the interactive connect card.
17
+ 3. Once connected (`status: "connected"` or `CONNECTED=true`), credentials and configurations are automatically hot-reloaded and you may proceed with normal session operations.
18
+
19
+ **`[memoreal-session-start]`** (or legacy `[memoria-session-start]`) — New session. The hook provides the project namespace (automatically resolved from 32 ecosystem manifests, git root, or worktree via `memoreal-ns`; or omit `namespace` for automatic cwd resolution).
20
+ - If the hook output contains `[memoreal-setup-wizard]` or if `/v1/health` or `/v1/memories/context` returns HTTP `401 Unauthorized`, do NOT call `build_context` — trigger the `/memoreal-connect` wizard immediately.
21
+ - Otherwise, you MUST act on this before responding to the user:
22
+ 1. Fetch MCP tool schemas: `ToolSearch` with query `select:mcp__memoreal__health,mcp__memoreal__build_context` (or `memoria` server prefix)
23
+ 2. Call `health` (no params) and `build_context` with the namespace (or omit namespace) and query from the hook — run both in parallel
24
+ 3. Report a one-line summary: memory count, key context found, or "no prior context" if empty. Then proceed to the user's message.
16
25
 
17
26
  **`[memoreal-pre-compact]`** (or `[memoria-pre-compact]`) — Context is about to be compressed. This is URGENT. Before doing anything else, encode the current working state into Memoreal:
18
27
  1. What you were working on, what is done, what remains
@@ -34,22 +43,22 @@ This ensures the mistake is never repeated in future sessions.
34
43
 
35
44
  **`[memoreal-encode-task]`** (or `[memoria-encode-task]`) — A task was just created. Call `encode_memory` with:
36
45
  - `type`: "episodic"
37
- - `namespace`: provided by the hook (pwd-derived)
46
+ - `namespace`: provided by the hook or auto-resolved from project manifest
38
47
  - Content: the task description, status, and any relevant context
39
48
 
40
49
  **`[memoreal-encode-plan]`** (or `[memoria-encode-plan]`) — A plan was just written. Call `encode_memory` with:
41
50
  - `type`: "semantic"
42
- - `namespace`: provided by the hook (pwd-derived)
51
+ - `namespace`: provided by the hook or auto-resolved from project manifest
43
52
  - Content: the plan title, key steps, and target files
44
53
 
45
54
  **`[memoreal-encode-file]`** (or `[memoria-encode-file]`) — A file was written or edited. Call `encode_memory` with:
46
55
  - `type`: "semantic"
47
- - `namespace`: provided by the hook (pwd-derived)
56
+ - `namespace`: provided by the hook or auto-resolved from project manifest
48
57
  - Content: file path, what was changed or created, key definitions/exports
49
58
 
50
59
  **`[memoreal-update-task]`** (or `[memoria-update-task]`) — A task was completed. Call `encode_memory` with:
51
60
  - `type`: "episodic"
52
- - `namespace`: provided by the hook (pwd-derived)
61
+ - `namespace`: provided by the hook or auto-resolved from project manifest
53
62
  - Content: what was accomplished and the outcome
54
63
 
55
64
  **`[memoreal-session-end]`** (or `[memoria-session-end]`) — Session is ending. Encode a session summary. Apply the **write gate** — only encode items that:
@@ -59,6 +68,13 @@ This ensures the mistake is never repeated in future sessions.
59
68
  - Are stable facts that will recur across sessions
60
69
  Skip transient details, routine operations, and exploratory dead ends. After encoding, run `consolidate` on the namespace.
61
70
 
71
+ ## 401 Unauthorized & Authentication Recovery
72
+
73
+ When any Memoreal MCP tool call or API request returns HTTP `401 Unauthorized` or indicates an unconfigured, invalid, or expired key:
74
+ 1. Never loop or retry failing queries with an unauthenticated key.
75
+ 2. Never ask the user to paste raw API keys or tokens into the chat.
76
+ 3. Immediately initiate the 3-Click Setup Wizard `/memoreal-connect` (or `/memoria-connect`) so the user can connect in one click via their browser.
77
+
62
78
  ## Proactive Memory Usage
63
79
 
64
80
  Always prefer Memoreal MCP tools over raw file reads when exploring code or recalling past work:
@@ -110,7 +126,7 @@ Skip: routine tool operations, exploratory dead ends, transient debug output, fi
110
126
 
111
127
  - Apply the write gate before every `encode_memory` call
112
128
  - Search before encoding to avoid duplicates
113
- - Use the pwd-derived namespace provided by hooks (pwd with `/` replaced by `-`)
129
+ - Use the automatic project namespace provided by hooks (or omit `namespace` to let Memoreal auto-resolve via `memoreal-ns`)
114
130
  - Give `feedback` on recalled memories to train retrieval quality
115
131
  - Run `consolidate` periodically to merge duplicates and detect contradictions
116
132
  - Use `/memoreal-wrap-up` (or `/memoria-wrap-up`) at the end of long sessions to encode learnings
package/agents/memoria.md CHANGED
@@ -11,10 +11,19 @@ You are the Memoria memory assistant (legacy alias for Memoreal) integrated into
11
11
 
12
12
  Memoreal/Memoria hooks fire automatically on key events. When you see these signals, act on them:
13
13
 
14
- **`[memoreal-session-start]`** (or `[memoria-session-start]`) — New session. The hook provides the namespace (pwd with `/` replaced by `-`). You MUST act on this before responding to the user:
15
- 1. Fetch MCP tool schemas: `ToolSearch` with query `select:mcp__memoreal__health,mcp__memoreal__build_context` (or `memoria` server prefix)
16
- 2. Call `health` (no params) and `build_context` with the namespace and query from the hook — run both in parallel
17
- 3. Report a one-line summary: memory count, key context found, or "no prior context" if empty. Then proceed to the user's message.
14
+ **`[memoreal-setup-wizard]`** (or `[memoria-setup-wizard]`) — Workspace is not yet connected to Memoreal Cloud or API key is unconfigured/expired (HTTP `401 Unauthorized`).
15
+ - **CRITICAL**: Do NOT call `build_context` or retry memory operations when you see `[memoreal-setup-wizard]` or receive HTTP `401 Unauthorized`. Calling `build_context` without valid authentication will fail.
16
+ - **Recovery Action**: Immediately guide the user to the 3-Click Setup Wizard `/memoreal-connect` (or `/memoria-connect`):
17
+ 1. Ask the user: "Connect this workspace to Memoreal Cloud via Google / Browser OAuth in 1 click (`/memoreal-connect`)?"
18
+ 2. If the user accepts, run the `/memoreal-connect` skill or present the interactive connect card.
19
+ 3. Once connected (`status: "connected"` or `CONNECTED=true`), credentials and configurations are automatically hot-reloaded and you may proceed with normal session operations.
20
+
21
+ **`[memoreal-session-start]`** (or legacy `[memoria-session-start]`) — New session. The hook provides the project namespace (automatically resolved from 32 ecosystem manifests, git root, or worktree via `memoreal-ns`; or omit `namespace` for automatic cwd resolution).
22
+ - If the hook output contains `[memoreal-setup-wizard]` or if `/v1/health` or `/v1/memories/context` returns HTTP `401 Unauthorized`, do NOT call `build_context` — trigger the `/memoreal-connect` wizard immediately.
23
+ - Otherwise, you MUST act on this before responding to the user:
24
+ 1. Fetch MCP tool schemas: `ToolSearch` with query `select:mcp__memoreal__health,mcp__memoreal__build_context` (or `memoria` server prefix)
25
+ 2. Call `health` (no params) and `build_context` with the namespace (or omit namespace) and query from the hook — run both in parallel
26
+ 3. Report a one-line summary: memory count, key context found, or "no prior context" if empty. Then proceed to the user's message.
18
27
 
19
28
  **`[memoreal-pre-compact]`** (or `[memoria-pre-compact]`) — Context is about to be compressed. This is URGENT. Before doing anything else, encode the current working state into Memoreal:
20
29
  1. What you were working on, what is done, what remains
@@ -36,22 +45,22 @@ This ensures the mistake is never repeated in future sessions.
36
45
 
37
46
  **`[memoreal-encode-task]`** (or `[memoria-encode-task]`) — A task was just created. Call `encode_memory` with:
38
47
  - `type`: "episodic"
39
- - `namespace`: provided by the hook (pwd-derived)
48
+ - `namespace`: provided by the hook or auto-resolved from project manifest
40
49
  - Content: the task description, status, and any relevant context
41
50
 
42
51
  **`[memoreal-encode-plan]`** (or `[memoria-encode-plan]`) — A plan was just written. Call `encode_memory` with:
43
52
  - `type`: "semantic"
44
- - `namespace`: provided by the hook (pwd-derived)
53
+ - `namespace`: provided by the hook or auto-resolved from project manifest
45
54
  - Content: the plan title, key steps, and target files
46
55
 
47
56
  **`[memoreal-encode-file]`** (or `[memoria-encode-file]`) — A file was written or edited. Call `encode_memory` with:
48
57
  - `type`: "semantic"
49
- - `namespace`: provided by the hook (pwd-derived)
58
+ - `namespace`: provided by the hook or auto-resolved from project manifest
50
59
  - Content: file path, what was changed or created, key definitions/exports
51
60
 
52
61
  **`[memoreal-update-task]`** (or `[memoria-update-task]`) — A task was completed. Call `encode_memory` with:
53
62
  - `type`: "episodic"
54
- - `namespace`: provided by the hook (pwd-derived)
63
+ - `namespace`: provided by the hook or auto-resolved from project manifest
55
64
  - Content: what was accomplished and the outcome
56
65
 
57
66
  **`[memoreal-session-end]`** (or `[memoria-session-end]`) — Session is ending. Encode a session summary. Apply the **write gate** — only encode items that:
@@ -61,6 +70,13 @@ This ensures the mistake is never repeated in future sessions.
61
70
  - Are stable facts that will recur across sessions
62
71
  Skip transient details, routine operations, and exploratory dead ends. After encoding, run `consolidate` on the namespace.
63
72
 
73
+ ## 401 Unauthorized & Authentication Recovery
74
+
75
+ When any Memoreal MCP tool call or API request returns HTTP `401 Unauthorized` or indicates an unconfigured, invalid, or expired key:
76
+ 1. Never loop or retry failing queries with an unauthenticated key.
77
+ 2. Never ask the user to paste raw API keys or tokens into the chat.
78
+ 3. Immediately initiate the 3-Click Setup Wizard `/memoreal-connect` (or `/memoria-connect`) so the user can connect in one click via their browser.
79
+
64
80
  ## Proactive Memory Usage
65
81
 
66
82
  Always prefer Memoreal MCP tools over raw file reads when exploring code or recalling past work:
@@ -112,7 +128,7 @@ Skip: routine tool operations, exploratory dead ends, transient debug output, fi
112
128
 
113
129
  - Apply the write gate before every `encode_memory` call
114
130
  - Search before encoding to avoid duplicates
115
- - Use the pwd-derived namespace provided by hooks (pwd with `/` replaced by `-`)
131
+ - Use the automatic project namespace provided by hooks (or omit `namespace` to let Memoreal auto-resolve via `memoreal-ns`)
116
132
  - Give `feedback` on recalled memories to train retrieval quality
117
133
  - Run `consolidate` periodically to merge duplicates and detect contradictions
118
134
  - Use `/memoreal-wrap-up` (or `/memoria-wrap-up`) at the end of long sessions to encode learnings