feat(mcp): update a running Shiny MCP App in place via update_<appId>_app (#4415)#4418
Merged
Conversation
Collaborator
Author
✅ Verified end-to-end in Claude Desktop (2026-07-17)Both open items from
The multi-instance case remains a model-judgment path (no server-side guarantee), so the caveat stays documented — but it works in practice for the common case. Pushed |
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.
Summary
Follow-up to #4414. Gives an MCP host/model an explicit update verb so it can change an already-open Shiny MCP App in place instead of re-opening it (which today renders a fresh instance per
open_*call).When an app declares
mcpConfigure(arguments = ...), Shiny now auto-registers a companionupdate_<appId>_apptool. A model call to it runs server-side, targets a specific running session, and pushes new arguments through the existingmcpUpdates()reactive channel — no re-render, no author code beyond the singleobserve(mcpUpdates())apps already write.Design (5 decisions)
update_*takes a requiredsessiontoken; no broadcast/most-recent guessing. To update several instances the model loops.reactiveValoverlay — each MCP session holds a server-pushreactiveVal;mcpUpdates()overlays it on the client-delivered init args (per-key, latest wins) then allow-list filters. Successive pushes accumulate.appsByToken— keyed bysession$token; unknown/stale/non-MCP token → tool error (never silent success).argumentsdeclared — handler pushes insidewithReactiveDomain(session, …)+requestFlush()so the app's observer fires in the right context.session$tokento the model (reserved-key envelope throughmcpUpdateModelContext, + a text instruction);mcpUpdateModelContext()payload now stampssessionintostructuredContent.Entirely R-side — the JS bridge already forwards these messages.
Known limitations (see
mcp/limitations.md){session, state}structured content + instruction so the model can echo the id. (Verify in Claude Desktop.)Docs & tests
mcp/design-mcp-update-running-app.md; plan:mcp/implementation-plan-update-running-app.md.?mcp-sessionroxygen,mcp/design-mcpConfigure.md,mcp/limitations.md,NEWS.mdupdated; demo apps (clock/demo/cars) get explanatory comments — the update path needs zero app-code change.🤖 Generated with Claude Code