Repository navigation
feat: an app's interface belongs to the upstream that published it - #74
Merged
Merged
Conversation
MCP Apps (SEP-1865) points a tool at an interactive interface through a
ui:// resource URI in its _meta.ui — a URI the extension requires to be
unique only *within one server*, and which the published starter templates
ship with no server segment at all. Federate two upstreams built from one
template and they advertise the same URI for different interfaces.
fold served a read of that URI from whichever upstream listed it last, so a
host rendering one team's tool could get another team's app — and which one
it got depended on request history: a cold gateway answered from the probe
order, a warmed one from the list. Reproduced against two of the official
ext-apps example servers before this change, and after it each tool reads its
own upstream's bundle, cold or warm.
Those URIs are now minted per namespace as ui://fold/{namespace}/{rest} on
every egress surface — _meta.ui.resourceUri and the deprecated flat form,
resources/list, the URIs a read answers with, and resources/updated for a
subscribed interface — and resolved back to (upstream, original) on read,
subscribe, unsubscribe, and the orphan sweep. Reads route from the URI
itself: no probe, no affinity index, no history.
This is the one exception to fold never rewriting a resource URI, and it is
argued rather than assumed: that rule protects identifiers clients persist,
while a ui:// pointer is republished on every tools/list. It stays narrow —
only the ui:// scheme, a form derived from the namespace the operator already
chose (so it is stable across restarts, reloads, and instances), policy and
audit still deciding on the URI the upstream published, and passthrough
rewriting nothing. A ui:// URI embedded in a tool result is deliberately not
chased: following it there is response-body rewriting.
No config field, no new error code, no new audit method. The rewrite happens
where the list cache refills and is memoized beside the namespaced views, so
the request path is unchanged: added p50 178.7µs against the 5ms gate, and
the federated list benchmark is identical to the parent commit.
Design record, including the weaker fix this replaced and why harvesting
ownership would only have logged the wrong render rather than preventing it:
docs/design-mcp-apps.md.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
The defect
MCP Apps (SEP-1865) points a tool at an interactive interface through a
ui://resource URI in its_meta.ui. The extension requires that URI to be unique only within one server, and the published starter templates ship one with no server segment at all (ui://get-time/mcp-app.html). Federate two upstreams built from that template and they advertise the same URI for two different interfaces.fold answered a read of it from whichever upstream listed it last — so a host rendering one team's tool could get another team's app, and which one it got depended on request history:
Reproduced against two of the official
ext-appsexample servers, not inferred.The fix
Mint per namespace on egress, resolve back on ingress:
tools/list_meta.ui.resourceUriand the deprecated flat_meta["ui/resourceUri"]→ui://fold/{namespace}/{rest}resources/listui://entries minted; every other scheme untouchedresources/readresources/subscribe/unsubscribe/ orphan sweepresources/updatedPolicy and the tenant subset are decided on the URI the upstream published, the way a tool is authorized on its bare name — an existing rule keeps working, and a URI fold invented never has to appear in one.
The invariant this touches
fold never rewrites a resource URI. This is the one exception, and it is argued rather than assumed in
docs/design-mcp-apps.md: the rule protects identifiers clients persist, while aui://pointer is republished on everytools/list. It stays narrow — only theui://scheme, a minted form derived from the namespace the operator already chose (stable across restarts, reloads, and instances), and passthrough rewriting nothing. Aui://URI embedded in a tool result is deliberately not chased: following it there is response-body rewriting, which fold does not do.The design record also carries the weaker fix this replaced — harvest ownership from tool metadata, keep last-writer-wins, emit a conflict event — and why it was retired: it would have logged the wrong render rather than preventing it.
Verification
gateway/uiresource_test.goagainst real SDK peers: colliding URIs stay apart, flat and nested pointers agree, onlyui://is rewritten, passthrough untouched, subscribe round-trips under the right URI in both directions, policy decides on the upstream's URI, plus round-trip and split unit tables.-race;golangci-lintclean.BenchmarkFederatedListToolsmeasured against the parent commit is identical (30.1k vs 30.4k ns/op, 103 allocs both) — the rewrite happens at list-cache fill and is memoized beside the namespaced views.ext-appsservers: each tool's interface now reads from its own upstream, cold or warm.Scope
No config field, no new error code, no new audit method, no schema lockstep. Docs move with it: README gains a feature paragraph and its "Not implemented" bullet narrows to the handshake half of MCP Apps,
CLAUDE.mdrecords the exception, roadmap item 15 splits into shipped routing and remaining capability parity.Not in this PR: capability negotiation (§1 of the design record) — fold declares no client extensions upstream, so an upstream that gates on
io.modelcontextprotocol/uiserves fold its text-only fallback. Designed, unbuilt, and insurance rather than a live fix, since nothing shipping gates yet. Two further gaps belong to the extension's specification and are reports to file, not features.🤖 Generated with Claude Code