Skip to content

Commit d97ae07

Browse files
authored
Merge pull request #88 from modelcontextprotocol/ochafik/theme-layout-enums
types: add McpUiTheme, McpUiDisplayMode
2 parents 5ae2921 + cb571bf commit d97ae07

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/types.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ type VerifySchemaMatches<TSchema extends z.ZodTypeAny, TInterface> =
4343
*/
4444
export const LATEST_PROTOCOL_VERSION = "2025-11-21";
4545

46+
/**
47+
* Color theme preference for the host environment.
48+
* @see {@link McpUiHostContext.theme}
49+
*/
50+
export type McpUiTheme = "light" | "dark";
51+
52+
/** Runtime validation schema for {@link McpUiTheme}. */
53+
export const McpUiThemeSchema = z.enum(["light", "dark"]);
54+
55+
/**
56+
* Display mode for UI presentation.
57+
* - `inline`: Embedded within the conversation flow
58+
* - `fullscreen`: Expanded to fill the available viewport
59+
* - `pip`: Picture-in-picture floating window
60+
*
61+
* @see {@link McpUiHostContext.displayMode}
62+
*/
63+
export type McpUiDisplayMode = "inline" | "fullscreen" | "pip";
64+
65+
/** Runtime validation schema for {@link McpUiDisplayMode}. */
66+
export const McpUiDisplayModeSchema = z.enum(["inline", "fullscreen", "pip"]);
67+
4668
/**
4769
* Request to open an external URL in the host's default browser.
4870
*
@@ -425,12 +447,12 @@ export interface McpUiHostContext {
425447
* Current color theme preference.
426448
* @example "dark"
427449
*/
428-
theme?: "light" | "dark";
450+
theme?: McpUiTheme;
429451
/**
430452
* How the UI is currently displayed.
431453
* @example "inline"
432454
*/
433-
displayMode?: "inline" | "fullscreen" | "pip";
455+
displayMode?: McpUiDisplayMode;
434456
/**
435457
* Display modes the host supports.
436458
* Apps can use this to offer mode-switching UI if applicable.
@@ -501,8 +523,8 @@ export const McpUiHostContextSchema: z.ZodType<McpUiHostContext> = z.object({
501523
tool: ToolSchema,
502524
})
503525
.optional(),
504-
theme: z.enum(["light", "dark"]).optional(),
505-
displayMode: z.enum(["inline", "fullscreen", "pip"]).optional(),
526+
theme: McpUiThemeSchema.optional(),
527+
displayMode: McpUiDisplayModeSchema.optional(),
506528
availableDisplayModes: z.array(z.string()).optional(),
507529
viewport: z
508530
.object({

0 commit comments

Comments
 (0)