Repository navigation
test(server): hold MCP answers to McpJson under any application Json - #62
Merged
Merged
Conversation
The MCP SDK logs a warning at startup because metrik installs its own ContentNegotiation before the endpoint. The test shows the warning names no harm: requests are parsed by the SDK from the raw body, and the one answer that passes through ContentNegotiation is encoded with McpJson by kore-mcp first. A bare SDK under the same harmful Json is the control.
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.
metrik logs
WARN ContentNegotiation is already installed. MCP requires json(McpJson)…at startup. This explains it and holds the explanation with a test (M-117).Why the warning is printed
SDK 0.15.0 prints it whenever it finds an application ContentNegotiation: Ktor's public API does not expose the installed
Json, so the SDK cannot check it. metrik installs ContentNegotiation onMetrikJsonbeforeinstallKoreMcpon purpose; the other order makes the SDK install its own on the whole application and metrik'sinstallthrowsDuplicatePluginException.Why it does no harm
In the stateless transport exactly one thing can pass through the application's ContentNegotiation: the JSON-RPC answer to a
POST(call.respond(payload)). Requests are read by the SDK from the raw body and decoded withMcpJson; refusals are written by the SDK as text. kore-mcp encodes that one answer withMcpJsonon the transport's route, before ContentNegotiation sees it.The test
McpWireFormatTestsends ten exchanges —initializewith the latest and an older protocol version,pingwith a key the protocol does not define,tools/list, a call without optional fields, a call ending in a tool error, an unknown tool, an unknown method, a batch, an unparseable body — and checks that each raw body is byte for byte whatMcpJsonwrites for the message it carries.module: clean;Jsonthat omits defaults (kotlinx defaults, unknown keys refused) and underjson()with no argument: clean;Json: mismatches. Omitting defaults dropsprotocolVersionfrom the latest-versioninitializeanswer and the wholeresultfromping;json()addsnullfor every unset field;pingwith an unknown key is refused by the strictJson(asserted), so its200shows requests are not parsed by the application'sJson.Mutations run locally:
json()instead ofjson(MetrikJson)inmodulekeeps the guard green (the applicationJsonnever reaches the answers); a byte comparison forced to "always equal" turns thenullcontrol red.Verified:
:server:jvmTestand:server:linuxX64Testfor this class, green; the SDK's warning is reproduced in the native run, once per application.