memoryintelligence-mcp 0.2.11__tar.gz → 0.2.14__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 (24) hide show
  1. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/CHANGELOG.md +122 -0
  2. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/PKG-INFO +17 -3
  3. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/README.md +14 -0
  4. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/pyproject.toml +4 -3
  5. memoryintelligence_mcp-0.2.14/src/mi_mcp/__init__.py +32 -0
  6. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/__main__.py +11 -4
  7. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/cli.py +75 -4
  8. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/local_index.py +37 -5
  9. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/server.py +21 -2
  10. memoryintelligence_mcp-0.2.11/src/mi_mcp/__init__.py +0 -3
  11. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/.gitignore +0 -0
  12. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/CONTRIBUTING.md +0 -0
  13. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/LICENSE +0 -0
  14. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/client.py +0 -0
  15. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/config.py +0 -0
  16. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/embedder.py +0 -0
  17. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/indexer.py +0 -0
  18. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/keys.py +0 -0
  19. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/localreads.py +0 -0
  20. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/paths.py +0 -0
  21. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/recall_guard.py +0 -0
  22. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/scrub.py +0 -0
  23. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/umo_format.py +0 -0
  24. {memoryintelligence_mcp-0.2.11 → memoryintelligence_mcp-0.2.14}/src/mi_mcp/vault.py +0 -0
