* feat(server): add hasUiSupport/getUiCapability for experimental+extensions Support double-tagging for MCP Apps capability negotiation: - Check both experimental and extensions fields in client capabilities - Add hasUiSupport() to easily check if client supports MCP Apps - Add getUiCapability() to retrieve the capability settings - Update spec to document both capability locations This enables forward compatibility as MCP transitions from experimental to the extensions field (SEP-1724). Claude-Generated-By: Claude Code (cli/claude-opus-4-5=100%) Claude-Steers: 0 Claude-Permission-Prompts: 0 Claude-Escapes: 0 * fix: update @types/node version in package-lock.json Replace invalid 22.19.5/22.19.6/22.19.7 versions with valid 22.19.3 * docs(spec): clarify hosts SHOULD double-tag, servers SHOULD check both - Hosts SHOULD advertise capabilities in both experimental and extensions - Servers SHOULD check both locations, preferring extensions when present - Updated example to show double-tagging pattern * chore: remove double-tagging recommendation, keep hasUiSupport helper Reverts the spec changes that recommended clients double-tag capabilities in both experimental and extensions fields. The helper functions remain as they're useful for checking capability in either location. * refactor(server): simplify to only getUiCapability, remove hasUiSupport - Remove hasUiSupport function (use getUiCapability directly) - Remove double-tagging logic (only check extensions field) - Add ClientCapabilitiesWithExtensions type using SDK's ClientCapabilities - Update spec to use getUiCapability - Simplify tests * fix: update @see link to getUiCapability * refactor(server): inline ClientCapabilitiesWithExtensions type in getUiCapability * refactor: move McpUiClientCapabilities to spec.types.ts
219 lines
6.3 KiB
TypeScript
219 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,
|
|
type McpUiClientCapabilities,
|
|
} 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;
|