Repository navigation
fix(mcp): serialize structured results into content by default - #55
Merged
mekedron merged 1 commit intoOct 16, 2026
Merged
Conversation
The MCP spec requires that "a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block". The tool-result middleware did the opposite: it replaced the SDK's serialized JSON with a short summary unless WOLT_MCP_DUPLICATE_CONTENT opted back in. A client that reads only content therefore received "10 matches" or "2 baskets" with no names, prices or ids behind them, and no way to tell that data was missing. Flip the default so content carries the serialized payload, and add WOLT_MCP_COMPACT_CONTENT=1 as the opt-out for clients that do read structuredContent and prefer the smaller response. The per-request contract is unchanged: _meta["wolt/duplicate_content"] true still asks for the serialized JSON and false for the summary, so a single client can still override the server either way. WOLT_MCP_DUPLICATE_CONTENT is still parsed and now warns once at startup that it can be removed, so existing configs keep working untouched. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Owner
|
Thanks a lot for this, Adam! A great catch, and the write-up with the spec quote and the before/after measurements made it easy to review. Merged as-is with a merge commit, and it ships in v2.5.0. |
mekedron
added a commit
that referenced
this pull request
Oct 17, 2026
The daily live smoke failed on 2026-10-17 at "mcp checkout preview" with "content is not the structured summary". Wolt did not change anything: since v2.5.0 wolt-mcp serializes the full structured result into content by default (PR #55), while mcp-checkout-smoke still asserted the old compact contract and rejected the JSON copy. The checker now asserts the current contract. A successful preview must carry content that decodes to the same JSON as structuredContent. A typed checkout outcome (IsError with structured data) keeps the handler's short summary in content, as before. Fixes #56
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.
What
Tool results now carry the serialized JSON payload in
contentby default. Theopt-out moves to
WOLT_MCP_COMPACT_CONTENT=1for clients that readstructuredContentand want the smaller response.Why
The MCP spec, under Structured Content, says:
newToolResultMiddlewaredid the reverse. The go-sdk already produces thatserialized block; the middleware replaced it with the short summary unless
WOLT_MCP_DUPLICATE_CONTENTasked for it back. For a client that reads onlycontent, every tool returned a bare count and nothing else.Observed with Claude Desktop on v2.4.2, which reads
contentonly. Itsexplanation of why it stopped using the server and scraped wolt.com in a browser
instead:
Same
wolt_topcall against v2.4.2, measured over stdio:content[0].textstructuredContent10 top venues(13 chars)WOLT_MCP_DUPLICATE_CONTENT=1The failure is silent: the client cannot distinguish "10 venues, details
withheld" from "10 venues with no details available", so it does not retry or
report a problem — it just works with nothing.
What this costs
Responses roughly double for clients that were relying on the compact default
and read
structuredContent. That tradeoff is why the old behavior is keptrather than removed: set
WOLT_MCP_COMPACT_CONTENT=1and it is byte-identicalto v2.4.2.
What this does not change
_meta["wolt/duplicate_content"]keeps itsoriginal sense —
trueasks for serialized JSON,falseasks for thesummary — and still overrides the server default in both directions. Only the
default it overrides has changed.
structuredContent. Untouched in every mode.normalizeToolErrorResultis not touched, so ordinary toolerrors still keep
structuredContentunset and the message incontent.WOLT_MCP_DUPLICATE_CONTENTis still parsed. It is nowa no-op, since its behavior became the default, and logs one
WARNat startupsaying it can be removed. Nothing breaks if it is left set.
Verification
Local gate from
AGENTS.MD, all passing:go build ./...,gofmt -l(clean),go vet ./...,golangci-lint runv2.4.0 (0 issues.),go test ./...,go test -race ./..., and the version-stamp check.End to end against the rebuilt binary, same
wolt_topcall:content[0]is 7,492 chars of JSON,structuredContentintactWOLT_MCP_COMPACT_CONTENT=1→content[0]is10 top venues, 13 charsTests updated in place rather than added alongside, since the existing ones
already pinned the old default: the end-to-end
wolt_cart_showcase now assertsthe serialized payload arrives with no
_metaand the summary arrives with_metafalse, and the server-level table covers both directions.🤖 Generated with Claude Code