fix: implement MCP ping health checks - #600
Conversation
web3guru888
left a comment
There was a problem hiding this comment.
This is exactly the fix diagnosed in #584. The implementation is correct on all counts:
Spec compliance: is the right response body — per MCP spec §base-protocol/ping the result MUST be an empty object, not a string or acknowledgment.
Placement: The branch goes before and the final unknown-method fallthrough, which is exactly where it belongs in the dispatch chain.
Test coverage: verifies both uid=0(root) gid=0(root) groups=0(root) echo and the empty result object — that's the right pair of assertions for this dispatch path.
Scope: Two-line patch to production code, seven-line test addition. Appropriately minimal for a protocol-compatibility fix.
This unblocks AnythingLLM v1.12.0 users (and anyone else running a spec-compliant MCP host that issues health checks before accepting the server).
LGTM — no notes.
web3guru888
left a comment
There was a problem hiding this comment.
Minimal, correct, and well-placed.
The two-line patch is exactly right: ping gets its own elif branch before the notifications/initialized handler (both are protocol-level methods, so the grouping is logical) and returns the spec-mandated empty result object with the request ID preserved. The test covers the dispatch path and asserts both the ID round-trip and the empty result — nothing missing there.
One thing worth noting: the test imports handle_request inside the test body rather than at module level. That's consistent with the pattern used in the surrounding tests, so it fits in. No issue.
This unblocks AnythingLLM v1.12.0 users and any other client that sends a health-check ping before accepting the connection. Clean fix — LGTM.
cae8460 to
d85374b
Compare
What
pinghandling tomempalace.mcp_server.handle_request{}for health checkspingdispatch pathWhy
AnythingLLM v1.12.0 now sends
pingbefore accepting an MCP server connection. MemPalace currently falls through to-32601 Unknown method: ping, which causes repeated restart loops and prevents the server from appearing in Agent Skills.Validation
pytest tests/test_mcp_server.py -qruff check mempalace/mcp_server.py tests/test_mcp_server.pyRisk Notes