File size: 6,457 Bytes
e1cc3bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/**
 * 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;