@@ -3,6 +3,128 @@
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.14] — 2026-10-19 — FINAL RELEASE
7
+
8
+ ### Deprecated — this package is retired; 0.2.14 is its last release (#2186)
9
+
10
+ `[KASEY-STATED 2026-09-18, release decided 2026-10-19]` `mi-local` — this package — is
11
+ retired. It keeps working exactly as it does today, but it receives no further updates,
12
+ fixes, or tools. Nothing is removed in this release; the deprecation is a **signal**, not a
13
+ cut.
14
+
15
+ **What replaces it**
16
+
17
+ - **On your computer:** the MemoryIntelligence desktop app's built-in MCP server
18
+ (*Connect Claude* inside the app). It sees everything you connect to MI — including
19
+ sources this package never could, such as Drive imports — and it enforces the
20
+ per-category disclosure you choose there. This package's redaction is pattern-matched
21
+ PII; the desktop's is the choice you actually made.
22
+ - **On the web and phone:** the claude.ai **MemoryIntelligence** connector (the remote
23
+ MCP served by the API).
24
+
25
+ **What you will see**
26
+
27
+ Every start of the server, and every `mi-mcp setup` / `mi-mcp doctor`, prints one line to
28
+ **stderr** (never stdout — stdout is the MCP transport):
29
+
30
+ ```
31
+ [mi-mcp] DEPRECATED: mi-mcp (mi-local) is DEPRECATED and 0.2.14 is its final release. It keeps working, but receives no further updates. Use the MemoryIntelligence desktop app's built-in MCP (Connect Claude) on your computer, or the claude.ai MemoryIntelligence connector on the web and phone. Details: https://github.com/somewhere11/MemoryIntelligence/issues/2186
32
+ ```
33
+
34
+ In a host that shows MCP logs (Claude Desktop's MCP log, Claude Code's `--mcp-debug`) that
35
+ line appears on each connection. The PyPI listing carries `Development Status :: 7 -
36
+ Inactive` and the same sentence in its summary; `server.json` says the same to the MCP
37
+ registry.
38
+
39
+ **Why a final release at all, rather than silence:** the package already on PyPI (0.2.13)
40
+ would otherwise keep being installed from docs and search results with no signal that it
41
+ is going away — the exact "nobody who has it configured ever sees the notice" failure
42
+ #2186 names. The two changes below had also landed on `main` under 0.2.14 without
43
+ shipping, which is the version-drift mode #2186 exists to end; this release closes it.
44
+
45
+ ### Added — `mi_ask` reports whether your memory can answer at all (#1117)
46
+
47
+ `mi_ask` results now carry `answerable` (boolean) at the envelope level, with
48
+ `top_similarity` beside it when the API provides one. Every hit already carried a
49
+ `score`, but on the cross-encoder scale most read `0.0`, so a junk row and a good row
50
+ looked identical to a reading model. `answerable` is the one field that separates them.
51
+ It is **advisory**: the rows are still returned and may be cited; this says what MI thinks,
52
+ it does not withhold.
53
+
54
+ ### Added — memories carry their stored title (#2258)
55
+
56
+ `mi_ask` and `mi_list` results include `title` on a memory and `memory_title` on a claim
57
+ (the title of the memory it was cut from), when the API has one. The API now stores one
58
+ title per memory (migration 079) instead of each surface inventing a label.
59
+
60
+ ### Not changed — large captures can still time out on the client (#1669)
61
+
62
+ The 30-second read timeout on `mi_capture` is unchanged. `[MEASURED 2026-08-17]` the
63
+ captures that failed took 1m45s–2m50s server-side, so no reasonable timeout bump makes them
64
+ reliable; the real fix is an idempotency key and a non-blocking capture, which belongs in
65
+ the surfaces that replace this one, not in a final release. After a `ReadTimeout`, do not
66
+ retry — call `mi_list` and check whether the capture landed.
67
+
68
+ ## [0.2.13] — 2026-08-13
69
+
70
+ > Ships **both** its own fix and 0.2.12's — see the note under [0.2.12].
71
+
72
+
73
+ ### Fixed — `setup` could not be re-run without re-entering your API key (#1351)
74
+
75
+ `mi-mcp setup` is the most discoverable command for "my install is broken, fix it", but it
76
+ was written as the **first-run** path: it prompted for the API key unconditionally, so a
77
+ returning user got sent to the portal to dig out a credential they never needed to touch,
78
+ and a perfectly good stored key was overwritten.
79
+
80
+ `setup` now **keeps a key that is already in the Keychain or the keyfile**, printing only a
81
+ masked prefix. `--reset-key` replaces it deliberately. Resolution order, most explicit
82
+ first: `--api-key` → `MI_API_KEY` → already-stored → prompt.
83
+
84
+ It also names the command that user actually wanted. **`mi-mcp wire`** re-connects Claude
85
+ Desktop / Code / Cursor and never touches your key — `doctor` recommended it in five
86
+ places, but the failure is precisely for the user who does not run `doctor` first. The
87
+ `--help` epilog now says which of the two you need.
88
+
89
+ ## [0.2.12] — 2026-08-12 — NEVER PUBLISHED
90
+
91
+ > ⚠️ **There is no 0.2.12 on PyPI.** The index goes 0.2.11 → 0.2.13.
92
+ >
93
+ > This number was minted on the branch for #1253, and #1351's branch independently
94
+ > minted the same one. The `MCP version + release-drift guard` is there to stop two
95
+ > different bodies of code shipping under one released version (#1135, the two-0.2.2s
96
+ > incident), so the second branch moved to 0.2.13 rather than reusing it.
97
+ >
98
+ > **The fix described below did ship — in 0.2.13**, together with #1351's. This
99
+ > section is kept rather than merged upward so the version history stays continuous
100
+ > for anyone reading top to bottom, and so `#1253 → 0.2.12` in the commit trail
101
+ > resolves to something.
102
+
103
+
104
+ ### Fixed — local recency was corpus-relative, so importing one old memory reordered every result (#1253)
105
+
106
+ `LocalIndex.search` normalised recency against `max_age`, the age of the **oldest entry
107
+ currently in the index**. A document's score therefore depended on the whole corpus, not
108
+ on the query and the document: import one old memory and every existing result reorders,
109
+ with no change to the query and no change to the memories being ranked. Ranking stopped
110
+ being a function of `(query, document)`.
111
+
112
+ Recency is now an **absolute linear 30-day decay**, with semantics reused from the cloud
113
+ read path (`core/engines/rerank.py::recency_score`) rather than re-derived — floor to
114
+ whole days, decay over 30, floor at 0.0. One deliberate difference, stated rather than
115
+ silent: the result is also capped at **1.0**, so a future-dated entry from clock skew
116
+ cannot let recency out-rank every real signal.
117
+
118
+ `DEFAULT_WEIGHTS` carried the comment *"kept comparable to the cloud ranking."* The
119
+ numbers do match; the signals underneath do not all match. It now says so. Recency is
120
+ genuinely shared as of this release; keyword and entity remain locally derived.
121
+
122
+ ⚠️ **Ranking output changes for any vault whose oldest entry is not ~30 days old.** Under
123
+ the old formula the oldest entry always scored 0.0 recency and the newest always 1.0,
124
+ whatever the real span. Absolute decay means a vault where everything is a week old now
125
+ sees recency contribute ~equally across all entries — which is correct, and is the point.
126
+
127
+ ||||||| parent of 3fd5f209 (fix(mcp): setup keeps an already-stored key, and names `wire` as the repair command)
6
128
  ## [0.2.11] — 2026-08-11
