fix: Recover widget structuredContent stripped by Claude Desktop - #1187
Merged
Conversation
Claude Desktop forwards ui/notifications/tool-result to MCP Apps views with only content/isError, dropping structuredContent (modelcontextprotocol/ext-apps#696). Widgets render from structuredContent, so they stayed on skeletons forever. Recover in the shared app context, in order: 1. Parse content[0] as JSON — run-widget tools mirror structuredContent there, so recovery is free and never re-executes anything. 2. Re-call the tool via the host tools/call proxy (returns the full CallToolResult intact). Only for read-only tools, declared per widget entry via refetchToolForArgs; never used for run-starting tools. Both paths are no-ops on hosts that deliver structuredContent (claude.ai, ChatGPT, MCP Jam). Remove when ext-apps#696 is fixed: grep for "ext-apps#696". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Jul 30, 2026
MQ37
approved these changes
Aug 3, 2026
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
Claude Desktop (Linux + macOS, Claude/1.22209.0 and macOS 1.18286.2 per upstream report) strips
structuredContentand_metafrom theui/notifications/tool-resultnotification delivered to MCP Apps views — the view receives onlycontent/isError. Upstream: modelcontextprotocol/ext-apps#696. Our widgets render exclusively fromstructuredContent, so on Claude Desktop every widget stayed on loading skeletons forever. claude.ai, ChatGPT and MCP Jam deliver the field intact and are unaffected.Wire-level evidence from an in-widget tap (Desktop):
raw:tool-result[content,isError]— the field is already absent in the postMessage payload, so no client-side parsing tweak can see it.What changed
Before: widgets set
toolResultstraight from the notification; missingstructuredContentmeant nothing to render.Now
mcp-app-context.tsxrecovers, in order:content[0]as JSON — the run-widget tools (call-actor-widget,get-actor-run-widget) mirrorstructuredContentthere, so recovery is free and never re-executes anything.tools/callproxy (Desktop returns the fullCallToolResultintact on that path — verified). Only for read-only tools, declared per widget entry viarefetchToolForArgs(search-actors-widget,fetch-actor-details-widget); never wired for run-starting tools, so no double runs.Both paths sit behind
if (!structuredContent && !isError)— a no-op wherever the host delivers the field. Temporary by design: when ext-apps#696 is fixed,grep -r "ext-apps#696" src/finds every line to delete.Notes for reviewers (human-written)
This was really painful :(
Proof it works
tool-result[sc:MISSING].tool-result[sc:MISSING] → refetched-via-tools/call[sc:ok]and actor cards render; run widgets recover via thecontent[0]JSON mirror. All four widget tools manually verified working on Desktop by @jirispilka.registerAppTool/registerAppResource): notification arriveskeys=[content,isError], while the same tool called through the host proxy returnskeys=[content,structuredContent].?ui=openai) — expect identical rendering and no secondtools/callin the server log (the guard makes the recovery inert whenstructuredContentis delivered).🤖 Generated with Claude Code