Skip to main content
import type {
  McpUiInitializeRequest,
  McpUiInitializeResult,
  McpUiOpenLinkRequest,
  McpUiOpenLinkResult,
  McpUiMessageRequest,
  McpUiMessageResult,
  McpUiUpdateModelContextRequest,
  McpUiRequestDisplayModeRequest,
  McpUiRequestDisplayModeResult,
  McpUiResourceTeardownRequest,
  McpUiResourceTeardownResult,
  AppRequest,
  AppNotification,
  AppResult,
} from "sunpeak";

Request / Result Types

Initialization

TypeMethodDirectionDescription
McpUiInitializeRequestui/initializeView → HostApp info, capabilities, protocol version
McpUiInitializeResultHost → ViewProtocol version, host info, capabilities, context

View → Host Requests

TypeMethodDescription
McpUiOpenLinkRequestui/open-linkOpen URL: { url: string }
McpUiOpenLinkResult{ isError?: boolean }
McpUiMessageRequestui/messageSend message: { role: "user"; content: ContentBlock[] }
McpUiMessageResult{ isError?: boolean }
McpUiUpdateModelContextRequestui/update-model-contextUpdate context: { content?; structuredContent? }
McpUiRequestDisplayModeRequestui/request-display-modeRequest mode: { mode: McpUiDisplayMode }
McpUiRequestDisplayModeResult{ mode: McpUiDisplayMode } (actual mode set)

Host → View Requests

TypeMethodDescription
McpUiResourceTeardownRequestui/resource-teardownGraceful shutdown: {}
McpUiResourceTeardownResult{}

Notification Types

Host → View

TypeMethodDescription
McpUiToolInputNotificationui/notifications/tool-inputComplete tool arguments
McpUiToolInputPartialNotificationui/notifications/tool-input-partialStreaming partial arguments
McpUiToolResultNotificationui/notifications/tool-resultTool execution result
McpUiToolCancelledNotificationui/notifications/tool-cancelledTool execution cancelled
McpUiHostContextChangedNotificationui/notifications/host-context-changedPartial context update

View → Host

TypeMethodDescription
McpUiInitializedNotificationui/notifications/initializedInitialization complete
McpUiSizeChangedNotificationui/notifications/size-changedUI size change: { width?; height? }

Union Types

These union types represent all possible message types in the protocol:
TypeDescription
AppRequestAll request types (UI requests + proxied MCP server requests + ping)
AppNotificationAll notification types (both directions)
AppResultAll result types

Method Constants

Type-safe string constants for protocol method names.
import {
  INITIALIZE_METHOD,
  INITIALIZED_METHOD,
  OPEN_LINK_METHOD,
  MESSAGE_METHOD,
  REQUEST_DISPLAY_MODE_METHOD,
  RESOURCE_TEARDOWN_METHOD,
  SIZE_CHANGED_METHOD,
  TOOL_INPUT_METHOD,
  TOOL_INPUT_PARTIAL_METHOD,
  TOOL_RESULT_METHOD,
  TOOL_CANCELLED_METHOD,
  HOST_CONTEXT_CHANGED_METHOD,
} from "sunpeak";
ConstantValue
INITIALIZE_METHOD"ui/initialize"
INITIALIZED_METHOD"ui/notifications/initialized"
OPEN_LINK_METHOD"ui/open-link"
MESSAGE_METHOD"ui/message"
REQUEST_DISPLAY_MODE_METHOD"ui/request-display-mode"
RESOURCE_TEARDOWN_METHOD"ui/resource-teardown"
SIZE_CHANGED_METHOD"ui/notifications/size-changed"
TOOL_INPUT_METHOD"ui/notifications/tool-input"
TOOL_INPUT_PARTIAL_METHOD"ui/notifications/tool-input-partial"
TOOL_RESULT_METHOD"ui/notifications/tool-result"
TOOL_CANCELLED_METHOD"ui/notifications/tool-cancelled"
HOST_CONTEXT_CHANGED_METHOD"ui/notifications/host-context-changed"

Other Constants

ConstantValueDescription
LATEST_PROTOCOL_VERSION"2026-01-26"Current protocol version
RESOURCE_MIME_TYPE"text/html;profile=mcp-app"MIME type for MCP App resources
RESOURCE_URI_META_KEY"ui/resourceUri"Deprecated metadata key for tool-resource linkage
EXTENSION_ID"io.modelcontextprotocol/ui"Extension identifier for capability negotiation

Zod Schemas

Every type has a corresponding Zod schema exported for runtime validation:
import {
  McpUiThemeSchema,
  McpUiDisplayModeSchema,
  McpUiHostContextSchema,
  McpUiHostCapabilitiesSchema,
  McpUiAppCapabilitiesSchema,
  McpUiInitializeRequestSchema,
  McpUiInitializeResultSchema,
  McpUiToolInputNotificationSchema,
  McpUiToolResultNotificationSchema,
  McpUiToolCancelledNotificationSchema,
  McpUiHostContextChangedNotificationSchema,
  McpUiResourceTeardownRequestSchema,
  McpUiResourceTeardownResultSchema,
  McpUiResourceCspSchema,
  McpUiResourcePermissionsSchema,
  McpUiResourceMetaSchema,
  McpUiToolVisibilitySchema,
  McpUiToolMetaSchema,
  // ... and more
} from "sunpeak";
Schema names follow the pattern {TypeName}Schema (e.g., McpUiThemeMcpUiThemeSchema).