7
129
 
8
130
  ### Fixed — `doctor` only ever asked PyPI, so a mirror install could not learn it was behind (#1347)
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: memoryintelligence-mcp
3
- Version: 0.2.11
4
- Summary: MCP server for MemoryIntelligence — give Claude a memory you own, set up in one command
3
+ Version: 0.2.14
4
+ Summary: DEPRECATED — final release (0.2.14). Use the MemoryIntelligence desktop app's MCP or the claude.ai connector. MCP server for MemoryIntelligence.
5
5
  Project-URL: Homepage, https://memoryintelligence.io
6
6
  Project-URL: Repository, https://github.com/somewhere11/memoryintelligence-mcp
7
7
  Project-URL: Issues, https://github.com/somewhere11/memoryintelligence-mcp/issues
@@ -11,7 +11,7 @@ Author-email: Somewhere <connect@somewheremedia.com>
11
11
  License-Expression: Apache-2.0
12
12
  License-File: LICENSE
13
13
  Keywords: ai,claude,llm,mcp,memory,memory-intelligence,model-context-protocol
14
- Classifier: Development Status :: 4 - Beta
14
+ Classifier: Development Status :: 7 - Inactive
15
15
  Classifier: Intended Audience :: Developers
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3.10
@@ -39,6 +39,20 @@ Description-Content-Type: text/markdown
39
39
 
40
40
  # MemoryIntelligence MCP Server
41
41
 
