feat(mcp): replace shiny.mcp.* options with mcpConfigure()#4414
Merged
Conversation
…estoreContext init path Real-host testing (Claude Desktop) showed init-arg widget auto-restore is unreachable (UI renders at resources/read before args exist), hosts re-render per tool call, and the restore-vs-mcpUpdates split raced. Route every ontoolinput to mcpUpdates(); remove createRestoreObservers, the server.R MCP restore branch, the JS init-frame injection + socket-start gate, encodeMcpRestore, and mcpFilterRestore. Document the constraints in mcp/limitations.md.
schloerke
added a commit
that referenced
this pull request
Jul 17, 2026
The @param arguments roxygen still claimed init args could be read 'via input/bookmark restoration (init)'. That auto-restore path was proven unworkable for MCP (the UI renders at resources/read before args exist) and removed in #4414. Describe the real mechanism instead: a single mcpUpdates() observer applying updateXxxInput(), with the unavoidable open flash noted. Handles the leftover doc correction deferred as a non-goal from #4415's design spec. Regenerated man/mcpConfigure.Rd.
This was referenced Jul 17, 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.
Summary
Replaces the seven
options(shiny.mcp.*)MCP App options with a single validatedmcpConfigure()function backed by.globals$mcp, tightening how an app opts into and configures MCP support. Also renames the session helpermcpToolInput()→mcpUpdates(), and routes the model's app-opening arguments through Shiny's bookmarkRestoreContextso inputs initialize flash-free, while post-init argument updates flow through the reactivemcpUpdates()channel.Motivation:
options()is an unregulated, process-global namespace (no validation, no discoverability, silent typos, cross-app leakage).mcpConfigure()is one gated, documented, autocomplete-friendly entry point.Public API
mcpConfigure()call ⇒ MCP is never served. InvalidappIdnow errors (was warn-and-ignore).appId(open_shiny_app/open_<appId>_app) — drops the manualtool$nameknob; gateway uniqueness is automatic.argumentsusesellmertypes (consistent withregisterMcpTool()), published as the toolinputSchemaand enforced as an allow-list on both the init and update paths.Argument delivery
initframe, and applied via Shiny'sRestoreContext(standard inputs auto-restore viarestoreInput(), no flash;onRestore()covers non-input state). Works without the app enabling bookmarking (the restore-callback observers were extracted intocreateRestoreObservers(); bookmarking behavior is unchanged).mcpUpdates(), wired by the author withupdateXxxInput().Notes
options(shiny.mcp.*), no deprecation shims. The threesendCustomMessagechannel names (shiny.mcp.updateModelContext/sendMessage/requestDisplayMode) are protocol channels, not options, and are unchanged.mcp/(design-mcpConfigure.md,plan-mcpConfigure.md,notes-restore-spike.md).Testing
devtools::test(): 3334 pass (14 pre-existing, unrelatedtest-zzz-st2-download.Rfailures).NEWS.mdbullet references PR#XXXX— replace with this PR number before merge.🤖 Built with subagent-driven development (9 planned tasks + 1 final-review fix, each independently reviewed).