Commit 41359ba
feat(mcp): daemon-route mcp_server.py via handle_request chokepoint
Mirror the PALACE_DAEMON_URL gate that hooks_cli.py shipped on
2026-04-24 (the daemon-strict fix for the HNSW drift incident). When
PALACE_DAEMON_URL is set and PALACE_DAEMON_STRICT != "0", every
JSON-RPC method (initialize, tools/list, tools/call, ping) is forwarded
to palace-daemon's /mcp proxy and the daemon's response is returned
verbatim. Single chokepoint at handle_request() is functionally
equivalent to per-handler gates and avoids 30+ duplicated branches —
no local chromadb client opens in strict mode. Startup HNSW probe is
skipped when daemon-strict (the daemon owns its palace's capacity).
Closes the last in-process write path that bypassed the daemon, so
the standalone palace-daemon/clients/mempalace-mcp.py bridge is now
optional — anyone running `python -m mempalace.mcp_server` with the
env var set gets the same behavior natively.
tests/conftest.py scrubs PALACE_DAEMON_URL/STRICT/API_KEY at module
load (matching the existing HOME-redirect pattern) so existing
local-path tests don't accidentally hit the live daemon when run from
a shell where the env var is set.
15 new tests in tests/test_mcp_server_daemon.py covering the gate,
helper body shape, network-failure surfacing as JSON-RPC error,
forwarded initialize/tools/call/error propagation, and a sentinel
TOOLS patch proving no local handler runs in strict mode. End-to-end
smoke against disks.jphe.in:8085 returns 160,351 drawers from the
canonical palace. Suite 1577 passed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b2b4fb3 commit 41359ba
3 files changed
Lines changed: 410 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
169 | 239 | | |
170 | 240 | | |
171 | 241 | | |
| |||
1907 | 1977 | | |
1908 | 1978 | | |
1909 | 1979 | | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
1910 | 1991 | | |
1911 | 1992 | | |
1912 | 1993 | | |
| |||
2024 | 2105 | | |
2025 | 2106 | | |
2026 | 2107 | | |
2027 | | - | |
2028 | | - | |
2029 | | - | |
2030 | | - | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
2031 | 2120 | | |
2032 | 2121 | | |
2033 | 2122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
30 | 42 | | |
31 | 43 | | |
| |||
0 commit comments