Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/spec.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,46 @@ export interface McpUiToolMeta {
*/
visibility?: McpUiToolVisibility[];
}

/**
* Method string constants for MCP Apps protocol messages.
*
* These constants provide a type-safe way to check message methods without
* accessing internal Zod schema properties. External libraries should use
* these constants instead of accessing `schema.shape.method._def.values[0]`.
*
* @example
* ```typescript
* import { SANDBOX_PROXY_READY_METHOD } from '@modelcontextprotocol/ext-apps';
*
* if (event.data.method === SANDBOX_PROXY_READY_METHOD) {
* // Handle sandbox proxy ready notification
* }
* ```
*/
export const OPEN_LINK_METHOD: McpUiOpenLinkRequest["method"] = "ui/open-link";
export const MESSAGE_METHOD: McpUiMessageRequest["method"] = "ui/message";
export const SANDBOX_PROXY_READY_METHOD: McpUiSandboxProxyReadyNotification["method"] =
"ui/notifications/sandbox-proxy-ready";
export const SANDBOX_RESOURCE_READY_METHOD: McpUiSandboxResourceReadyNotification["method"] =
"ui/notifications/sandbox-resource-ready";
export const SIZE_CHANGED_METHOD: McpUiSizeChangedNotification["method"] =
"ui/notifications/size-changed";
export const TOOL_INPUT_METHOD: McpUiToolInputNotification["method"] =
"ui/notifications/tool-input";
export const TOOL_INPUT_PARTIAL_METHOD: McpUiToolInputPartialNotification["method"] =
"ui/notifications/tool-input-partial";
export const TOOL_RESULT_METHOD: McpUiToolResultNotification["method"] =
"ui/notifications/tool-result";
export const TOOL_CANCELLED_METHOD: McpUiToolCancelledNotification["method"] =
"ui/notifications/tool-cancelled";
export const HOST_CONTEXT_CHANGED_METHOD: McpUiHostContextChangedNotification["method"] =
"ui/notifications/host-context-changed";
export const RESOURCE_TEARDOWN_METHOD: McpUiResourceTeardownRequest["method"] =
"ui/resource-teardown";
export const INITIALIZE_METHOD: McpUiInitializeRequest["method"] =
"ui/initialize";
export const INITIALIZED_METHOD: McpUiInitializedNotification["method"] =
"ui/notifications/initialized";
export const REQUEST_DISPLAY_MODE_METHOD: McpUiRequestDisplayModeRequest["method"] =
"ui/request-display-mode";
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
// Re-export all types from spec.types.ts
export {
LATEST_PROTOCOL_VERSION,
OPEN_LINK_METHOD,
MESSAGE_METHOD,
SANDBOX_PROXY_READY_METHOD,
SANDBOX_RESOURCE_READY_METHOD,
SIZE_CHANGED_METHOD,
TOOL_INPUT_METHOD,
TOOL_INPUT_PARTIAL_METHOD,
TOOL_RESULT_METHOD,
TOOL_CANCELLED_METHOD,
HOST_CONTEXT_CHANGED_METHOD,
RESOURCE_TEARDOWN_METHOD,
INITIALIZE_METHOD,
INITIALIZED_METHOD,
REQUEST_DISPLAY_MODE_METHOD,
type McpUiTheme,
type McpUiDisplayMode,
type McpUiStyleVariableKey,
Expand Down
Loading