Skip to content

Commit eedf28d

Browse files
committed
feat: export method names as consts
1 parent e514e6c commit eedf28d

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/spec.types.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,38 @@ export interface McpUiToolMeta {
548548
*/
549549
visibility?: McpUiToolVisibility[];
550550
}
551+
552+
/**
553+
* Method string constants for MCP UI protocol messages.
554+
*
555+
* These constants provide a type-safe way to check message methods without
556+
* accessing internal Zod schema properties. External libraries should use
557+
* these constants instead of accessing `schema.shape.method._def.values[0]`.
558+
*
559+
* @example
560+
* ```typescript
561+
* import { MCP_UI_SANDBOX_PROXY_READY_METHOD } from '@modelcontextprotocol/ext-apps';
562+
*
563+
* if (event.data.method === MCP_UI_SANDBOX_PROXY_READY_METHOD) {
564+
* // Handle sandbox proxy ready notification
565+
* }
566+
* ```
567+
*/
568+
export const MCP_UI_OPEN_LINK_METHOD = "ui/open-link";
569+
export const MCP_UI_MESSAGE_METHOD = "ui/message";
570+
export const MCP_UI_SANDBOX_PROXY_READY_METHOD =
571+
"ui/notifications/sandbox-proxy-ready";
572+
export const MCP_UI_SANDBOX_RESOURCE_READY_METHOD =
573+
"ui/notifications/sandbox-resource-ready";
574+
export const MCP_UI_SIZE_CHANGED_METHOD = "ui/notifications/size-changed";
575+
export const MCP_UI_TOOL_INPUT_METHOD = "ui/notifications/tool-input";
576+
export const MCP_UI_TOOL_INPUT_PARTIAL_METHOD =
577+
"ui/notifications/tool-input-partial";
578+
export const MCP_UI_TOOL_RESULT_METHOD = "ui/notifications/tool-result";
579+
export const MCP_UI_TOOL_CANCELLED_METHOD = "ui/notifications/tool-cancelled";
580+
export const MCP_UI_HOST_CONTEXT_CHANGED_METHOD =
581+
"ui/notifications/host-context-changed";
582+
export const MCP_UI_RESOURCE_TEARDOWN_METHOD = "ui/resource-teardown";
583+
export const MCP_UI_INITIALIZE_METHOD = "ui/initialize";
584+
export const MCP_UI_INITIALIZED_METHOD = "ui/notifications/initialized";
585+
export const MCP_UI_REQUEST_DISPLAY_MODE_METHOD = "ui/request-display-mode";

src/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
1212
// Re-export all types from spec.types.ts
1313
export {
1414
LATEST_PROTOCOL_VERSION,
15+
MCP_UI_OPEN_LINK_METHOD,
16+
MCP_UI_MESSAGE_METHOD,
17+
MCP_UI_SANDBOX_PROXY_READY_METHOD,
18+
MCP_UI_SANDBOX_RESOURCE_READY_METHOD,
19+
MCP_UI_SIZE_CHANGED_METHOD,
20+
MCP_UI_TOOL_INPUT_METHOD,
21+
MCP_UI_TOOL_INPUT_PARTIAL_METHOD,
22+
MCP_UI_TOOL_RESULT_METHOD,
23+
MCP_UI_TOOL_CANCELLED_METHOD,
24+
MCP_UI_HOST_CONTEXT_CHANGED_METHOD,
25+
MCP_UI_RESOURCE_TEARDOWN_METHOD,
26+
MCP_UI_INITIALIZE_METHOD,
27+
MCP_UI_INITIALIZED_METHOD,
28+
MCP_UI_REQUEST_DISPLAY_MODE_METHOD,
1529
type McpUiTheme,
1630
type McpUiDisplayMode,
1731
type McpUiStyleVariableKey,

0 commit comments

Comments
 (0)