Skip to content

Commit cf9fed1

Browse files
martinalongclaude
andauthored
[MCP Apps] Add appCapabilities.availableDisplayModes documentation to spec (#331)
* Add appCapabilities.availableDisplayModes documentation to spec Document the availableDisplayModes field in McpUiAppCapabilities that allows apps to declare which display modes they support. This enables hosts to compute the intersection of host and app capabilities and only offer appropriate display mode controls. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Address PR review feedback - Change "Guest UI" to "View" terminology - Add "View" prefix to availableDisplayModes heading for disambiguation - Remove intersection logic - host only checks its own supported modes - Remove assumption that apps must support inline mode - Simplify host behavior to honor/reject based on its own capabilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Add appCapabilities.availableDisplayModes to types - Add `availableDisplayModes` field to `McpUiAppCapabilities` so apps can declare which display modes they support - Change `HostContext.availableDisplayModes` type from `string[]` to `McpUiDisplayMode[]` for type safety - Regenerate schemas 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Address Olivier's feedback - consolidate display mode docs - Remove separate "App Capabilities" section for availableDisplayModes - Add display mode requirements to existing ui/request-display-mode section: - Host MUST NOT switch View to mode not in appCapabilities.availableDisplayModes - Host MAY decline requests from Views that didn't declare modes - View MUST declare supported modes during initialization 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Restore McpUiAppCapabilities docs and fix display mode clause - Restore McpUiAppCapabilities interface documentation with availableDisplayModes - Restore "View MUST check if the requested mode is in availableDisplayModes from host context" clause that was accidentally removed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Create unified Display Modes section Consolidate all display mode documentation into a single section: - Display mode types (inline, fullscreen, pip) - Declaring support from View (appCapabilities.availableDisplayModes) - Declaring support from Host (HostContext.availableDisplayModes) - Requesting changes (ui/request-display-mode) - Notifying changes (ui/notifications/host-context-changed) - All MUST/SHOULD requirements for View and Host behavior The ui/request-display-mode in Requests section now references the Display Modes section for behavior details. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove mode coercion clause from display modes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Regenerate schemas with correct version 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 51e984f commit cf9fed1

4 files changed

Lines changed: 174 additions & 14 deletions

File tree

specification/draft/apps.mdx

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,27 @@ UI iframes can use the following subset of standard MCP protocol messages:
505505
- `ui/initialize``ui/notifications/initialized` - MCP-like handshake (replaces custom iframe-ready pattern in MCP-UI)
506506
- `ping` - Connection health check
507507

508+
### App Capabilities in `ui/initialize`
509+
510+
When the View sends an `ui/initialize` request to the Host, it MUST include its capabilities in the `appCapabilities` field:
511+
512+
```typescript
513+
interface McpUiAppCapabilities {
514+
/** Experimental features (structure TBD). */
515+
experimental?: {};
516+
/** App exposes MCP-style tools that the host can call. */
517+
tools?: {
518+
/** App supports tools/list_changed notifications. */
519+
listChanged?: boolean;
520+
};
521+
/**
522+
* Display modes the app supports. See Display Modes section for details.
523+
* @example ["inline", "fullscreen"]
524+
*/
525+
availableDisplayModes?: Array<"inline" | "fullscreen" | "pip">;
526+
}
527+
```
528+
508529
### Host Context in `McpUiInitializeResult`
509530

510531
When the View sends an `ui/initialize` request to the Host, the Host SHOULD include UI-specific context in the `McpUiInitializeResult`'s `hostContext` field:
@@ -709,6 +730,62 @@ bridge.onsizechange = ({ width, height }) => {
709730

710731
Apps using the SDK automatically send size-changed notifications via ResizeObserver when `autoResize` is enabled (the default). The notifications are debounced and only sent when dimensions actually change.
711732

733+
### Display Modes
734+
735+
Views can be displayed in different modes depending on the host's capabilities and the view's declared support.
736+
737+
```typescript
738+
type McpUiDisplayMode = "inline" | "fullscreen" | "pip";
739+
```
740+
741+
- **inline**: Default mode, embedded within the host's content flow
742+
- **fullscreen**: View takes over the full screen/window
743+
- **pip**: Picture-in-picture, floating overlay
744+
745+
#### Declaring Support
746+
747+
**View (`appCapabilities.availableDisplayModes`):**
748+
749+
Views declare which display modes they support in the `ui/initialize` request via `appCapabilities.availableDisplayModes`. This allows hosts to only offer display mode options that the view can handle.
750+
751+
```typescript
752+
// Example: View declares support for inline and fullscreen
753+
{
754+
method: "ui/initialize",
755+
params: {
756+
appCapabilities: {
757+
availableDisplayModes: ["inline", "fullscreen"]
758+
},
759+
// ...
760+
}
761+
}
762+
```
763+
764+
**Host (`HostContext.availableDisplayModes`):**
765+
766+
Hosts declare which display modes they support in `HostContext.availableDisplayModes`. Views should check this before requesting a mode change.
767+
768+
#### Requesting Changes
769+
770+
Views request display mode changes via `ui/request-display-mode`. See the Requests section for message format.
771+
772+
#### Notifying Changes
773+
774+
Hosts notify views of display mode changes via `ui/notifications/host-context-changed` with the `displayMode` field.
775+
776+
#### Requirements
777+
778+
**View behavior:**
779+
- View MUST declare all display modes it supports in `appCapabilities.availableDisplayModes` during initialization.
780+
- View MUST check if the requested mode is in `availableDisplayModes` from host context before requesting a mode change.
781+
- View MUST handle the response mode differing from the requested mode.
782+
783+
**Host behavior:**
784+
- Host MUST NOT switch the View to a display mode that does not appear in its `appCapabilities.availableDisplayModes`, if set.
785+
- Host MUST return the resulting mode (whether updated or not) in the response to `ui/request-display-mode`.
786+
- If the requested mode is not available, Host SHOULD return the current display mode in the response.
787+
- Host MAY decline display mode requests from Views that did not declare said modes in their capabilities.
788+
712789
### Theming
713790

714791
Hosts can optionally pass CSS custom properties via `HostContext.styles.variables` for visual cohesion with the host environment.
@@ -977,15 +1054,7 @@ Host behavior:
9771054
}
9781055
```
9791056

980-
Host behavior:
981-
* App MUST check if the requested mode is in `availableDisplayModes` from host context.
982-
* It is up to the host whether it switches to the requested mode, but the host MUST return the resulting mode (whether updated or not) in the response.
983-
* If the requested mode is not available, Host SHOULD return the current display mode in the response.
984-
* Host MAY coerce modes on certain platforms (e.g., "pip" to "fullscreen" on mobile).
985-
986-
View behavior:
987-
* View SHOULD check `availableDisplayModes` in host context before requesting a mode change.
988-
* View MUST handle the response mode differing from the requested mode.
1057+
See the Display Modes section for detailed behavior requirements.
9891058

9901059
`ui/update-model-context` - Update the model context
9911060

src/generated/schema.json

Lines changed: 87 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generated/schema.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/spec.types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export interface McpUiHostContext {
321321
/** @description How the UI is currently displayed. */
322322
displayMode?: McpUiDisplayMode;
323323
/** @description Display modes the host supports. */
324-
availableDisplayModes?: string[];
324+
availableDisplayModes?: McpUiDisplayMode[];
325325
/**
326326
* @description Container dimensions. Represents the dimensions of the iframe or other
327327
* container holding the app. Specify either width or maxWidth, and either height or maxHeight.
@@ -487,6 +487,8 @@ export interface McpUiAppCapabilities {
487487
/** @description App supports tools/list_changed notifications. */
488488
listChanged?: boolean;
489489
};
490+
/** @description Display modes the app supports. */
491+
availableDisplayModes?: McpUiDisplayMode[];
490492
}
491493

492494
/**

0 commit comments

Comments
 (0)