memoryintelligence-mcp 0.2.4__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of memoryintelligence-mcp might be problematic. Click here for more details.

Files changed (23) hide show
  1. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/CHANGELOG.md +120 -0
  2. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/PKG-INFO +39 -7
  3. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/README.md +37 -5
  4. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/pyproject.toml +7 -2
  5. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/__init__.py +1 -1
  6. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/cli.py +83 -14
  7. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/client.py +87 -6
  8. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/config.py +47 -2
  9. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/server.py +382 -30
  10. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/.gitignore +0 -0
  11. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/CONTRIBUTING.md +0 -0
  12. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/LICENSE +0 -0
  13. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/__main__.py +0 -0
  14. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/embedder.py +0 -0
  15. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/indexer.py +0 -0
  16. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/keys.py +0 -0
  17. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/local_index.py +0 -0
  18. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/localreads.py +0 -0
  19. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/paths.py +0 -0
  20. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/recall_guard.py +0 -0
  21. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/scrub.py +0 -0
  22. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/umo_format.py +0 -0
  23. {memoryintelligence_mcp-0.2.4 → memoryintelligence_mcp-0.2.7}/src/mi_mcp/vault.py +0 -0
@@ -3,6 +3,126 @@
3
3
  All notable changes to `memoryintelligence-mcp` are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/); this project uses [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [0.2.7] — 2026-08-03
7
+
8
+ ### Added — `mi_ask` / `mi_list` take a `workspace_id` (#385 UC2)
9
+ Symmetric with `mi_capture` (one mental model: *omit = personal, pass an id = that
10
+ workspace*). Omit it and the read is personal, byte-for-byte as before — no wrapper,
11
+ no extra key, no extra round-trip. Pass a workspace you belong to and the read is
12
+ scoped to it; a workspace you do **not** belong to is refused rather than silently
13
+ downgraded to personal, so the scope a result reports is never a lie.
14
+
15
+ Two things specific to this surface:
16
+
17
+ - **A workspace read never comes from the on-device index.** `MI_MCP_LOCAL=1`
18
+ serves reads locally, and the local index has no workspace concept — answering
19
+ from it would return personal memories under a workspace label. A workspace
20
+ target forces the cloud path, the same way advanced filters already do.
21
+ - **The result says whether other members' memories are actually included.**
22
+ Server-side workspace read-isolation (`MI_WORKSPACE_READ_ISOLATION`) is **off by
23
+ default**, and with it off a member-targeted read returns exactly what a personal
24
+ read returns. The scope block therefore carries `member_wide_reads`
25
+ (`true` / `false` / `"unknown"`), read from the server's own `/health`
26
+ capabilities and cached per process. When it is not `true` on a multi-member
27
+ workspace the block also carries a `note` telling the agent not to claim it
28
+ searched the whole team. **Without this, `shared: true, member_count: 4` on an
29
+ owner-scoped read is an overclaim waiting to be repeated to a user.**
30
+
31
+ Requires an API server new enough to advertise
32
+ `capabilities.workspace_read_isolation` in `/health`; older servers report
33
+ `"unknown"` rather than a guess. The remote MCP surface reports the same field
34
+ (read directly from the flag, since it runs inside the API process), so both
35
+ surfaces describe a workspace read the same way.
36
+
37
+ ### Added — `mi_capture(workspace_id=…)` — workspace routing actually works (#385 UC1)
38
+ Routing a capture to a specific workspace was **documented as shipped and was not
39
+ implemented on this surface**. The backend has honored it since #736/#385 and the
40
+ REMOTE MCP sends it — but the local package had no way to *express* a target:
41
+ `mi_capture` had no `workspace_id` argument and `MIClient.capture()` sent no
42
+ routing header. `mi_workspaces` (added in 0.2.6) listed workspaces the tools then
43
+ could not capture into, and its description told agents to pass the workspace ULID
44
+ as `scope_id`, which routes nothing (`scope`/`scope_id` is the separate governance-scope
45
+ axis, sent in the request body). Now:
46
+
47
+ - **`mi_capture(content, workspace_id?, confirm?)`** routes the capture. Omit
48
+ `workspace_id` and the capture goes to your home workspace exactly as before —
49
+ personal is still the default, and an untargeted capture costs no extra API call.
50
+ - **A shared-workspace write is gated.** Targeting a workspace with more than one
51
+ member without `confirm=true` returns `{"status": "confirm_required", …}` and
52
+ **saves nothing** — a single silent call can never post a memory into a team
53
+ space. Solo and personal captures need no confirm.
54
+ - **Every routed capture names where it landed** — the response carries
55
+ `destination: {workspace_id, name, role, shared, member_count}`.
56
+ - **A workspace you are not a member of is refused, not silently downgraded** to
57
+ personal, so a reported destination is never a lie. Authorization itself stays
58
+ server-side; this mirrors it so the feedback is accurate.
59
+
60
+ This matches the remote surface's contract (`mi_capture` there already took
61
+ `workspace_id` + `confirm`), so both MCP surfaces now route captures identically.
62
+
63
+ Note on the wire: the target is sent as a **header**, and the API has two names for
64
+ it depending on the auth plane — `X-MI-Workspace` (API-key plane, which this package
65
+ uses) and `X-Workspace-Id` (JWT plane, what the remote sends). The client sends both,
66
+ so routing is correct on either plane.
67
+
68
+ ## [0.2.6] — 2026-08-03
69
+
70
+ ### Changed — the local server is now named `mi-local` (#1320)
71
+ The local stdio server announced itself as `Server("memoryintelligence")` and
72
+ `mi-mcp setup`/`wire` registered it under the config key `memoryintelligence` —
73
+ while the REMOTE MCP surface (`api.memoryintelligence.io/v1/mcp`) announces
74
+ `memoryintelligence-remote` but is typically added to claude.ai/Desktop under
75
+ the display name "memoryintelligence". On any client hosting both, the two
76
+ surfaces were indistinguishable and tool calls silently resolved to the wrong
77
+ one: during a 2026-08-02 debug, the local server's tools masqueraded as the
78
+ remote's, and `mi_workspaces` "didn't exist" because the remote was never
79
+ called. The local server now announces `mi-local` and wires under that key.
80
+
81
+ **Migration is automatic and guarded**: re-running `mi-mcp setup` or
82
+ `mi-mcp wire` renames an existing `memoryintelligence` (or pre-0.1.8
83
+ `memory-intelligence`) config entry to `mi-local` — but ONLY when that entry
84
+ points at the mi-mcp launcher (`run-mi-mcp.sh`, `python -m mi_mcp`, or the
85
+ `mi-mcp` binary). An identically-named entry pointing anywhere else is left
86
+ untouched. `mi-mcp doctor` detects a pending rename and tells you to run
87
+ `mi-mcp wire`. Idempotent — re-running is always safe.
88
+
89
+ Which server am I talking to? The local announces `mi-local` (7 tools by
90
+ default, 11 with `MI_MCP_FULL=1`); the remote announces
91
+ `memoryintelligence-remote` (4 tools).
92
+
93
+ ### Added — `mi_workspaces` (tool-surface parity with the remote, #1320)
94
+ The remote surface added `mi_workspaces` for workspace routing; the local
95
+ package now has it too, in the default surface: lists the workspaces you can
96
+ capture into (id, name, your role, member count) via `GET /v1/workspaces` —
97
+ the same endpoint the remote calls, so "does mi_workspaces exist" answers the
98
+ same on both surfaces. Default surface is now 7 tools; the full surface is 11.
99
+
100
+ ## [0.2.5] — 2026-07-24
101
+
102
+ ### Fixed — capture now works on Claude Desktop / claude.ai connector / Cowork
103
+ Capture (`mi_capture`/`mi_upload`) was silently blocked on GUI and remote
104
+ surfaces. The write-consent gate keys on the server's working directory, but
105
+ those launchers spawn the server at the filesystem root (`/`) with no project
106
+ folder — so the per-folder allowlist could never match, and running `mi-mcp
107
+ setup` in a project folder didn't help (the server isn't running from there).
108
+ Claude Desktop was already accommodated via a wired `MI_MCP_OPT_IN_ALL=1`, but
109
+ the claude.ai connector is configured outside `mi-mcp wire` and so had no way to
110
+ satisfy the gate at all.
111
+
112
+ Now the gate recognizes "no project working directory" (a root cwd) as a
113
+ **surface-level consent** case: capture is allowed and tagged with a
114
+ `claude-connector` provenance source, so it's identifiable. This mirrors the
115
+ existing Desktop behavior but is derived at runtime, so it covers every
116
+ GUI/remote surface automatically. Reads were never gated. Editor surfaces
117
+ (Code/Cursor launched inside a real folder) keep per-folder consent unchanged,
118
+ and `MI_MCP_STRICT_CWD=1` restores strict folder gating on every surface for
119
+ anyone who wants it. The blocked-capture message is now plain-language.
120
+
121
+ ### Changed — pinned the dev linter (`ruff==0.15.22`)
122
+ `[dev]` pulled the latest ruff, whose newer rules flagged pre-existing code and
123
+ reddened the public mirror's CI on every push. Pinned in lockstep with the
124
+ monorepo (#1163); no runtime effect.
125
+
6
126
  ## [0.2.4] — 2026-07-24
7
127
 
8
128
  Proof surface + recall trust + upload honesty. No setup change (no re-`wire` —
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memoryintelligence-mcp
3
- Version: 0.2.4
3
+ Version: 0.2.7
4
4
  Summary: MCP server for MemoryIntelligence — give Claude a memory you own, set up in one command
5
5
  Project-URL: Homepage, https://memoryintelligence.io
6
6
  Project-URL: Repository, https://github.com/somewhere11/memoryintelligence-mcp
@@ -30,7 +30,7 @@ Requires-Dist: fastembed<1.0,>=0.3.0; extra == 'dev'
30
30
  Requires-Dist: numpy<3,>=1.24; extra == 'dev'
31
31
  Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
32
32
  Requires-Dist: pytest>=8.0; extra == 'dev'
33
- Requires-Dist: ruff>=0.4.0; extra == 'dev'
33
+ Requires-Dist: ruff==0.15.22; extra == 'dev'
34
34
  Provides-Extra: local
35
35
  Requires-Dist: cryptography<46,>=42.0; extra == 'local'
36
36
  Requires-Dist: fastembed<1.0,>=0.3.0; extra == 'local'
@@ -86,10 +86,37 @@ And four things that make it more than a notepad:
86
86
  - **Owned** — memories are portable structured objects in *your* account, not locked in a model.
87
87
  - **Private** — capture is opt-in per project; PII is redacted from what the agent sees.
88
88
 
89
- > Set `MI_MCP_FULL=1` for the full surface (`mi_upload`, `mi_verify`, `mi_forget`,
89
+ > The default surface is 7 tools (also `mi_upload`, `mi_verify`, `mi_forget`,
90
+ > `mi_workspaces`). Set `MI_MCP_FULL=1` for the full 11-tool surface (adds
90
91
  > `mi_batch`, `mi_explain`, `mi_match`, `mi_account`). Tools outside the active
91
92
  > surface are rejected at the call boundary, not just hidden.
92
93
 
94
+ ### Capturing into a shared workspace
95
+
96
+ By default every capture is **personal** — it lands in your home workspace and
97
+ nobody else sees it. To put one in a team space, name it:
98
+
99
+ > *"List my workspaces."* → `mi_workspaces`
100
+ > *"Save that to Somewhere Inc."* → `mi_capture(workspace_id=…)`
101
+
102
+ Two rules keep a shared space from filling up by accident:
103
+
104
+ - **A workspace with more than one member needs an explicit confirm.** The first
105
+ call returns a preview — *"this posts to Somewhere Inc, visible to 4 members"* —
106
+ and **saves nothing**. Only after you say yes does the agent re-call with
107
+ `confirm=true`. A fresh chat can't inherit that approval.
108
+ - **Every capture tells you where it went**, and a workspace you don't belong to is
109
+ refused rather than quietly saved somewhere else.
110
+
111
+ Reading works the same way — `mi_ask` and `mi_list` take the same `workspace_id`:
112
+
113
+ > *"What did the team decide about billing?"* → `mi_ask(workspace_id=…)`
114
+
115
+ Omit it and you search your own memories. One caveat worth knowing: whether a
116
+ workspace read returns *other members'* memories is a server-side setting that is
117
+ **off by default**. The result's `scope` block reports `member_wide_reads` so the
118
+ assistant can tell you what it actually searched instead of assuming.
119
+
93
120
  ## How it works
94
121
 
95
122
  ```
@@ -132,7 +159,7 @@ and never leaves your machine except to authenticate.
132
159
  redacts PII from what the agent sees (your own portal shows it raw).
133
160
  - **stdio only — no open port.** Runs as a local subprocess; networked transports are
134
161
  disabled in this version (they return with OAuth 2.1 + TLS later).
135
- - **Off switch.** Clear `opt-in-paths`, or remove the `memoryintelligence` entry from
162
+ - **Off switch.** Clear `opt-in-paths`, or remove the `mi-local` entry from
136
163
  your config to fully unwire.
137
164
 
138
165
  Found a vulnerability? [SECURITY.md](SECURITY.md) — report privately to connect@somewheremedia.com.
@@ -147,7 +174,7 @@ Found a vulnerability? [SECURITY.md](SECURITY.md) — report privately to connec
147
174
  |----------|---------|-------------|
148
175
  | `MI_API_KEY` | — | Resolved by the launcher from Keychain / keyfile — don't set inline in configs |
149
176
  | `MI_BASE_URL` | `https://api.memoryintelligence.io` | API base URL |
150
- | `MI_MCP_FULL` | _(off)_ | `1` exposes all 10 tools; otherwise the 3 core |
177
+ | `MI_MCP_FULL` | _(off)_ | `1` exposes all 11 tools; otherwise the 7-tool default surface |
151
178
  | `MI_VAULT` | `~/Somewhere` (set by `wire`) | Local `.umo` vault — `wire`/`setup` point it at `~/Somewhere` so it's shared with the MemorySpace Desktop app. Unwired fallback is `~/MemoryIntelligence`; an explicit value here always wins. |
152
179
  | `MI_DEFAULT_SCOPE` · `MI_DEFAULT_RETENTION` · `MI_DEFAULT_PII_HANDLING` | `user` · `meaning_only` · `extract_and_redact` | Governance defaults |
153
180
 
@@ -158,7 +185,7 @@ Found a vulnerability? [SECURITY.md](SECURITY.md) — report privately to connec
158
185
  | `MemoryIntelligence` | the brand |
159
186
  | `memoryintelligence-mcp` | the PyPI package (`pip install`) |
160
187
  | `mi-mcp` | the command you run (`mi-mcp setup`) |
161
- | `memoryintelligence` | the server id in your MCP config |
188
+ | `mi-local` | the server id in your MCP config — distinct from the REMOTE MCP surface, which announces `memoryintelligence-remote` (#1320). `memoryintelligence` (≤0.2.5) is legacy; `mi-mcp wire` renames it |
162
189
  | `MI_*` | env vars / Keychain service |
163
190
 
164
191
  **On disk** — one namespace:
@@ -199,6 +226,11 @@ mi-mcp doctor # checks binary, PATH, key, wiring, opt-in, vault path
199
226
  mi-mcp status # wired surfaces + opt-in allowlist
200
227
  mi-mcp wire --dry-run # preview wiring changes
201
228
  ```
229
+
230
+ **Which server am I talking to?** The local server announces `mi-local`; the
231
+ remote MCP surface announces `memoryintelligence-remote`. The local default
232
+ surface is 7 tools; the remote is 4 — if the tool list doesn't match what you
233
+ expect, the client resolved the other surface (#1320).
202
234
  </details>
203
235
 
204
236
  <details>
@@ -209,7 +241,7 @@ VS Code / Copilot read a different config than Claude: servers live under `"serv
209
241
  it, or add per-workspace `.vscode/mcp.json`:
210
242
 
211
243
  ```json
212
- { "servers": { "memoryintelligence": { "type": "stdio", "command": "mi-mcp" } } }
244
+ { "servers": { "mi-local": { "type": "stdio", "command": "mi-mcp" } } }
213
245
  ```
214
246
 
215
247
  Then open Copilot Chat in **Agent** mode — the memory tools only appear there.
@@ -47,10 +47,37 @@ And four things that make it more than a notepad:
47
47
  - **Owned** — memories are portable structured objects in *your* account, not locked in a model.
48
48
  - **Private** — capture is opt-in per project; PII is redacted from what the agent sees.
49
49
 
50
- > Set `MI_MCP_FULL=1` for the full surface (`mi_upload`, `mi_verify`, `mi_forget`,
50
+ > The default surface is 7 tools (also `mi_upload`, `mi_verify`, `mi_forget`,
51
+ > `mi_workspaces`). Set `MI_MCP_FULL=1` for the full 11-tool surface (adds
51
52
  > `mi_batch`, `mi_explain`, `mi_match`, `mi_account`). Tools outside the active
52
53
  > surface are rejected at the call boundary, not just hidden.
53
54
 
55
+ ### Capturing into a shared workspace
56
+
57
+ By default every capture is **personal** — it lands in your home workspace and
58
+ nobody else sees it. To put one in a team space, name it:
59
+
60
+ > *"List my workspaces."* → `mi_workspaces`
61
+ > *"Save that to Somewhere Inc."* → `mi_capture(workspace_id=…)`
62
+
63
+ Two rules keep a shared space from filling up by accident:
64
+
65
+ - **A workspace with more than one member needs an explicit confirm.** The first
66
+ call returns a preview — *"this posts to Somewhere Inc, visible to 4 members"* —
67
+ and **saves nothing**. Only after you say yes does the agent re-call with
68
+ `confirm=true`. A fresh chat can't inherit that approval.
69
+ - **Every capture tells you where it went**, and a workspace you don't belong to is
70
+ refused rather than quietly saved somewhere else.
71
+
72
+ Reading works the same way — `mi_ask` and `mi_list` take the same `workspace_id`:
73
+
74
+ > *"What did the team decide about billing?"* → `mi_ask(workspace_id=…)`
75
+
76
+ Omit it and you search your own memories. One caveat worth knowing: whether a
77
+ workspace read returns *other members'* memories is a server-side setting that is
78
+ **off by default**. The result's `scope` block reports `member_wide_reads` so the
79
+ assistant can tell you what it actually searched instead of assuming.
80
+
54
81
  ## How it works
55
82
 
56
83
  ```
@@ -93,7 +120,7 @@ and never leaves your machine except to authenticate.
93
120
  redacts PII from what the agent sees (your own portal shows it raw).
94
121
  - **stdio only — no open port.** Runs as a local subprocess; networked transports are
95
122
  disabled in this version (they return with OAuth 2.1 + TLS later).
96
- - **Off switch.** Clear `opt-in-paths`, or remove the `memoryintelligence` entry from
123
+ - **Off switch.** Clear `opt-in-paths`, or remove the `mi-local` entry from
97
124
  your config to fully unwire.
98
125
 
99
126
  Found a vulnerability? [SECURITY.md](SECURITY.md) — report privately to connect@somewheremedia.com.
@@ -108,7 +135,7 @@ Found a vulnerability? [SECURITY.md](SECURITY.md) — report privately to connec
108
135
  |----------|---------|-------------|
109
136
  | `MI_API_KEY` | — | Resolved by the launcher from Keychain / keyfile — don't set inline in configs |
110
137
  | `MI_BASE_URL` | `https://api.memoryintelligence.io` | API base URL |
111
- | `MI_MCP_FULL` | _(off)_ | `1` exposes all 10 tools; otherwise the 3 core |
138
+ | `MI_MCP_FULL` | _(off)_ | `1` exposes all 11 tools; otherwise the 7-tool default surface |
112
139
  | `MI_VAULT` | `~/Somewhere` (set by `wire`) | Local `.umo` vault — `wire`/`setup` point it at `~/Somewhere` so it's shared with the MemorySpace Desktop app. Unwired fallback is `~/MemoryIntelligence`; an explicit value here always wins. |
113
140
  | `MI_DEFAULT_SCOPE` · `MI_DEFAULT_RETENTION` · `MI_DEFAULT_PII_HANDLING` | `user` · `meaning_only` · `extract_and_redact` | Governance defaults |
114
141
 
@@ -119,7 +146,7 @@ Found a vulnerability? [SECURITY.md](SECURITY.md) — report privately to connec
119
146
  | `MemoryIntelligence` | the brand |
120
147
  | `memoryintelligence-mcp` | the PyPI package (`pip install`) |
121
148
  | `mi-mcp` | the command you run (`mi-mcp setup`) |
122
- | `memoryintelligence` | the server id in your MCP config |
149
+ | `mi-local` | the server id in your MCP config — distinct from the REMOTE MCP surface, which announces `memoryintelligence-remote` (#1320). `memoryintelligence` (≤0.2.5) is legacy; `mi-mcp wire` renames it |
123
150
  | `MI_*` | env vars / Keychain service |
124
151
 
125
152
  **On disk** — one namespace:
@@ -160,6 +187,11 @@ mi-mcp doctor # checks binary, PATH, key, wiring, opt-in, vault path
160
187
  mi-mcp status # wired surfaces + opt-in allowlist
161
188
  mi-mcp wire --dry-run # preview wiring changes
162
189
  ```
190
+
191
+ **Which server am I talking to?** The local server announces `mi-local`; the
192
+ remote MCP surface announces `memoryintelligence-remote`. The local default
193
+ surface is 7 tools; the remote is 4 — if the tool list doesn't match what you
194
+ expect, the client resolved the other surface (#1320).
163
195
  </details>
164
196
 
165
197
  <details>
@@ -170,7 +202,7 @@ VS Code / Copilot read a different config than Claude: servers live under `"serv
170
202
  it, or add per-workspace `.vscode/mcp.json`:
171
203
 
172
204
  ```json
173
- { "servers": { "memoryintelligence": { "type": "stdio", "command": "mi-mcp" } } }
205
+ { "servers": { "mi-local": { "type": "stdio", "command": "mi-mcp" } } }
174
206
  ```
175
207
 
176
208
  Then open Copilot Chat in **Agent** mode — the memory tools only appear there.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "memoryintelligence-mcp"
7
- version = "0.2.4"
7
+ version = "0.2.7"
8
8
  description = "MCP server for MemoryIntelligence — give Claude a memory you own, set up in one command"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -50,7 +50,12 @@ local = [
50
50
  dev = [
51
51
  "pytest>=8.0",
52
52
  "pytest-asyncio>=0.24",
53
- "ruff>=0.4.0",
53
+ # Pinned, matching the monorepo (#1163): an unpinned ruff pulls the latest
54
+ # release, and 0.16 turned on rules (e.g. PLW1510) that flag pre-existing
55
+ # code the shipped `ruff check src/` never linted before — reddening the
56
+ # public mirror's CI on every push. Bump deliberately, in lockstep with the
57
+ # monorepo, never implicitly.
58
+ "ruff==0.15.22",
54
59
  "cryptography>=42.0,<46",
55
60
  "numpy>=1.24,<3",
56
61
  "fastembed>=0.3.0,<1.0",
@@ -1,3 +1,3 @@
1
1
  """MI MCP Server — MemoryIntelligence tools for Claude."""
2
2
 
3
- __version__ = "0.2.4"
3
+ __version__ = "0.2.7"
@@ -41,11 +41,39 @@ from pathlib import Path
41
41
  from . import __version__, paths
42
42
  from .config import load_opt_in_paths
43
43
 
44
- SERVER_KEY = "memoryintelligence"
45
- # Pre-0.1.8 server ids we replace on wire so an upgrade leaves no orphaned entry.
46
- # (0.1.7 and earlier registered the server as "memory-intelligence" — the one
47
- # dash-seam that didn't match the brand/package "memoryintelligence".)
48
- LEGACY_SERVER_KEYS = ("memory-intelligence",)
44
+ # "mi-local" (#1320): the local stdio server's config id. It was
45
+ # "memoryintelligence" through 0.2.5, which collided with the REMOTE MCP surface
46
+ # (announced "memoryintelligence-remote" but added to claude.ai/Desktop under the
47
+ # display name "memoryintelligence") — on a client hosting both, the two were
48
+ # indistinguishable and tool calls silently resolved to the wrong surface.
49
+ SERVER_KEY = "mi-local"
50
+ # Older server ids we migrate on wire so an upgrade leaves no orphaned entry:
51
+ # "memoryintelligence" — 0.1.8 … 0.2.5 (renamed to "mi-local" in 0.2.6, #1320)
52
+ # "memory-intelligence" — 0.1.7 and earlier
53
+ # Migration is GUARDED: an entry under a legacy id is only removed/renamed when it
54
+ # actually points at the mi-mcp launcher (see _is_mi_launcher_entry) — an entry a
55
+ # user pointed elsewhere (e.g. a remote connector they named "memoryintelligence")
56
+ # is never touched.
57
+ LEGACY_SERVER_KEYS = ("memoryintelligence", "memory-intelligence")
58
+
59
+
60
+ def _is_mi_launcher_entry(entry: object) -> bool:
61
+ """True when a client-config server entry points at OUR launcher.
62
+
63
+ Recognizes every shape mi-mcp has ever written: the run-mi-mcp.sh wrapper
64
+ (Code/Cursor/VS Code), the sandbox-safe ``python -m mi_mcp`` Desktop entry,
65
+ and a bare ``mi-mcp`` binary path. Anything else is not ours to migrate.
66
+ """
67
+ if not isinstance(entry, dict):
68
+ return False
69
+ blob = " ".join(
70
+ [str(entry.get("command", "")), *(str(a) for a in (entry.get("args") or []))]
71
+ )
72
+ return (
73
+ "run-mi-mcp" in blob
74
+ or "mi_mcp" in blob
75
+ or blob.rstrip().endswith("mi-mcp")
76
+ )
49
77
 
50
78
  # Wrapper rendered by `wire`. __MI_MCP_BIN__ is replaced with the absolute path
51
79
  # to the mi-mcp binary (resolved at wire time) so the host can spawn it even
@@ -187,9 +215,18 @@ def _wire_code_via_cli(home: Path, wrapper: Path, dry_run: bool) -> bool:
187
215
  print(f" would run: {' '.join(add_cmd)}")
188
216
  return True
189
217
  # idempotent + migrate: drop any existing entry — current id AND the legacy
190
- # pre-0.1.8 ids — before re-adding, so an upgrade leaves no orphan.
191
- for key in (SERVER_KEY, *LEGACY_SERVER_KEYS):
192
- subprocess.run([claude, "mcp", "remove", key], capture_output=True, text=True)
218
+ # ids — before re-adding, so an upgrade leaves no orphan. Legacy ids are only
219
+ # removed when `claude mcp get` shows they point at OUR launcher (#1320): a
220
+ # server the user registered under "memoryintelligence" that isn't mi-mcp
221
+ # (e.g. the remote connector) must not be deleted out from under them.
222
+ subprocess.run([claude, "mcp", "remove", SERVER_KEY], capture_output=True, text=True)
223
+ for key in LEGACY_SERVER_KEYS:
224
+ g = subprocess.run([claude, "mcp", "get", key], capture_output=True, text=True)
225
+ blob = (g.stdout or "") + (g.stderr or "")
226
+ # "mi-mcp" also matches the wrapper's "run-mi-mcp.sh".
227
+ if g.returncode == 0 and ("mi-mcp" in blob or "mi_mcp" in blob):
228
+ subprocess.run([claude, "mcp", "remove", key], capture_output=True, text=True)
229
+ print(f" migrated legacy id {key} → {SERVER_KEY}")
193
230
  r = subprocess.run(add_cmd, capture_output=True, text=True)
194
231
  if r.returncode != 0:
195
232
  print(f" ! claude mcp add failed ({r.stderr.strip()[:160]}); falling back to file")
@@ -303,17 +340,39 @@ def do_wire(home: Path, surfaces: list[str], dry_run: bool,
303
340
  cfg_key = _surface_key(s)
304
341
  cfg = _load_json(cfg_path)
305
342
  servers = cfg.setdefault(cfg_key, {})
306
- # Migrate: drop any pre-0.1.8 id (e.g. "memory-intelligence") so the
307
- # rename to "memoryintelligence" doesn't leave a duplicate/orphan entry.
308
- migrated = [k for k in LEGACY_SERVER_KEYS if servers.pop(k, None) is not None]
343
+ # Migrate: drop any legacy id ("memoryintelligence" ≤0.2.5, or the
344
+ # pre-0.1.8 "memory-intelligence") so the rename to "mi-local" (#1320)
345
+ # doesn't leave a duplicate/orphan entry. GUARDED: only entries that
346
+ # point at the mi-mcp launcher are ours to migrate — a legacy-named
347
+ # entry the user pointed elsewhere is left exactly as it is.
348
+ migrated, foreign = [], []
349
+ # Keep the first migrated entry's contents: a ≤0.2.5 user's overrides
350
+ # (MI_VAULT, MI_MCP_OPT_IN_ALL) live under the LEGACY key, and the
351
+ # desktop branch below reads `prior` to preserve exactly those. Popping
352
+ # without remembering silently reset them on upgrade (Copilot, #1326).
353
+ legacy_prior = None
354
+ for k in LEGACY_SERVER_KEYS:
355
+ if k not in servers:
356
+ continue
357
+ if _is_mi_launcher_entry(servers[k]):
358
+ popped = servers.pop(k)
359
+ if legacy_prior is None:
360
+ legacy_prior = popped
361
+ migrated.append(k)
362
+ else:
363
+ foreign.append(k)
309
364
  if migrated:
310
365
  print(f" {s:8} migrated id {', '.join(migrated)} → {SERVER_KEY}")
366
+ if foreign:
367
+ print(f" {s:8} left {', '.join(foreign)} untouched — not an mi-mcp launcher entry")
311
368
  # Build this surface's entry. capture_anywhere is tri-state: True enables,
312
369
  # False disables, None preserves the current setting (so a plain re-wire
313
370
  # never silently flips a capture choice the user made).
314
371
  env: dict[str, str] = {}
315
372
  if s == "desktop":
316
- prior = servers.get(SERVER_KEY)
373
+ # A mi-local entry wins; else the legacy entry we just migrated —
374
+ # so a ≤0.2.5 upgrade carries its env forward instead of resetting it.
375
+ prior = servers.get(SERVER_KEY) or legacy_prior
317
376
  prior_env = prior.get("env") if isinstance(prior, dict) else None
318
377
  # D7: point the local .umo vault at the MemorySpace Desktop vault (~/Somewhere) so
319
378
  # both surfaces resolve ONE vault. The shell wrapper used to set this at launch;
@@ -465,10 +524,20 @@ def cmd_doctor(argv: list[str]) -> int:
465
524
  for s, p in _surface_paths(home).items():
466
525
  servers = _load_json(p).get(_surface_key(s), {})
467
526
  wired = SERVER_KEY in servers
468
- legacy = [k for k in LEGACY_SERVER_KEYS if k in servers]
527
+ # #1320 migration detection: a legacy id ("memoryintelligence" ≤0.2.5,
528
+ # "memory-intelligence" ≤0.1.7) counts only when its entry actually points
529
+ # at the mi-mcp launcher — an identically-named entry the user pointed at
530
+ # something else (e.g. the remote connector) is not ours and is ignored.
531
+ legacy = [
532
+ k for k in LEGACY_SERVER_KEYS
533
+ if k in servers and _is_mi_launcher_entry(servers[k])
534
+ ]
469
535
  detail = str(p) if wired else "(not wired)"
470
536
  if legacy and not wired:
471
- detail = f"legacy id {', '.join(legacy)} present — run `mi-mcp wire` to migrate"
537
+ detail = (f"legacy id {', '.join(legacy)} points at the mi-mcp launcher — "
538
+ f"run `mi-mcp wire` to rename it to {SERVER_KEY} (#1320)")
539
+ elif legacy:
540
+ detail += f" (stale legacy id {', '.join(legacy)} also present — `mi-mcp wire` cleans it up)"
472
541
  check(f"{s} wired", wired, detail, critical=False)
473
542
 
474
543
  # #1135 — the escalated-user failure this check exists to catch in ONE
@@ -124,9 +124,13 @@ class MIClient:
124
124
  json: dict | None = None,
125
125
  params: dict | None = None,
126
126
  idempotent: bool = False,
127
+ headers: dict[str, str] | None = None,
127
128
  ) -> dict[str, Any]:
128
129
  """Make an API request and return the JSON response.
129
130
 
131
+ ``headers`` are merged over the client's defaults for this one request
132
+ (used by the workspace-routing headers — see ``_workspace_headers``).
133
+
130
134
  Idempotent reads (ask/list/explain/verify/match/account_info) are retried
131
135
  on a read timeout or a transient 5xx, with exponential backoff. The hosted
132
136
  API can intermittently cold-start or saturate
@@ -140,7 +144,9 @@ class MIClient:
140
144
  for attempt in range(attempts):
141
145
  is_last = attempt + 1 >= attempts
142
146
  try:
143
- resp = await self._http.request(method, path, json=json, params=params)
147
+ resp = await self._http.request(
148
+ method, path, json=json, params=params, headers=headers
149
+ )
144
150
  except httpx.TimeoutException:
145
151
  if is_last:
146
152
  raise
@@ -169,6 +175,30 @@ class MIClient:
169
175
 
170
176
  # ----- Core operations -----
171
177
 
178
+ @staticmethod
179
+ def _workspace_headers(workspace_id: str | None) -> dict[str, str] | None:
180
+ """Headers that route a request to a specific workspace (#385 UC1).
181
+
182
+ BOTH names are sent on purpose — the API has two headers for this one
183
+ concept, and which one is honored depends on the auth plane:
184
+
185
+ * ``X-MI-Workspace`` — the API-KEY plane (``deps.py::get_api_key``, #736).
186
+ This is the one that matters for this package, which always authenticates
187
+ with an ``mi_sk_*`` / ``mi_beta_*`` key.
188
+ * ``X-Workspace-Id`` — the JWT plane (``deps.py::get_api_key_or_jwt``),
189
+ which is what the REMOTE MCP surface (``api/public/mcp_resource.py``)
190
+ sends. ``get_api_key_or_jwt`` forwards only ``X-MI-Workspace`` down to
191
+ ``get_api_key``, so a key-authenticated ``X-Workspace-Id`` is IGNORED.
192
+
193
+ Sending both means routing is correct on either plane instead of silently
194
+ no-op'ing if this client is ever pointed at a JWT-authenticated deployment.
195
+ The unhonored name is inert, and both planes fail CLOSED (403) on a
196
+ workspace the caller is not a member of — enforcement stays server-side.
197
+ """
198
+ if not workspace_id:
199
+ return None
200
+ return {"X-MI-Workspace": workspace_id, "X-Workspace-Id": workspace_id}
201
+
172
202
  async def capture(
173
203
  self,
174
204
  content: str,
@@ -176,6 +206,7 @@ class MIClient:
176
206
  source: str | None = None,
177
207
  scope: str | None = None,
178
208
  scope_id: str | None = None,
209
+ workspace_id: str | None = None,
179
210
  retention_policy: str | None = None,
180
211
  pii_handling: str | None = None,
181
212
  metadata: dict | None = None,
@@ -188,6 +219,14 @@ class MIClient:
188
219
  capture persists as a parent + one child per claim, each independently
189
220
  recallable. Short single-claim captures stay a single UMO (the server's
190
221
  <=1-claim guard), so this is safe to leave on by default.
222
+
223
+ ``workspace_id`` (#385 UC1) routes the capture to a specific workspace via
224
+ the routing headers. Omit it and the capture goes to the caller's HOME
225
+ workspace (the server's agent-source home-binding), which is personal for
226
+ most users. The server validates membership and 403s a workspace the caller
227
+ does not belong to — this client cannot route anywhere it shouldn't.
228
+ ``scope``/``scope_id`` are a DIFFERENT axis (governance scope in the request
229
+ body); they do not route between workspaces.
191
230
  """
192
231
  payload: dict[str, Any] = {
193
232
  "content": content,
@@ -210,7 +249,10 @@ class MIClient:
210
249
  if metadata:
211
250
  payload["metadata"] = metadata
212
251
 
213
- return await self._request("POST", "/v1/process", json=payload)
252
+ return await self._request(
253
+ "POST", "/v1/process", json=payload,
254
+ headers=self._workspace_headers(workspace_id),
255
+ )
214
256
 
215
257
  async def ask(
216
258
  self,
@@ -218,6 +260,7 @@ class MIClient:
218
260
  *,
219
261
  scope: str | None = None,
220
262
  scope_id: str | None = None,
263
+ workspace_id: str | None = None,
221
264
  limit: int = 10,
222
265
  offset: int = 0,
223
266
  explain: str | bool = "none",
@@ -226,7 +269,13 @@ class MIClient:
226
269
  topics: list[str] | None = None,
227
270
  entities: list[str] | None = None,
228
271
  ) -> dict[str, Any]:
229
- """POST /v1/memories/query — semantic search across memories."""
272
+ """POST /v1/memories/query — semantic search across memories.
273
+
274
+ ``workspace_id`` (#385 UC2) targets a workspace you are a member of; omit
275
+ for personal (owner-scoped) search. Same routing headers as capture. Note
276
+ the server only *widens* the read to every member's memories when its
277
+ workspace read-isolation flag is on — see ``health()``.
278
+ """
230
279
  payload: dict[str, Any] = {
231
280
  "query": query,
232
281
  "scope": scope or self._config.default_scope,
@@ -253,7 +302,8 @@ class MIClient:
253
302
  payload["entities"] = entities
254
303
 
255
304
  return await self._request(
256
- "POST", "/v1/memories/query", json=payload, idempotent=True
305
+ "POST", "/v1/memories/query", json=payload, idempotent=True,
306
+ headers=self._workspace_headers(workspace_id),
257
307
  )
258
308
 
259
309
  async def list_memories(
@@ -262,12 +312,33 @@ class MIClient:
262
312
  limit: int = 20,
263
313
  offset: int = 0,
264
314
  scope: str | None = None,
315
+ workspace_id: str | None = None,
265
316
  ) -> dict[str, Any]:
266
- """GET /v1/memories — list UMOs with pagination."""
317
+ """GET /v1/memories — list UMOs with pagination.
318
+
319
+ ``workspace_id`` (#385 UC2) targets a workspace you are a member of; omit
320
+ for personal. See :meth:`ask` for the read-isolation caveat.
321
+ """
267
322
  params: dict[str, Any] = {"limit": limit, "offset": offset}
268
323
  if scope:
269
324
  params["scope"] = scope
270
- return await self._request("GET", "/v1/memories", params=params, idempotent=True)
325
+ return await self._request(
326
+ "GET", "/v1/memories", params=params, idempotent=True,
327
+ headers=self._workspace_headers(workspace_id),
328
+ )
329
+
330
+ async def health(self) -> dict[str, Any]:
331
+ """GET /health — server status + capability discovery.
332
+
333
+ Used for one thing here: reading
334
+ ``capabilities.workspace_read_isolation.enabled``, which decides whether a
335
+ workspace-targeted READ actually returns every member's memories or only
336
+ the caller's own. Without it a workspace read looks successful and
337
+ identical to a personal one, and any "searched the team workspace" claim
338
+ would be unverifiable. Unauthenticated on the server side; we send the
339
+ client's normal headers anyway (harmless).
340
+ """
341
+ return await self._request("GET", "/health", idempotent=True)
271
342
 
272
343
  async def explain(self, umo_id: str, *, level: str = "full") -> dict[str, Any]:
273
344
  """GET /v1/memories/{id}/explain — UMO introspection."""
@@ -378,3 +449,13 @@ class MIClient:
378
449
  async def account_info(self) -> dict[str, Any]:
379
450
  """GET /v1/accounts/me — get current account info and key status."""
380
451
  return await self._request("GET", "/v1/accounts/me", idempotent=True)
452
+
453
+ async def workspaces(self) -> dict[str, Any]:
454
+ """GET /v1/workspaces — list the caller's workspaces (mi_workspaces, #1320).
455
+
456
+ Returns ``{"workspaces": [...], "count": N}`` where each entry carries
457
+ id, name, the caller's role, and member_count — the routing directory
458
+ for workspace-targeted captures. Same endpoint the remote MCP surface's
459
+ mi_workspaces calls, so both surfaces answer identically.
460
+ """
461
+ return await self._request("GET", "/v1/workspaces", idempotent=True)