feat: include structuredContent as JSON text in every tool result - #62
Merged
Merged
Conversation
The spec says a tool returning structured content SHOULD also return it serialized in a TextContent block. Every tool's text here was a one-line summary, so a client that shows the model only `content` never saw the data. Wrapped once in registerTools; error results and non-object structuredContent (which the SDK serializes itself) are untouched. Verified over the wire with get-document-link.
This was referenced Sep 22, 2026
marselsel
changed the base branch from
fix/plain-403-for-refused-domain
to
main
September 22, 2026 21:57
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.
Part 4 of 8 in the MCP best-practices stack. Stacked on #61, so merge in order.
Why
contentnever saw the document itself.structuredContentyet." A third-party report (Claude Custom Connector cannot see structured MCP tool results yyjeqhc/webcodex#456, 2026-09-14) describes a Claude custom connector passing the model onlycontent[0].text. Claude Code is reported to forwardstructuredContent, so the added text does not double what the model sees there.structuredContentitself, so object payloads need this.Changes
withJsonTextinshared.ts: appendsJSON.stringify(structuredContent)(compact) as the last text block. Error results and non-object payloads pass through untouched.registerToolswraps every handler, instead of changing about 40 handlers.Verification
registerTools.get-document-linkreturned the summary block followed by the JSON block.npm testpasses all 475 tests.