Repository navigation
test(server): hold every MCP answer to McpJson on the raw body - #99
Merged
Merged
Conversation
katcher's own Json pretty-prints and omits defaults: an MCP answer written with it loses protocolVersion from initialize and the whole result from ping. kore-mcp encodes the answers with McpJson before ContentNegotiation sees them, and nothing here watched more than protocolVersion. McpWireFormatTest drives ten exchanges through the assembled module and compares each raw body with what McpJson writes for it. Its control sends the same requests to the bare SDK under katcher's Json and must come out different, so a green run cannot mean the comparison catches nothing. The protocolVersion test in McpEndpointTest is covered and goes; the negotiated value itself is kore-mcp's and tested there. The README says why the SDK's startup warning is expected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
katcher's ContentNegotiation (
common()) pretty-prints and does not write defaults. On MCP SDK 0.15.0 the one thing the stateless transport sends through the application's ContentNegotiation is the answer to aPOSTin JSON mode, and under katcher'sJsonthat answer losesprotocolVersionfrominitializeand the wholeresultfromping. kore-mcp encodes the answer withMcpJsonbefore ContentNegotiation sees it — and the only test here watching that looked atprotocolVersionalone.What changes
McpWireFormatTest(commonTest): ten exchanges through the assembledmodule—initializelatest and older,ping,tools/list,tools/callwithout arguments, a call ending in a tool error, an unknown tool, an unknown method, a batch of two, an unparseable body. Each raw body must be exactly whatMcpJsonwrites for the message inside it.common(), katcher's five tools, the same requests, the transport installed by the bare SDK. It must come out different; the KDoc says what to do if it ever stops.McpEndpointTest: theprotocolVersiontest is removed — the new test catches the missing field (see below); the negotiated value itself is kore-mcp's and is tested there.ContentNegotiation is already installed…warning at startup is expected and what holds it. CLAUDE.md: one sentence pointing at the test.Verified
Locally, JVM and the macOS native target:
:server:jvmTestand:server:nativeTest --tests 'io.github.youndie.katcher.mcp.*'green,ktlintCheckclean. Linux native is CI'sbuild.installMcpswitched frominstallKoreMcpto the bare SDK'smcpStatelessStreamableHttp→ the new test fails with 9 of 10 exchanges different (all but the unparseable body, which the SDK writes itself); the removedprotocolVersiontest failed on the same mutation.Json9 of 10 differ; underMcpJsonnone; under katcher'sJsonwithoutprettyPrintthree still do —initializelatest,pingand the batch carrying it, none of whichMcpJsoncan read back. So the comparison catches the droppedprotocolVersionon its own, not only whitespace.