fix: Declare widget csp/prefersBorder on the UI resource, not the tool - #1190
Open
jirispilka wants to merge 1 commit into
Open
fix: Declare widget csp/prefersBorder on the UI resource, not the tool#1190jirispilka wants to merge 1 commit into
jirispilka wants to merge 1 commit into
Conversation
Per MCP Apps spec (SEP-1865), csp/prefersBorder are UI-resource metadata (McpUiResourceMeta); the tool's _meta.ui (McpUiToolMeta) carries only resourceUri/visibility and types csp/permissions as never. Claude's host warns at runtime about the current placement and ignores the misplaced keys. Split the shared blob into per-surface variants, serve the resource variant on resources/list and resources/read, and add the legacy ui/resourceUri alias that registerAppTool populates for older hosts. Closes #1188 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
Closes #1188. Per MCP Apps spec (SEP-1865),
csp/prefersBorderare UI-resource metadata (McpUiResourceMeta) — hosts read them from theresources/readcontent item (with theresources/listentry as fallback) — while the tool's_meta.ui(McpUiToolMeta) carries onlyresourceUri/visibilityand typescsp/permissionsasnever. Claude's host warns at runtime about our current placement and ignores the misplaced keys, so our declared CSP is dead weight on the wrong surface.What changed
Before: one
_meta.uiblob (resourceUri, visibility, csp, prefersBorder) served on every surface — tool descriptor, tool result, resources/list, resources/read.Now:
WidgetConfigcarriesmeta(tool/result:resourceUri,visibility, plus the legacyui/resourceUrialias that the ext-apps SDK'sregisterAppToolpopulates for older hosts) andresourceMeta(list/read:csp,prefersBorder).resource_service.tsservesresourceMetaon both resource surfaces. Widget-meta tests pin the per-surface placement.Notes for reviewers (human-written)
Proof it works
mcpc probe against the built stdio server in apps mode:
tools/listshows widget tools with_meta.ui = {visibility, resourceUri}+ui/resourceUriand nocsp;resources/read ui://widget/search-actors.htmlreturns_metawithopenai/widgetCSP,openai/widgetDomain, andui: {prefersBorder, csp}. Widgets verified rendering in Claude Desktop and MCP Jam alongside #1187 during the ext-apps#696 investigation (this change was bisected there and is behavior-neutral for current hosts — they ignore the misplaced keys either way; this aligns us with the spec surface hosts actually read).🤖 Generated with Claude Code