modelcontextprotocol / modelcontextprotocol/ext-apps
ui/update-model-context: How should hosts handle multiple instances of the same app resource?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 387
- Avg merge
- 3h 21m
- Merged PRs (30d)
- 6
Description
Problem
When a host renders the same MCP App resource URI multiple times in a single session (e.g., the same tool is invoked twice, producing two iframes for the same ui:// resource), each instance independently calls ui/update-model-context. The spec doesn't provide guidance on how the host should scope these updates.
A natural host-side key for storing context is {extension}_{resourceUri}, but this means all instances of the same resource share a single slot. The last instance to send an update overwrites the others, and the model sees only that instance's state on the next turn — potentially the wrong one.
Example
- User invokes a tool that renders
ui://my-extension/editor— Instance A appears - User invokes the same tool again — Instance B appears
- User interacts with Instance A, which sends
ui/update-model-contextwith{ counter: 5 } - User interacts with Instance B, which sends
ui/update-model-contextwith{ counter: 0 } - On the next turn, the model sees
counter: 0— Instance B's state silently overwrote Instance A's
Questions
-
Should the spec recommend instance-scoped keys? For example, the host could append a render-specific identifier (message ID, sequence number) to the context key so each instance gets its own slot.
-
Or should last-write-wins be the expected behavior? If the spec considers each resource URI to represent a single logical piece of state, then the latest update is correct by definition — the "active" instance is whichever the user touched last.
-
Does this interact with the slots proposal (#500)? Slots address multiple context dimensions within a single app instance. Multi-instance scoping is orthogonal — you could have per-instance slots, or per-instance single context. But the two proposals share the question of key granularity.
Context
We ran into this while implementing ui/update-model-context in goose. Our current implementation uses last-write-wins keyed by {extension}__{resourceUri}, which is simple and works for the common case (one instance per resource). We'd like spec guidance before adding instance-scoped keys, since it affects how apps reason about their context lifecycle.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the ui/update-model-context behavior described here and compare it with the slots proposal in issue #500. Review the instance-scoping and last-write-wins alternatives, then define what spec guidance is needed for repeated resource instances and how completion would be verified.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100