Skip to content

Commit f753ec4

Browse files
jpheinclaude
andauthored
feat(mcp): add fusion_mode to mempalace_search input schema (closes #302) (#310)
* feat(mcp): add fusion_mode to mempalace_search input schema (closes #302) palace-daemon#107 ships the daemon-side surface for `/search/hybrid?fusion_mode=…` but the mempalace MCP layer was dropping the parameter via its schema whitelist before it reached search_memories(). This closes the gap. Three changes: 1. Add fusion_mode to mempalace_search's input_schema with enum ["convex", "rrf"] and a description matching search_memories' docstring. 2. Add fusion_mode kwarg to tool_search() defaulting to "convex" (same as search_memories()), and pass it through to the search_memories call alongside candidate_strategy. 3. Surface fusion_mode in the trace output so callers can confirm which algorithm answered. When palace-daemon's `/search/hybrid?fusion_mode=rrf` reaches mempalace now, the MCP layer accepts it, threads it to search_memories(), and the RRF code path actually runs. End-to-end A/B testing of convex vs RRF against the production palace becomes possible. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(docs): tests + fork-changes entry + README/llms-full re-render for #302 PR #310's initial commit added only the 8-line mempalace/mcp_server.py change, but the CI check-docs gate requires: - fork-changes.yaml entry + render of FORK_CHANGELOG.md - README test count bump (3770 → 3773) - llms-full.txt re-render via scripts/render-llms-full.py - python-api re-render via scripts/render-api-docs.py And the change needs test coverage. tests/test_mcp_server.py now has three new tests against the boundary the bug was filed for: - fusion_mode reaches search_memories with convex default and rrf override - fusion_mode survives the MCP handle_request whitelist (the actual #302 bug) - schema advertises both modes in enum Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1d19a8b commit f753ec4

7 files changed

Lines changed: 373 additions & 161 deletions

File tree

FORK_CHANGELOG.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,68 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
2424
### Added
2525

2626

27+
- **mempalace_search MCP input schema accepts fusion_mode (convex|rrf) and forwards to search_memories (#302)** ([`HEAD`](https://github.com/techempower-org/mempalace/commit/HEAD))
28+
#162 / PR #295 added ``fusion_mode`` to ``search_memories()`` with
29+
``"convex"`` default and ``"rrf"`` opt-in, validated by the
30+
``_FUSION_RANKERS`` registry. palace-daemon#105 adds the same
31+
parameter to its ``/search/hybrid`` HTTP surface so daemon-fronted
32+
callers can A/B at production scale. But the MCP boundary in
33+
``mempalace/mcp_server.py`` whitelists callable arguments against
34+
the declared ``input_schema`` ``properties`` — and ``fusion_mode``
35+
wasn't in the list. Daemon-forwarded values were silently dropped
36+
before reaching ``search_memories``, and the end-to-end A/B never
37+
worked.
38+
39+
This change adds ``fusion_mode`` to the ``mempalace_search``
40+
input schema (enum ``["convex", "rrf"]``, mirroring
41+
``candidate_strategy``'s shape), threads the parameter through
42+
``tool_search`` into the ``search_memories()`` call, and surfaces
43+
it on the ``trace`` dict alongside ``candidate_strategy`` /
44+
``sources`` when ``include_trace=true``. The default stays
45+
``"convex"`` — same default as ``search_memories``' own signature,
46+
so unmodified callers see no behavior change.
47+
48+
Three unit tests cover the kwarg path: ``fusion_mode`` reaches
49+
``search_memories`` with the default, the explicit value passes
50+
through, and the MCP whitelist via ``handle_request`` accepts the
51+
arg rather than returning ``-32602 Unknown parameter`` (the bug
52+
this issue was filed to fix).
53+
54+
*Tests:* 3 — tests/test_mcp_server.py (fusion_mode forwarded to search_memories incl. convex default + rrf override, fusion_mode survives MCP whitelist via handle_request, schema advertises both modes in enum)
55+
*Files:* `mempalace/mcp_server.py`, `tests/test_mcp_server.py`
56+
57+
58+
- **mempalace_search MCP input schema accepts fusion_mode (convex|rrf) and forwards to search_memories (#302)** ([`HEAD`](https://github.com/techempower-org/mempalace/commit/HEAD))
59+
#162 / PR #295 added ``fusion_mode`` to ``search_memories()`` with
60+
``"convex"`` default and ``"rrf"`` opt-in, validated by the
61+
``_FUSION_RANKERS`` registry. palace-daemon#105 adds the same
62+
parameter to its ``/search/hybrid`` HTTP surface so daemon-fronted
63+
callers can A/B at production scale. But the MCP boundary in
64+
``mempalace/mcp_server.py`` whitelists callable arguments against
65+
the declared ``input_schema`` ``properties`` — and ``fusion_mode``
66+
wasn't in the list. Daemon-forwarded values were silently dropped
67+
before reaching ``search_memories``, and the end-to-end A/B never
68+
worked.
69+
70+
This change adds ``fusion_mode`` to the ``mempalace_search``
71+
input schema (enum ``["convex", "rrf"]``, mirroring
72+
``candidate_strategy``'s shape), threads the parameter through
73+
``tool_search`` into the ``search_memories()`` call, and surfaces
74+
it on the ``trace`` dict alongside ``candidate_strategy`` /
75+
``sources`` when ``include_trace=true``. The default stays
76+
``"convex"`` — same default as ``search_memories``' own signature,
77+
so unmodified callers see no behavior change.
78+
79+
Three unit tests cover the kwarg path: ``fusion_mode`` reaches
80+
``search_memories`` with the default, the explicit value passes
81+
through, and the MCP whitelist via ``handle_request`` accepts the
82+
arg rather than returning ``-32602 Unknown parameter`` (the bug
83+
this issue was filed to fix).
84+
85+
*Tests:* 3 — tests/test_mcp_server.py (fusion_mode forwarded to search_memories incl. convex default + rrf override, fusion_mode survives MCP whitelist via handle_request, schema advertises both modes in enum)
86+
*Files:* `mempalace/mcp_server.py`, `tests/test_mcp_server.py`
87+
88+
2789
- **mempalace why + tunnels — explain a drawer + inventory cross-wing tunnels (slice of #191)** ([`fdcd0b4`](https://github.com/techempower-org/mempalace/commit/fdcd0b4))
2890
Two more verbs join the daemon-fast-path family started by
2991
``tags`` / ``overlap`` / ``list`` / ``move`` / ``stats`` /

0 commit comments

Comments
 (0)