Key improvements:
- Add `{@link}` cross-references throughout the codebase to make API
documentation navigable and help AI models understand relationships
- Use `{@link module!Export}` syntax for cross-module references
- Add backticks for inline code formatting (`ResizeObserver`, `App`, etc)
- Fix `PostMessageTransport` examples to show required two-argument form
- Clarify `onteardown` callback return type requirement
- Document React hooks cleanup behavior and Strict Mode considerations
- Add tool visibility example for `registerAppTool`
- Add CSP example for `registerAppResource`
- Fix notification direction documentation in `spec.types.ts`
TypeDoc config migrated from `typedoc.json` to `typedoc.config.mjs` to:
- Support custom `@description` block tag
- Add `intentionallyNotExported` for internal types
- Include `src/server/index.ts` entry point
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
218 lines
6.3 KiB
TypeScript
218 lines
6.3 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,
|
|
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,
|
|
type McpUiStyles,
|
|
type McpUiHostCss,
|
|
type McpUiHostStyles,
|
|
type McpUiOpenLinkRequest,
|
|
type McpUiOpenLinkResult,
|
|
type McpUiMessageRequest,
|
|
type McpUiMessageResult,
|
|
type McpUiUpdateModelContextRequest,
|
|
type McpUiSupportedContentBlockModalities,
|
|
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 McpUiResourcePermissions,
|
|
type McpUiResourceMeta,
|
|
type McpUiRequestDisplayModeRequest,
|
|
type McpUiRequestDisplayModeResult,
|
|
type McpUiToolVisibility,
|
|
type McpUiToolMeta,
|
|
} from "./spec.types.js";
|
|
|
|
// Import types needed for protocol type unions (not re-exported, just used internally)
|
|
import type {
|
|
McpUiInitializeRequest,
|
|
McpUiOpenLinkRequest,
|
|
McpUiMessageRequest,
|
|
McpUiUpdateModelContextRequest,
|
|
McpUiResourceTeardownRequest,
|
|
McpUiRequestDisplayModeRequest,
|
|
McpUiHostContextChangedNotification,
|
|
McpUiToolInputNotification,
|
|
McpUiToolInputPartialNotification,
|
|
McpUiToolResultNotification,
|
|
McpUiToolCancelledNotification,
|
|
McpUiSandboxResourceReadyNotification,
|
|
McpUiInitializedNotification,
|
|
McpUiSizeChangedNotification,
|
|
McpUiSandboxProxyReadyNotification,
|
|
McpUiInitializeResult,
|
|
McpUiOpenLinkResult,
|
|
McpUiMessageResult,
|
|
McpUiResourceTeardownResult,
|
|
McpUiRequestDisplayModeResult,
|
|
} from "./spec.types.js";
|
|
|
|
// Re-export all schemas from generated/schema.ts (already PascalCase)
|
|
export {
|
|
McpUiThemeSchema,
|
|
McpUiDisplayModeSchema,
|
|
McpUiHostCssSchema,
|
|
McpUiHostStylesSchema,
|
|
McpUiOpenLinkRequestSchema,
|
|
McpUiOpenLinkResultSchema,
|
|
McpUiMessageRequestSchema,
|
|
McpUiMessageResultSchema,
|
|
McpUiUpdateModelContextRequestSchema,
|
|
McpUiSupportedContentBlockModalitiesSchema,
|
|
McpUiSandboxProxyReadyNotificationSchema,
|
|
McpUiSandboxResourceReadyNotificationSchema,
|
|
McpUiSizeChangedNotificationSchema,
|
|
McpUiToolInputNotificationSchema,
|
|
McpUiToolInputPartialNotificationSchema,
|
|
McpUiToolResultNotificationSchema,
|
|
McpUiToolCancelledNotificationSchema,
|
|
McpUiHostContextSchema,
|
|
McpUiHostContextChangedNotificationSchema,
|
|
McpUiResourceTeardownRequestSchema,
|
|
McpUiResourceTeardownResultSchema,
|
|
McpUiHostCapabilitiesSchema,
|
|
McpUiAppCapabilitiesSchema,
|
|
McpUiInitializeRequestSchema,
|
|
McpUiInitializeResultSchema,
|
|
McpUiInitializedNotificationSchema,
|
|
McpUiResourceCspSchema,
|
|
McpUiResourcePermissionsSchema,
|
|
McpUiResourceMetaSchema,
|
|
McpUiRequestDisplayModeRequestSchema,
|
|
McpUiRequestDisplayModeResultSchema,
|
|
McpUiToolVisibilitySchema,
|
|
McpUiToolMetaSchema,
|
|
} from "./generated/schema.js";
|
|
|
|
// Re-export SDK types used in protocol type unions
|
|
import {
|
|
CallToolRequest,
|
|
CallToolResult,
|
|
EmptyResult,
|
|
ListPromptsRequest,
|
|
ListPromptsResult,
|
|
ListResourcesRequest,
|
|
ListResourcesResult,
|
|
ListResourceTemplatesRequest,
|
|
ListResourceTemplatesResult,
|
|
ListToolsRequest,
|
|
ListToolsResult,
|
|
LoggingMessageNotification,
|
|
PingRequest,
|
|
PromptListChangedNotification,
|
|
ReadResourceRequest,
|
|
ReadResourceResult,
|
|
ResourceListChangedNotification,
|
|
ToolListChangedNotification,
|
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
|
|
/**
|
|
* All request types in the MCP Apps protocol.
|
|
*
|
|
* Includes:
|
|
* - MCP UI requests (initialize, open-link, message, resource-teardown, request-display-mode)
|
|
* - MCP server requests forwarded from the app (tools/call, tools/list, resources/list,
|
|
* resources/templates/list, resources/read, prompts/list)
|
|
* - Protocol requests (ping)
|
|
*/
|
|
export type AppRequest =
|
|
| McpUiInitializeRequest
|
|
| McpUiOpenLinkRequest
|
|
| McpUiMessageRequest
|
|
| McpUiUpdateModelContextRequest
|
|
| McpUiResourceTeardownRequest
|
|
| McpUiRequestDisplayModeRequest
|
|
| CallToolRequest
|
|
| ListToolsRequest
|
|
| ListResourcesRequest
|
|
| ListResourceTemplatesRequest
|
|
| ReadResourceRequest
|
|
| ListPromptsRequest
|
|
| PingRequest;
|
|
|
|
/**
|
|
* All notification types in the MCP Apps protocol.
|
|
*
|
|
* Host to app:
|
|
* - Tool lifecycle (input, input-partial, result, cancelled)
|
|
* - Host context changes
|
|
* - MCP list changes (tools, resources, prompts)
|
|
* - Sandbox resource ready
|
|
*
|
|
* App to host:
|
|
* - Initialized, size-changed, sandbox-proxy-ready
|
|
* - Logging messages
|
|
*/
|
|
export type AppNotification =
|
|
// Sent to app
|
|
| McpUiHostContextChangedNotification
|
|
| McpUiToolInputNotification
|
|
| McpUiToolInputPartialNotification
|
|
| McpUiToolResultNotification
|
|
| McpUiToolCancelledNotification
|
|
| McpUiSandboxResourceReadyNotification
|
|
| ToolListChangedNotification
|
|
| ResourceListChangedNotification
|
|
| PromptListChangedNotification
|
|
// Received from app
|
|
| McpUiInitializedNotification
|
|
| McpUiSizeChangedNotification
|
|
| McpUiSandboxProxyReadyNotification
|
|
| LoggingMessageNotification;
|
|
|
|
/**
|
|
* All result types in the MCP Apps protocol.
|
|
*/
|
|
export type AppResult =
|
|
| McpUiInitializeResult
|
|
| McpUiOpenLinkResult
|
|
| McpUiMessageResult
|
|
| McpUiResourceTeardownResult
|
|
| McpUiRequestDisplayModeResult
|
|
| CallToolResult
|
|
| ListToolsResult
|
|
| ListResourcesResult
|
|
| ListResourceTemplatesResult
|
|
| ReadResourceResult
|
|
| ListPromptsResult
|
|
| EmptyResult;
|