* feat: implement ui/notifications/tool-cancelled throughout SDK Wire the tool-cancelled notification that hosts MUST send when tool execution is cancelled (user action, timeout, classifier intervention, etc.): - Add McpUiToolCancelledNotification type in spec.types.ts - Generate Zod schema via ts-to-zod - Add AppBridge.sendToolCancelled() method for hosts - Add App.ontoolcancelled setter for guest UIs - Export type and schema from types.ts - Add tests for notification with/without reason 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add App.onteardown handler for graceful shutdown Wire the guest UI side of ui/resource-teardown request: - Add onteardown setter in App class for guest UIs to handle teardown - Allow ui/resource-teardown in assertRequestHandlerCapability - Import McpUiResourceTeardownRequest/Result types - Add tests for sync and async cleanup handlers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat(example): wire tool-cancelled and teardown in basic-host Update basic-host example to properly use the new notifications: - Send sendToolCancelled when tool call promise rejects - Send sendResourceTeardown when React component unmounts - Store appBridge ref for cleanup access 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(example): implement graceful teardown per spec recommendation Address review feedback: the host now waits for guest's teardown response before unmounting, following the spec: "Host SHOULD wait for a response before tearing down the resource (to prevent data loss)." Changes: - Add close button to tool call panels - Two-phase unmount: isDestroying state dims panel and disables events - sendResourceTeardown() completes before component removal - Non-app tool results close immediately 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat(examples): add onteardown handlers to demo apps Demonstrate graceful shutdown with simulated 500ms cleanup work. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
/**
|
|
* MCP Apps Protocol Types and Schemas
|
|
*
|
|
* This file re-exports types from spec.types.ts and schemas from generated/schema.ts.
|
|
* Compile-time verification is handled by generated/schema.test.ts.
|
|
*
|
|
* @see spec.types.ts for the source of truth TypeScript interfaces
|
|
* @see generated/schema.ts for auto-generated Zod schemas
|
|
* @see generated/schema.test.ts for compile-time verification
|
|
*/
|
|
|
|
// Re-export all types from spec.types.ts
|
|
export {
|
|
LATEST_PROTOCOL_VERSION,
|
|
type McpUiTheme,
|
|
type McpUiDisplayMode,
|
|
type McpUiOpenLinkRequest,
|
|
type McpUiOpenLinkResult,
|
|
type McpUiMessageRequest,
|
|
type McpUiMessageResult,
|
|
type McpUiSandboxProxyReadyNotification,
|
|
type McpUiSandboxResourceReadyNotification,
|
|
type McpUiSizeChangedNotification,
|
|
type McpUiToolInputNotification,
|
|
type McpUiToolInputPartialNotification,
|
|
type McpUiToolResultNotification,
|
|
type McpUiToolCancelledNotification,
|
|
type McpUiHostContext,
|
|
type McpUiHostContextChangedNotification,
|
|
type McpUiResourceTeardownRequest,
|
|
type McpUiResourceTeardownResult,
|
|
type McpUiHostCapabilities,
|
|
type McpUiAppCapabilities,
|
|
type McpUiInitializeRequest,
|
|
type McpUiInitializeResult,
|
|
type McpUiInitializedNotification,
|
|
type McpUiResourceCsp,
|
|
type McpUiResourceMeta,
|
|
} from "./spec.types.js";
|
|
|
|
// Re-export all schemas from generated/schema.ts (already PascalCase)
|
|
export {
|
|
McpUiThemeSchema,
|
|
McpUiDisplayModeSchema,
|
|
McpUiOpenLinkRequestSchema,
|
|
McpUiOpenLinkResultSchema,
|
|
McpUiMessageRequestSchema,
|
|
McpUiMessageResultSchema,
|
|
McpUiSandboxProxyReadyNotificationSchema,
|
|
McpUiSandboxResourceReadyNotificationSchema,
|
|
McpUiSizeChangedNotificationSchema,
|
|
McpUiToolInputNotificationSchema,
|
|
McpUiToolInputPartialNotificationSchema,
|
|
McpUiToolResultNotificationSchema,
|
|
McpUiToolCancelledNotificationSchema,
|
|
McpUiHostContextSchema,
|
|
McpUiHostContextChangedNotificationSchema,
|
|
McpUiResourceTeardownRequestSchema,
|
|
McpUiResourceTeardownResultSchema,
|
|
McpUiHostCapabilitiesSchema,
|
|
McpUiAppCapabilitiesSchema,
|
|
McpUiInitializeRequestSchema,
|
|
McpUiInitializeResultSchema,
|
|
McpUiInitializedNotificationSchema,
|
|
McpUiResourceCspSchema,
|
|
McpUiResourceMetaSchema,
|
|
} from "./generated/schema.js";
|