42
+ > ## ⚠️ DEPRECATED — 0.2.14 is the final release
43
+ >
44
+ > This package (`mi-local`) is retired. It keeps working but receives no further
45
+ > updates, fixes, or new tools. Replace it with:
46
+ >
47
+ > - **On your computer:** the MemoryIntelligence desktop app's built-in MCP
48
+ > (*Connect Claude* inside the app). It sees everything you connect to MI and
49
+ > enforces the per-category disclosure you choose there, which this package
50
+ > never could.
51
+ > - **On the web and phone:** the claude.ai **MemoryIntelligence** connector.
52
+ >
53
+ > Every start of `mi-mcp`, `mi-mcp setup` and `mi-mcp doctor` prints this notice
54
+ > to stderr. Decision and rationale: [MemoryIntelligence#2186](https://github.com/somewhere11/MemoryIntelligence/issues/2186).
55
+
42
56
  [![PyPI](https://img.shields.io/pypi/v/memoryintelligence-mcp.svg)](https://pypi.org/project/memoryintelligence-mcp/)
43
57
  [![Python](https://img.shields.io/pypi/pyversions/memoryintelligence-mcp.svg)](https://pypi.org/project/memoryintelligence-mcp/)
44
58
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
@@ -1,5 +1,19 @@
1
1
  # MemoryIntelligence MCP Server
2
2
 
3
+ > ## ⚠️ DEPRECATED — 0.2.14 is the final release
4
+ >
5
+ > This package (`mi-local`) is retired. It keeps working but receives no further
6
+ > updates, fixes, or new tools. Replace it with:
7
+ >
8
+ > - **On your computer:** the MemoryIntelligence desktop app's built-in MCP
9
+ > (*Connect Claude* inside the app). It sees everything you connect to MI and
10
+ > enforces the per-category disclosure you choose there, which this package
11
+ > never could.
12
+ > - **On the web and phone:** the claude.ai **MemoryIntelligence** connector.
13
+ >
14
+ > Every start of `mi-mcp`, `mi-mcp setup` and `mi-mcp doctor` prints this notice
15
+ > to stderr. Decision and rationale: [MemoryIntelligence#2186](https://github.com/somewhere11/MemoryIntelligence/issues/2186).
16
+
3
17
  [![PyPI](https://img.shields.io/pypi/v/memoryintelligence-mcp.svg)](https://pypi.org/project/memoryintelligence-mcp/)
4
18
  [![Python](https://img.shields.io/pypi/pyversions/memoryintelligence-mcp.svg)](https://pypi.org/project/memoryintelligence-mcp/)
5
19
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
@@ -4,15 +4,16 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "memoryintelligence-mcp"
7
- version = "0.2.11"
8
- description = "MCP server for MemoryIntelligence — give Claude a memory you own, set up in one command"
7
+ version = "0.2.14"
8
+ description = "DEPRECATED — final release (0.2.14). Use the MemoryIntelligence desktop app's MCP or the claude.ai connector. MCP server for MemoryIntelligence."
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
11
11
  requires-python = ">=3.10"
12
12
  authors = [{ name = "Somewhere", email = "connect@somewheremedia.com" }]
13
13
  keywords = ["mcp", "model-context-protocol", "memory-intelligence", "claude", "llm", "memory", "ai"]
14
14
  classifiers = [
15
- "Development Status :: 4 - Beta",
15
+ # 7 - Inactive: 0.2.14 is the final release (#2186). PyPI shows this status.
16
+ "Development Status :: 7 - Inactive",
16
17
  "Intended Audience :: Developers",
17
18
  "Programming Language :: Python :: 3",
18
19
  "Programming Language :: Python :: 3.10",
@@ -0,0 +1,32 @@
1
+ """MI MCP Server — MemoryIntelligence tools for Claude.
2
+
3
+ DEPRECATED — 0.2.14 is the FINAL release of this package (`mi-local`).
4
+ See :data:`DEPRECATION_NOTICE` and somewhere11/MemoryIntelligence#2186.
5
+ """
6
+
7
+ import sys
8
+
9
+ __version__ = "0.2.14"
10
+
11
+ #: One line, shown on every server start and on `mi-mcp setup` / `mi-mcp doctor`.
12
+ #: Goes to STDERR only: the server speaks MCP over stdout, and one stray byte
13
+ #: there breaks the host's JSON-RPC framing. [KASEY-STATED 2026-10-19] this is
14
+ #: the last release; the desktop app carries the local MCP from here on.
15
+ DEPRECATION_NOTICE = (
16
+ "mi-mcp (mi-local) is DEPRECATED and 0.2.14 is its final release. It keeps "
17
+ "working, but receives no further updates. Use the MemoryIntelligence desktop "
18
+ "app's built-in MCP (Connect Claude) on your computer, or the claude.ai "
19
+ "MemoryIntelligence connector on the web and phone. "
20
+ "Details: https://github.com/somewhere11/MemoryIntelligence/issues/2186"
21
+ )
22
+
23
+
24
+ def warn_deprecated(stream=None) -> None:
25
+ """Write :data:`DEPRECATION_NOTICE` to ``stream`` (default: stderr).
26
+
27
+ Written directly rather than through ``logging`` so it appears even when the
28
+ host runs the server with logging quietened, and never on stdout.
29
+ """
30
+ out = stream if stream is not None else sys.stderr
31
+ out.write(f"[mi-mcp] DEPRECATED: {DEPRECATION_NOTICE}\n")
32
+ out.flush()
@@ -20,7 +20,7 @@ import asyncio
20
20
  import logging
21
21
  import sys
22
22
 
23
- from . import __version__
23
+ from . import __version__, warn_deprecated
24
24
 
25
25
  logger = logging.getLogger("mi_mcp")
26
26
 
@@ -43,9 +43,11 @@ def main():
43
43
  # user checking `--help` for `setup` shouldn't conclude the docs are stale.
44
44
  epilog=(
45
45
  "setup commands (run these first, not shown above):\n"
46
- " mi-mcp setup store your API key + wire + opt-in + verify (one command)\n"
47
- " mi-mcp wire wire into Claude Desktop / Code / Cursor\n"
48
- " mi-mcp doctor verify install, key resolution, and wiring\n"
46
+ " mi-mcp setup first run: store your API key + wire + opt-in + verify\n"
47
+ " mi-mcp wire ALREADY SET UP AND SOMETHING BROKE? start here —\n"
48
+ " re-connects Claude Desktop / Code / Cursor and\n"
49
+ " never touches your key\n"
50
+ " mi-mcp doctor tells you which of the two you need\n"
49
51
  " mi-mcp status show wired surfaces + opt-in allowlist\n"
50
52
  "\nGet a key at https://memoryintelligence.io/portal, then run `mi-mcp setup`."
51
53
  ),
@@ -94,6 +96,11 @@ def main():
94
96
  # config/import reads as a silent "connected → 60s timeout" with no failure point.
95
97
  logger.info("mi-mcp %s starting…", __version__)
96
98
 
99
+ # #2186 — final release. Anyone who still has mi-local wired sees this in the
100
+ # host's MCP log on every start; nothing is removed and nothing changes shape.
101
+ # stderr only: stdout is the MCP transport.
102
+ warn_deprecated()
103
+
97
104
  # Load config from env (CLI args override env vars)
98
105
  from .config import MIConfig
99
106
 
@@ -38,7 +38,7 @@ import tempfile
38
38
  from dataclasses import dataclass
39
39
  from pathlib import Path
40
40
 
41
- from . import __version__, paths
41
+ from . import __version__, paths, warn_deprecated
42
42
  from .config import load_opt_in_paths
43
43
 
44
44
  # "mi-local" (#1320): the local stdio server's config id. It was
@@ -576,6 +576,7 @@ def _upgrade_command() -> str:
576
576
 
577
577
 
578
578
  def cmd_doctor(argv: list[str]) -> int:
579
+ warn_deprecated() # #2186 — final release; stderr, before anything else
579
580
  ap = argparse.ArgumentParser(prog="mi-mcp doctor")
580
581
  ap.add_argument("--home", default=os.environ.get("HOME"))
581
582
  ap.add_argument("--no-version-check", action="store_true",
@@ -1082,6 +1083,36 @@ def cmd_backfill(argv: list[str]) -> int:
1082
1083
  # setup — the one-command front door (store key → wire → opt-in → verify)
1083
1084
  # ---------------------------------------------------------------------------
1084
1085
 
1086
+ def _stored_api_key(home: Path) -> str | None:
1087
+ """Return (key, where) for a key already on disk/Keychain, else (None, "").
1088
+
1089
+ Deliberately does NOT consult ``MI_API_KEY`` from the environment, unlike
1090
+ ``config.resolve_api_key``. Setup uses this to answer "do you already have a
1091
+ key I would be about to overwrite?", and an env var is neither stored nor
1092
+ overwritten — reporting it as "already stored" would be a lie the user
1093
+ cannot act on.
1094
+ """
1095
+ account = os.environ.get("MI_KEYCHAIN_ACCOUNT") or os.environ.get("USER") or ""
1096
+ try:
1097
+ r = subprocess.run(
1098
+ ["security", "find-generic-password", "-a", account, "-s", "MI_API_KEY", "-w"],
1099
+ capture_output=True, text=True, timeout=5,
1100
+ )
1101
+ if r.returncode == 0 and r.stdout.strip():
1102
+ return r.stdout.strip()
1103
+ except (OSError, subprocess.SubprocessError):
1104
+ pass # non-macOS or `security` unavailable — fall through to the keyfile
1105
+ envf = paths.resolve_keyfile(home)
1106
+ if envf is not None:
1107
+ for line in envf.read_text().splitlines():
1108
+ line = line.strip()
1109
+ if line.startswith("MI_API_KEY="):
1110
+ val = line.split("=", 1)[1].strip().strip('"').strip("'")
1111
+ if val:
1112
+ return val
1113
+ return None
1114
+
1115
+
1085
1116
  def _store_key_keychain(key: str, account: str) -> None:
1086
1117
  """Store the key in the macOS Keychain under service ``MI_API_KEY``.
1087
1118
 
@@ -1139,12 +1170,15 @@ def _opt_in_dir(home: Path, directory: str) -> tuple[Path, bool]:
1139
1170
 
1140
1171
 
1141
1172
  def cmd_setup(argv: list[str]) -> int:
1173
+ warn_deprecated() # #2186 — final release; stderr, before anything else
1142
1174
  ap = argparse.ArgumentParser(
1143
1175
  prog="mi-mcp setup",
1144
1176
  description="One command: store your key, wire hosts, opt in this dir, verify.",
1145
1177
  )
1146
1178
  ap.add_argument("--api-key", default=None,
1147
1179
  help="provide the key non-interactively (else you're prompted, hidden)")
1180
+ ap.add_argument("--reset-key", action="store_true",
1181
+ help="replace a key that is already stored (default: keep it)")
1148
1182
  ap.add_argument("--store", choices=["auto", "keychain", "file"], default="auto",
1149
1183
  help="where to keep the key (auto: Keychain on macOS, ~/.memoryintelligence/.env elsewhere)")
1150
1184
  ap.add_argument("--surfaces", default="desktop,code",
@@ -1174,6 +1208,46 @@ def cmd_setup(argv: list[str]) -> int:
1174
1208
  if key:
1175
1209
  print(" ⚠ --api-key is visible in the process list (ps); on shared machines\n"
1176
1210
  " prefer the interactive prompt or the MI_API_KEY env var.", file=sys.stderr)
1211
+
1212
+ # #1351 — `setup` is the most discoverable command for "my install is
1213
+ # broken, fix it", but it was written as the FIRST-RUN path and prompted
1214
+ # for the key unconditionally. A returning user got sent to the portal to
1215
+ # dig out a credential they never needed to touch, and a perfectly good
1216
+ # stored key was overwritten.
1217
+ #
1218
+ # `mi-mcp wire` is the correct command for that user — it re-connects the
1219
+ # hosts and never touches the key — and nothing told them so. `doctor`
1220
+ # recommends `wire` in five places, but the whole failure is for the user
1221
+ # who does NOT run doctor first and goes straight for the command whose
1222
+ # name sounds like what they want.
1223
+ #
1224
+ # Resolution order, most explicit first:
1225
+ # --api-key → MI_API_KEY env → ALREADY-STORED key → prompt
1226
+ #
1227
+ # An env var set for this invocation is a deliberate per-run override and
1228
+ # outranks what is on disk; a stored key outranks the prompt, which is the
1229
+ # fix. Ordering matters and is asserted in test_cli_setup.py.
1230
+ if not key and os.environ.get("MI_API_KEY"):
1231
+ key = os.environ["MI_API_KEY"].strip()
1232
+ print(" using MI_API_KEY from the environment")
1233
+
1234
+ if not key and not args.reset_key:
1235
+ existing = _stored_api_key(home)
1236
+ if existing:
1237
+ key = existing
1238
+ # Nothing derived from the key is printed — not a masked slice, not
1239
+ # a hash. CodeQL taints the key value, so ANY derived value reaching
1240
+ # stdout is a clear-text-logging flow, and it is right to: the useful
1241
+ # fact here is that a key was kept and WHERE it lives, which needs no
1242
+ # part of the secret. Two earlier attempts got this wrong — a
1243
+ # `key[:11]…key[-4:]` mask (1 alert), then a SHA-256 fingerprint,
1244
+ # which kept that alert AND added a weak-hash-on-sensitive-data one
1245
+ # (2 alerts). `mi-mcp doctor` is where key identity belongs.
1246
+ print(" keeping the key already stored on this machine")
1247
+ print(" re-run with --reset-key to replace it\n")
1248
+ print(" \u2139 if you only need to re-connect the hosts, `mi-mcp wire` is\n"
1249
+ " the narrower command — it never touches your key.\n")
1250
+
1177
1251
  if not key:
1178
1252
  if sys.stdin.isatty():
1179
1253
  print("Get a free key at https://memoryintelligence.io/portal")
@@ -1182,9 +1256,6 @@ def cmd_setup(argv: list[str]) -> int:
1182
1256
  except (EOFError, KeyboardInterrupt):
1183
1257
  print("\naborted — nothing stored.", file=sys.stderr)
1184
1258
  return 130
1185
- elif os.environ.get("MI_API_KEY"):
1186
- key = os.environ["MI_API_KEY"].strip()
1187
- print(" using MI_API_KEY from the environment")
1188
1259
  else:
1189
1260
  print("error: no API key. Run in a terminal to be prompted, set MI_API_KEY,\n"
1190
1261
  " or pass --api-key. Get a free key at https://memoryintelligence.io/portal",
@@ -37,9 +37,44 @@ from typing import Optional, Sequence
37
37
  # module — for its dataclasses or JSON persistence — never requires numpy. Only
38
38
  # ranking does. Keeps `pip install memoryintelligence-mcp` numpy-free.
39
39
 
40
- # Local ranking weights, kept comparable to the cloud ranking.
40
+ # Local ranking weights. The NUMBERS match the cloud's
41
+ # (`core/engines/rerank.py`); the SIGNALS underneath are not all identical, so
42
+ # read this as "same blend, not the same function" rather than as a parity
43
+ # guarantee. Recency is now genuinely shared (see below); keyword and entity
44
+ # are still locally derived.
41
45
  DEFAULT_WEIGHTS = {"semantic": 0.60, "keyword": 0.15, "entity": 0.15, "recency": 0.10}
42
46
 
47
+ #: Days over which recency decays to zero. Mirrors `rerank.recency_score`,
48
+ #: which the cloud/sidecar read path uses.
49
+ RECENCY_HALFLIFE_DAYS = 30.0
50
+ _SECONDS_PER_DAY = 86_400.0
51
+
52
+
53
+ def _recency_score(created_at: float, now: float) -> float:
54
+ """Absolute linear 30-day decay — NOT normalized against the corpus (#1253).
55
+
56
+ This was ``1.0 - ((now - created_at) / max_age)`` where ``max_age`` was the
57
+ age of the oldest entry in the index. A document's score therefore depended
58
+ on the whole corpus: **importing one old memory reordered every existing
59
+ result**, with no change to the query and no change to the memories being
60
+ ranked. Ranking stopped being a function of ``(query, document)``, which is
61
+ wrong under any architecture we might pick for the local runtime — which is
62
+ why it is fixed here rather than folded into the local/cloud convergence
63
+ question.
64
+
65
+ Semantics are reused from ``core/engines/rerank.py::recency_score`` rather
66
+ than re-derived: floor to whole days ago, linear decay over
67
+ ``RECENCY_HALFLIFE_DAYS``, floor at 0.0.
68
+
69
+ One deliberate difference from the cloud function, stated rather than
70
+ silent: the result is also capped at **1.0**. A future-dated entry (clock
71
+ skew, a bad import) yields a negative ``days_ago`` there and a score above
72
+ 1.0, which would let recency out-rank every real signal. Capping cannot
73
+ hide a real difference — nothing legitimately scores above 1.0.
74
+ """
75
+ days_ago = (now - created_at) // _SECONDS_PER_DAY
76
+ return max(0.0, min(1.0, 1.0 - (days_ago / RECENCY_HALFLIFE_DAYS)))
77
+
43
78
  _TOKEN_RE = re.compile(r"[a-z0-9]+")
44
79
 
45
80
 
@@ -124,9 +159,6 @@ class LocalIndex:
124
159
  q_tokens = _tokens(query_text)
125
160
  q_ents = {e.lower() for e in (query_entities or [])}
126
161
 
127
- ages = [now - e.created_at for e in self._entries.values()]
128
- max_age = max(ages) or 1.0 # normalize recency against the oldest entry
129
-
130
162
  w = self._weights
131
163
  hits = []
132
164
  for e in self._entries.values():
@@ -135,7 +167,7 @@ class LocalIndex:
135
167
  semantic = max(0.0, cos) # similarity, never negative
136
168
  keyword = _overlap(q_tokens, _tokens(e.summary))
137
169
  entity = _overlap(q_ents, {x.lower() for x in e.entities}) if q_ents else 0.0
138
- recency = 1.0 - ((now - e.created_at) / max_age)
170
+ recency = _recency_score(e.created_at, now)
139
171
  score = (
140
172
  w["semantic"] * semantic
141
173
  + w["keyword"] * keyword
@@ -168,6 +168,9 @@ def _shape_ask(result: Any, explain: Any = "none") -> Any:
168
168
  "umo_id": r.get("umo_id"),
169
169
  # content_text duplicates summary; fall back to it only if summary is empty.
170
170
  "summary": r.get("summary") or r.get("content_text"),
171
+ # The memory's stored title (API migration 079): its own on a
172
+ # memory, the parent memory's on a claim. Kept only when present.
173
+ **{k: r[k] for k in ("title", "memory_title") if r.get(k)},
171
174
  # #538: the API omits source when it's the default — absent means "api".
172
175
  "source": r.get("source") or "api",
173
176
  "score": r.get("score"),
@@ -186,10 +189,25 @@ def _shape_ask(result: Any, explain: Any = "none") -> Any:
186
189
  # level; drop the receipt's duplicate result seals (the hits already carry
187
190
  # them) and keep the fields an agent cites. Absent when receipts are
188
191
  # disabled server-side — then the shape is just {"results": [...]}.
192
+ # #1117: the answerability verdict, surfaced WITHOUT asking for explain.
193
+ # Every hit already carries a `score`, and on the CE scale ~94% of them read
194
+ # 0.0 (#2013) — so a junk row and a good row look identical to a reading
195
+ # model. `answerable` is the one field that separates them. It rides at the
196
+ # envelope level, next to results, because a model that has to opt in to the
197
+ # verdict will not.
198
+ #
199
+ # ADVISORY, deliberately: the rows are still here and a caller may cite them.
200
+ # This says what MI thinks, it does not withhold.
201
+ envelope: dict = {"results": shaped}
202
+ if isinstance(data.get("answerable"), bool):
203
+ envelope["answerable"] = data["answerable"]
204
+ if data.get("top_similarity") is not None:
205
+ envelope["top_similarity"] = data["top_similarity"]
206
+
189
207
  receipt = data.get("knowledge_receipt")
190
208
  if isinstance(receipt, dict):
191
209
  return {
192
- "results": shaped,
210
+ **envelope,
193
211
  "knowledge_receipt": {
194
212
  "receipt_id": receipt.get("receipt_id"),
195
213
  "question_hash": receipt.get("question_hash"),
@@ -198,7 +216,7 @@ def _shape_ask(result: Any, explain: Any = "none") -> Any:
198
216
  "versions": receipt.get("versions"),
199
217
  },
200
218
  }
201
- return {"results": shaped}
219
+ return envelope
202
220
 
203
221
 
204
222
  def _entity_tags(it: dict) -> list:
@@ -246,6 +264,7 @@ def _shape_list(result: Any) -> Any:
246
264
  continue
247
265
  shaped.append({
248
266
  "umo_id": it.get("umo_id"),
267
+ **{k: it[k] for k in ("title", "memory_title") if it.get(k)},
249
268
  "summary": it.get("summary"),
250
269
  "source": it.get("source"),
251
270
  "topics": it.get("topics"),
@@ -1,3 +0,0 @@
1
- """MI MCP Server — MemoryIntelligence tools for Claude."""
2
-
3
- __version__ = "0.2.11"