Merge pull request #152 from modelcontextprotocol/martinalong/mcp-apps/display-mode-updates

[MCP Apps] Have apps request display mode instead
This commit is contained in:
martinalong 2025-12-15 16:12:45 -08:00 • committed by GitHub
commit c516cf0894
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 272 additions and 1 deletions

View file

@ -2845,6 +2845,67 @@
},
"additionalProperties": {}
},
"McpUiRequestDisplayModeRequest": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"method": {
"type": "string",
"const": "ui/request-display-mode"
},
"params": {
"type": "object",
"properties": {
"mode": {
"description": "The display mode being requested.",
"anyOf": [
{
"type": "string",
"const": "inline"
},
{
"type": "string",
"const": "fullscreen"
},
{
"type": "string",
"const": "pip"
}
]
}
},
"required": ["mode"],
"additionalProperties": false
}
},
"required": ["method", "params"],
"additionalProperties": false
},
"McpUiRequestDisplayModeResult": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"mode": {
"description": "The display mode that was actually set. May differ from requested if not supported.",
"anyOf": [
{
"type": "string",
"const": "inline"
},
{
"type": "string",
"const": "fullscreen"
},
{
"type": "string",
"const": "pip"
}
]
}
},
"required": ["mode"],
"additionalProperties": {}
},
"McpUiResourceCsp": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",

View file

@ -95,6 +95,14 @@ export type McpUiResourceMetaSchemaInferredType = z.infer<
typeof generated.McpUiResourceMetaSchema
>;
export type McpUiRequestDisplayModeRequestSchemaInferredType = z.infer<
typeof generated.McpUiRequestDisplayModeRequestSchema
>;
export type McpUiRequestDisplayModeResultSchemaInferredType = z.infer<
typeof generated.McpUiRequestDisplayModeResultSchema
>;
export type McpUiMessageRequestSchemaInferredType = z.infer<
typeof generated.McpUiMessageRequestSchema
>;
@ -217,6 +225,18 @@ expectType<spec.McpUiResourceCsp>({} as McpUiResourceCspSchemaInferredType);
expectType<McpUiResourceCspSchemaInferredType>({} as spec.McpUiResourceCsp);
expectType<spec.McpUiResourceMeta>({} as McpUiResourceMetaSchemaInferredType);
expectType<McpUiResourceMetaSchemaInferredType>({} as spec.McpUiResourceMeta);
expectType<spec.McpUiRequestDisplayModeRequest>(
{} as McpUiRequestDisplayModeRequestSchemaInferredType,
);
expectType<McpUiRequestDisplayModeRequestSchemaInferredType>(
{} as spec.McpUiRequestDisplayModeRequest,
);
expectType<spec.McpUiRequestDisplayModeResult>(
{} as McpUiRequestDisplayModeResultSchemaInferredType,
);
expectType<McpUiRequestDisplayModeResultSchemaInferredType>(
{} as spec.McpUiRequestDisplayModeResult,
);
expectType<spec.McpUiMessageRequest>(
{} as McpUiMessageRequestSchemaInferredType,
);

View file

@ -424,6 +424,31 @@ export const McpUiResourceMetaSchema = z.object({
),
});
/**
* @description Request to change the display mode of the UI.
* The host will respond with the actual display mode that was set,
* which may differ from the requested mode if not supported.
* @see {@link app.App.requestDisplayMode} for the method that sends this request
*/
export const McpUiRequestDisplayModeRequestSchema = z.object({
method: z.literal("ui/request-display-mode"),
params: z.object({
/** @description The display mode being requested. */
mode: McpUiDisplayModeSchema.describe("The display mode being requested."),
}),
});
/**
* @description Result from requesting a display mode change.
* @see {@link McpUiRequestDisplayModeRequest}
*/
export const McpUiRequestDisplayModeResultSchema = z.looseObject({
/** @description The display mode that was actually set. May differ from requested if not supported. */
mode: McpUiDisplayModeSchema.describe(
"The display mode that was actually set. May differ from requested if not supported.",
),
});
/**
* @description Request to send a message to the host's chat interface.
* @see {@link app.App.sendMessage} for the method that sends this request