feat: export method names as consts (#192)
* feat: export method names as consts * rename * fix * format
This commit is contained in:
parent
c475dc3c17
commit
773943cad1
2 changed files with 57 additions and 0 deletions
|
|
@ -562,3 +562,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
src/types.ts
14
src/types.ts
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue