Skip to content

feat: add UI preload and result-driven close controls - #751

Open
sunnymitramsft wants to merge 1 commit into
modelcontextprotocol:mainfrom
sunnymitramsft:feat/ui-preload-close
Open

feat: add UI preload and result-driven close controls#751
sunnymitramsft wants to merge 1 commit into
modelcontextprotocol:mainfrom
sunnymitramsft:feat/ui-preload-close

Conversation

@sunnymitramsft

Copy link
Copy Markdown

Summary

  • add _meta.ui.preload with "optional" (default) and "disabled" modes
  • standardize _meta["ui/close"] on tool results for invocation-scoped View suppression or teardown
  • expose getToolUiPreload, shouldCloseToolUi, and UI_CLOSE_META_KEY for host and server integrations
  • generate matching Zod and JSON schemas and document the lifecycle contract in the draft specification

Motivation

A server may only know after executing a tool whether a View adds value. Separate UI and non-UI tools do not solve cases where both variants represent the same intent and accept the same arguments, such as search_orders(query) returning one exact match, several possible matches, or no matches.

This keeps UI discovery early enough for host optimization while allowing servers to defer loading and suppress or close a View when the result can be presented without it.

Compatibility

The change is additive. Existing resourceUri behavior remains the default, omitted or unrecognized preload modes resolve to "optional", hosts may ignore metadata they do not recognize, and no new RPC method or transport behavior is introduced.

Validation

  • npm run build
  • npm exec bun test src (290 passed)
  • npm exec bun test src/app-bridge.test.ts (156 passed)
  • typedoc --treatValidationWarningsAsErrors --emit none
  • Prettier check for all changed source and generated files

npm test completed with 377 passed and 2 skipped; 2 unrelated PDF-server tests could not create directory symlinks on Windows (EPERM) before their assertions ran.

Closes #744.

Follow-up to modelcontextprotocol/modelcontextprotocol#3260, which was moved here per MCP Apps Working Group guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add UI "preload" Control and "ui/close" Signal for MCP Apps Tool-Driven Widgets

1 participant