@modelcontextprotocol/ext-apps 0.0.7 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,849 +1,12 @@
1
- import { CallToolResult, ContentBlock, Implementation, RequestId, Tool } from "@modelcontextprotocol/sdk/types.js";
2
- import { z } from "zod/v4";
3
1
  /**
4
- * Current protocol version supported by this SDK.
2
+ * MCP Apps Protocol Types and Schemas
5
3
  *
6
- * The SDK automatically handles version negotiation during initialization.
7
- * Apps and hosts don't need to manage protocol versions manually.
8
- */
9
- export declare const LATEST_PROTOCOL_VERSION = "2025-11-21";
10
- /**
11
- * Color theme preference for the host environment.
12
- * @see {@link McpUiHostContext.theme}
13
- */
14
- export type McpUiTheme = "light" | "dark";
15
- /** Runtime validation schema for {@link McpUiTheme}. */
16
- export declare const McpUiThemeSchema: z.ZodEnum<{
17
- light: "light";
18
- dark: "dark";
19
- }>;
20
- /**
21
- * Display mode for UI presentation.
22
- * - `inline`: Embedded within the conversation flow
23
- * - `fullscreen`: Expanded to fill the available viewport
24
- * - `pip`: Picture-in-picture floating window
25
- *
26
- * @see {@link McpUiHostContext.displayMode}
27
- */
28
- export type McpUiDisplayMode = "inline" | "fullscreen" | "pip";
29
- /** Runtime validation schema for {@link McpUiDisplayMode}. */
30
- export declare const McpUiDisplayModeSchema: z.ZodEnum<{
31
- inline: "inline";
32
- fullscreen: "fullscreen";
33
- pip: "pip";
34
- }>;
35
- /**
36
- * Request to open an external URL in the host's default browser.
37
- *
38
- * Sent from the Guest UI to the Host when requesting to open an external link.
39
- * The host may deny the request based on user preferences or security policy.
40
- *
41
- * @see {@link app.App.sendOpenLink} for the method that sends this request
42
- */
43
- export interface McpUiOpenLinkRequest {
44
- method: "ui/open-link";
45
- params: {
46
- /** URL to open in the host's browser */
47
- url: string;
48
- };
49
- }
50
- /**
51
- * Runtime validation schema for {@link McpUiOpenLinkRequest}.
52
- * @internal
53
- */
54
- export declare const McpUiOpenLinkRequestSchema: z.ZodObject<{
55
- method: z.ZodLiteral<"ui/open-link">;
56
- params: z.ZodObject<{
57
- url: z.ZodString;
58
- }, z.core.$strip>;
59
- }, z.core.$strip>;
60
- /**
61
- * Result from a {@link McpUiOpenLinkRequest}.
62
- *
63
- * The host returns this result after attempting to open the requested URL.
64
- *
65
- * @see {@link McpUiOpenLinkRequest}
66
- */
67
- export interface McpUiOpenLinkResult {
68
- /**
69
- * True if the host failed to open the URL (e.g., due to security policy,
70
- * user cancellation, or system error). False or undefined indicates success.
71
- */
72
- isError?: boolean;
73
- /**
74
- * Index signature required for MCP SDK `Protocol` class compatibility.
75
- * Note: The schema intentionally omits this to enforce strict validation.
76
- */
77
- [key: string]: unknown;
78
- }
79
- /**
80
- * Runtime validation schema for {@link McpUiOpenLinkResult}.
81
- * @internal
82
- */
83
- export declare const McpUiOpenLinkResultSchema: z.ZodType<McpUiOpenLinkResult>;
84
- /**
85
- * Request to send a message to the host's chat interface.
86
- *
87
- * Sent from the Guest UI to the Host when the app wants to add a message to the
88
- * conversation thread. This enables interactive apps to communicate with the user
89
- * through the host's chat interface.
90
- *
91
- * @see {@link app.App.sendMessage} for the method that sends this request
92
- */
93
- export interface McpUiMessageRequest {
94
- method: "ui/message";
95
- params: {
96
- /** Message role, currently only "user" is supported */
97
- role: "user";
98
- /** Message content blocks (text, image, etc.) */
99
- content: ContentBlock[];
100
- };
101
- }
102
- /**
103
- * Runtime validation schema for {@link McpUiMessageRequest}.
104
- * @internal
105
- */
106
- export declare const McpUiMessageRequestSchema: z.ZodObject<{
107
- method: z.ZodLiteral<"ui/message">;
108
- params: z.ZodObject<{
109
- role: z.ZodLiteral<"user">;
110
- content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
111
- type: z.ZodLiteral<"text">;
112
- text: z.ZodString;
113
- annotations: z.ZodOptional<z.ZodObject<{
114
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
115
- user: "user";
116
- assistant: "assistant";
117
- }>>>;
118
- priority: z.ZodOptional<z.ZodNumber>;
119
- lastModified: z.ZodOptional<z.ZodISODateTime>;
120
- }, z.core.$strip>>;
121
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
122
- }, z.core.$strip>, z.ZodObject<{
123
- type: z.ZodLiteral<"image">;
124
- data: z.ZodString;
125
- mimeType: z.ZodString;
126
- annotations: z.ZodOptional<z.ZodObject<{
127
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
128
- user: "user";
129
- assistant: "assistant";
130
- }>>>;
131
- priority: z.ZodOptional<z.ZodNumber>;
132
- lastModified: z.ZodOptional<z.ZodISODateTime>;
133
- }, z.core.$strip>>;
134
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
135
- }, z.core.$strip>, z.ZodObject<{
136
- type: z.ZodLiteral<"audio">;
137
- data: z.ZodString;
138
- mimeType: z.ZodString;
139
- annotations: z.ZodOptional<z.ZodObject<{
140
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
141
- user: "user";
142
- assistant: "assistant";
143
- }>>>;
144
- priority: z.ZodOptional<z.ZodNumber>;
145
- lastModified: z.ZodOptional<z.ZodISODateTime>;
146
- }, z.core.$strip>>;
147
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
148
- }, z.core.$strip>, z.ZodObject<{
149
- uri: z.ZodString;
150
- description: z.ZodOptional<z.ZodString>;
151
- mimeType: z.ZodOptional<z.ZodString>;
152
- annotations: z.ZodOptional<z.ZodObject<{
153
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
154
- user: "user";
155
- assistant: "assistant";
156
- }>>>;
157
- priority: z.ZodOptional<z.ZodNumber>;
158
- lastModified: z.ZodOptional<z.ZodISODateTime>;
159
- }, z.core.$strip>>;
160
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
161
- icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
162
- src: z.ZodString;
163
- mimeType: z.ZodOptional<z.ZodString>;
164
- sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
165
- }, z.core.$strip>>>;
166
- name: z.ZodString;
167
- title: z.ZodOptional<z.ZodString>;
168
- type: z.ZodLiteral<"resource_link">;
169
- }, z.core.$strip>, z.ZodObject<{
170
- type: z.ZodLiteral<"resource">;
171
- resource: z.ZodUnion<readonly [z.ZodObject<{
172
- uri: z.ZodString;
173
- mimeType: z.ZodOptional<z.ZodString>;
174
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
175
- text: z.ZodString;
176
- }, z.core.$strip>, z.ZodObject<{
177
- uri: z.ZodString;
178
- mimeType: z.ZodOptional<z.ZodString>;
179
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
180
- blob: z.ZodString;
181
- }, z.core.$strip>]>;
182
- annotations: z.ZodOptional<z.ZodObject<{
183
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
184
- user: "user";
185
- assistant: "assistant";
186
- }>>>;
187
- priority: z.ZodOptional<z.ZodNumber>;
188
- lastModified: z.ZodOptional<z.ZodISODateTime>;
189
- }, z.core.$strip>>;
190
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
191
- }, z.core.$strip>]>>;
192
- }, z.core.$strip>;
193
- }, z.core.$strip>;
194
- /**
195
- * Result from a {@link McpUiMessageRequest}.
196
- *
197
- * Note: The host does not return message content or follow-up results to prevent
198
- * leaking information from the conversation. Only error status is provided.
199
- *
200
- * @see {@link McpUiMessageRequest}
201
- */
202
- export interface McpUiMessageResult {
203
- /**
204
- * True if the host rejected or failed to deliver the message (e.g., due to
205
- * rate limiting, content policy, or system error). False or undefined
206
- * indicates the message was accepted.
207
- */
208
- isError?: boolean;
209
- /**
210
- * Index signature required for MCP SDK `Protocol` class compatibility.
211
- * Note: The schema intentionally omits this to enforce strict validation.
212
- */
213
- [key: string]: unknown;
214
- }
215
- /**
216
- * Runtime validation schema for {@link McpUiMessageResult}.
217
- * @internal
218
- */
219
- export declare const McpUiMessageResultSchema: z.ZodType<McpUiMessageResult>;
220
- /**
221
- * Notification that the sandbox proxy iframe is ready to receive content.
222
- *
223
- * This is an internal message used by web-based hosts implementing the
224
- * double-iframe sandbox architecture. The sandbox proxy sends this to the host
225
- * after it loads and is ready to receive HTML content via
226
- * {@link McpUiSandboxResourceReadyNotification}.
227
- *
228
- * @internal
229
- * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx#sandbox-proxy
230
- */
231
- export interface McpUiSandboxProxyReadyNotification {
232
- method: "ui/notifications/sandbox-proxy-ready";
233
- params: {};
234
- }
235
- /**
236
- * Runtime validation schema for {@link McpUiSandboxProxyReadyNotification}.
237
- * @internal
238
- */
239
- export declare const McpUiSandboxProxyReadyNotificationSchema: z.ZodObject<{
240
- method: z.ZodLiteral<"ui/notifications/sandbox-proxy-ready">;
241
- params: z.ZodObject<{}, z.core.$strip>;
242
- }, z.core.$strip>;
243
- /**
244
- * Notification containing HTML resource for the sandbox proxy to load.
245
- *
246
- * This is an internal message used by web-based hosts implementing the
247
- * double-iframe sandbox architecture. After the sandbox proxy signals readiness,
248
- * the host sends this notification with the HTML content and optional sandbox
249
- * attributes to load into the inner iframe.
250
- *
251
- * @internal
252
- * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx#sandbox-proxy
253
- */
254
- export interface McpUiSandboxResourceReadyNotification {
255
- method: "ui/notifications/sandbox-resource-ready";
256
- params: {
257
- /** HTML content to load into the inner iframe */
258
- html: string;
259
- /** Optional override for the inner iframe's sandbox attribute */
260
- sandbox?: string;
261
- /** CSP configuration from resource metadata */
262
- csp?: {
263
- /** Origins for network requests (fetch/XHR/WebSocket) */
264
- connectDomains?: string[];
265
- /** Origins for static resources (scripts, images, styles, fonts) */
266
- resourceDomains?: string[];
267
- };
268
- };
269
- }
270
- /**
271
- * Runtime validation schema for {@link McpUiSandboxResourceReadyNotification}.
272
- * @internal
273
- */
274
- export declare const McpUiSandboxResourceReadyNotificationSchema: z.ZodObject<{
275
- method: z.ZodLiteral<"ui/notifications/sandbox-resource-ready">;
276
- params: z.ZodObject<{
277
- html: z.ZodString;
278
- sandbox: z.ZodOptional<z.ZodString>;
279
- csp: z.ZodOptional<z.ZodObject<{
280
- connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
281
- resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
282
- }, z.core.$strip>>;
283
- }, z.core.$strip>;
284
- }, z.core.$strip>;
285
- /**
286
- * Notification of UI size changes (bidirectional: Guest ↔ Host).
287
- *
288
- * **Guest UI → Host**: Sent by the Guest UI when its rendered content size changes,
289
- * typically using ResizeObserver. This helps the host adjust the iframe container.
290
- * If {@link app.App} is configured with `autoResize: true` (default), this is sent
291
- * automatically.
292
- *
293
- * **Host → Guest UI**: Sent by the Host when the viewport size changes (e.g.,
294
- * window resize, orientation change). This allows the Guest UI to adjust its layout.
295
- *
296
- * @see {@link app.App.sendSizeChanged} for the method to send this from Guest UI
297
- * @see {@link app.App.setupSizeChangedNotifications} for automatic size reporting
298
- */
299
- export interface McpUiSizeChangedNotification {
300
- method: "ui/notifications/size-changed";
301
- params: {
302
- /** New width in pixels */
303
- width?: number;
304
- /** New height in pixels */
305
- height?: number;
306
- };
307
- }
308
- /**
309
- * Runtime validation schema for {@link McpUiSizeChangedNotification}.
310
- * @internal
311
- */
312
- export declare const McpUiSizeChangedNotificationSchema: z.ZodObject<{
313
- method: z.ZodLiteral<"ui/notifications/size-changed">;
314
- params: z.ZodObject<{
315
- width: z.ZodOptional<z.ZodNumber>;
316
- height: z.ZodOptional<z.ZodNumber>;
317
- }, z.core.$strip>;
318
- }, z.core.$strip>;
319
- /**
320
- * Notification containing complete tool arguments (Host → Guest UI).
321
- *
322
- * The host MUST send this notification after the Guest UI's initialize request
323
- * completes, when complete tool arguments become available. This notification is
324
- * sent exactly once and is required before {@link McpUiToolResultNotification}.
325
- *
326
- * The arguments object contains the complete tool call parameters that triggered
327
- * this App instance.
328
- */
329
- export interface McpUiToolInputNotification {
330
- method: "ui/notifications/tool-input";
331
- params: {
332
- /** Complete tool call arguments as key-value pairs */
333
- arguments?: Record<string, unknown>;
334
- };
335
- }
336
- /**
337
- * Runtime validation schema for {@link McpUiToolInputNotification}.
338
- * @internal
339
- */
340
- export declare const McpUiToolInputNotificationSchema: z.ZodObject<{
341
- method: z.ZodLiteral<"ui/notifications/tool-input">;
342
- params: z.ZodObject<{
343
- arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
344
- }, z.core.$strip>;
345
- }, z.core.$strip>;
346
- /**
347
- * Notification containing partial/streaming tool arguments (Host → Guest UI).
348
- *
349
- * The host MAY send this notification zero or more times while the agent is
350
- * streaming tool arguments, before {@link McpUiToolInputNotification} is sent
351
- * with complete arguments.
352
- *
353
- * The arguments object represents best-effort recovery of incomplete JSON, with
354
- * unclosed structures automatically closed to produce valid JSON. Guest UIs may
355
- * ignore these notifications or use them to render progressive loading states.
356
- *
357
- * Guest UIs MUST NOT rely on partial arguments for critical operations and SHOULD
358
- * gracefully handle missing or changing fields between notifications.
359
- */
360
- export interface McpUiToolInputPartialNotification {
361
- method: "ui/notifications/tool-input-partial";
362
- params: {
363
- /** Partial tool call arguments (incomplete, may change) */
364
- arguments?: Record<string, unknown>;
365
- };
366
- }
367
- /**
368
- * Runtime validation schema for {@link McpUiToolInputPartialNotification}.
369
- * @internal
370
- */
371
- export declare const McpUiToolInputPartialNotificationSchema: z.ZodObject<{
372
- method: z.ZodLiteral<"ui/notifications/tool-input-partial">;
373
- params: z.ZodObject<{
374
- arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
375
- }, z.core.$strip>;
376
- }, z.core.$strip>;
377
- /**
378
- * Notification containing tool execution result (Host → Guest UI).
379
- *
380
- * The host MUST send this notification when tool execution completes successfully,
381
- * provided the UI is still displayed. If the UI was closed before execution
382
- * completes, the host MAY skip this notification. This notification is sent after
383
- * {@link McpUiToolInputNotification}.
384
- *
385
- * The result follows the standard MCP CallToolResult format, containing content
386
- * for the model and optionally structuredContent optimized for UI rendering.
387
- */
388
- export interface McpUiToolResultNotification {
389
- method: "ui/notifications/tool-result";
390
- /** Standard MCP tool execution result */
391
- params: CallToolResult;
392
- }
393
- /**
394
- * Runtime validation schema for {@link McpUiToolResultNotification}.
395
- * @internal
396
- */
397
- export declare const McpUiToolResultNotificationSchema: z.ZodObject<{
398
- method: z.ZodLiteral<"ui/notifications/tool-result">;
399
- params: z.ZodObject<{
400
- _meta: z.ZodOptional<z.ZodObject<{
401
- "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
402
- taskId: z.ZodString;
403
- }, z.core.$loose>>;
404
- }, z.core.$loose>>;
405
- content: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
406
- type: z.ZodLiteral<"text">;
407
- text: z.ZodString;
408
- annotations: z.ZodOptional<z.ZodObject<{
409
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
410
- user: "user";
411
- assistant: "assistant";
412
- }>>>;
413
- priority: z.ZodOptional<z.ZodNumber>;
414
- lastModified: z.ZodOptional<z.ZodISODateTime>;
415
- }, z.core.$strip>>;
416
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
417
- }, z.core.$strip>, z.ZodObject<{
418
- type: z.ZodLiteral<"image">;
419
- data: z.ZodString;
420
- mimeType: z.ZodString;
421
- annotations: z.ZodOptional<z.ZodObject<{
422
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
423
- user: "user";
424
- assistant: "assistant";
425
- }>>>;
426
- priority: z.ZodOptional<z.ZodNumber>;
427
- lastModified: z.ZodOptional<z.ZodISODateTime>;
428
- }, z.core.$strip>>;
429
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
430
- }, z.core.$strip>, z.ZodObject<{
431
- type: z.ZodLiteral<"audio">;
432
- data: z.ZodString;
433
- mimeType: z.ZodString;
434
- annotations: z.ZodOptional<z.ZodObject<{
435
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
436
- user: "user";
437
- assistant: "assistant";
438
- }>>>;
439
- priority: z.ZodOptional<z.ZodNumber>;
440
- lastModified: z.ZodOptional<z.ZodISODateTime>;
441
- }, z.core.$strip>>;
442
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
443
- }, z.core.$strip>, z.ZodObject<{
444
- uri: z.ZodString;
445
- description: z.ZodOptional<z.ZodString>;
446
- mimeType: z.ZodOptional<z.ZodString>;
447
- annotations: z.ZodOptional<z.ZodObject<{
448
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
449
- user: "user";
450
- assistant: "assistant";
451
- }>>>;
452
- priority: z.ZodOptional<z.ZodNumber>;
453
- lastModified: z.ZodOptional<z.ZodISODateTime>;
454
- }, z.core.$strip>>;
455
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
456
- icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
457
- src: z.ZodString;
458
- mimeType: z.ZodOptional<z.ZodString>;
459
- sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
460
- }, z.core.$strip>>>;
461
- name: z.ZodString;
462
- title: z.ZodOptional<z.ZodString>;
463
- type: z.ZodLiteral<"resource_link">;
464
- }, z.core.$strip>, z.ZodObject<{
465
- type: z.ZodLiteral<"resource">;
466
- resource: z.ZodUnion<readonly [z.ZodObject<{
467
- uri: z.ZodString;
468
- mimeType: z.ZodOptional<z.ZodString>;
469
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
470
- text: z.ZodString;
471
- }, z.core.$strip>, z.ZodObject<{
472
- uri: z.ZodString;
473
- mimeType: z.ZodOptional<z.ZodString>;
474
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
475
- blob: z.ZodString;
476
- }, z.core.$strip>]>;
477
- annotations: z.ZodOptional<z.ZodObject<{
478
- audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
479
- user: "user";
480
- assistant: "assistant";
481
- }>>>;
482
- priority: z.ZodOptional<z.ZodNumber>;
483
- lastModified: z.ZodOptional<z.ZodISODateTime>;
484
- }, z.core.$strip>>;
485
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
486
- }, z.core.$strip>]>>>;
487
- structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
488
- isError: z.ZodOptional<z.ZodBoolean>;
489
- }, z.core.$loose>;
490
- }, z.core.$strip>;
491
- /**
492
- * Rich context about the host environment provided to Guest UIs.
493
- *
494
- * Hosts provide this context in the {@link McpUiInitializeResult} response and send
495
- * updates via {@link McpUiHostContextChangedNotification} when values change.
496
- * All fields are optional and Guest UIs should handle missing fields gracefully.
497
- *
498
- * @example
499
- * ```typescript
500
- * // Received during initialization
501
- * const result = await app.connect(transport);
502
- * const context = result.hostContext;
503
- *
504
- * if (context.theme === "dark") {
505
- * document.body.classList.add("dark-mode");
506
- * }
507
- * ```
508
- */
509
- export interface McpUiHostContext {
510
- /** Metadata of the tool call that instantiated this App */
511
- toolInfo?: {
512
- /** JSON-RPC id of the tools/call request */
513
- id: RequestId;
514
- /** Tool definition including name, inputSchema, etc. */
515
- tool: Tool;
516
- };
517
- /**
518
- * Current color theme preference.
519
- * @example "dark"
520
- */
521
- theme?: McpUiTheme;
522
- /**
523
- * How the UI is currently displayed.
524
- * @example "inline"
525
- */
526
- displayMode?: McpUiDisplayMode;
527
- /**
528
- * Display modes the host supports.
529
- * Apps can use this to offer mode-switching UI if applicable.
530
- */
531
- availableDisplayModes?: string[];
532
- /** Current and maximum dimensions available to the UI */
533
- viewport?: {
534
- /** Current viewport width in pixels */
535
- width: number;
536
- /** Current viewport height in pixels */
537
- height: number;
538
- /** Maximum available height in pixels (if constrained) */
539
- maxHeight?: number;
540
- /** Maximum available width in pixels (if constrained) */
541
- maxWidth?: number;
542
- };
543
- /**
544
- * User's language and region preference in BCP 47 format.
545
- * @example "en-US", "fr-CA", "ja-JP"
546
- */
547
- locale?: string;
548
- /**
549
- * User's timezone in IANA format.
550
- * @example "America/New_York", "Europe/London", "Asia/Tokyo"
551
- */
552
- timeZone?: string;
553
- /**
554
- * Host application identifier.
555
- * @example "claude-desktop/1.0.0"
556
- */
557
- userAgent?: string;
558
- /**
559
- * Platform type for responsive design decisions.
560
- * @example "desktop"
561
- */
562
- platform?: "web" | "desktop" | "mobile";
563
- /** Device input capabilities */
564
- deviceCapabilities?: {
565
- /** Whether the device supports touch input */
566
- touch?: boolean;
567
- /** Whether the device supports hover interactions */
568
- hover?: boolean;
569
- };
570
- /**
571
- * Safe area boundaries in pixels.
572
- * Used to avoid notches, rounded corners, and system UI.
573
- */
574
- safeAreaInsets?: {
575
- /** Top safe area inset in pixels */
576
- top: number;
577
- /** Right safe area inset in pixels */
578
- right: number;
579
- /** Bottom safe area inset in pixels */
580
- bottom: number;
581
- /** Left safe area inset in pixels */
582
- left: number;
583
- };
584
- }
585
- /**
586
- * Runtime validation schema for {@link McpUiHostContext}.
587
- * @internal
588
- */
589
- export declare const McpUiHostContextSchema: z.ZodType<McpUiHostContext>;
590
- /**
591
- * Notification that host context has changed (Host → Guest UI).
592
- *
593
- * The host MAY send this notification when any context field changes, such as:
594
- * - Theme toggled (light/dark)
595
- * - Display mode changed (inline/fullscreen)
596
- * - Device orientation changed
597
- * - Window/panel resized
598
- *
599
- * This notification contains partial updates. Guest UIs SHOULD merge received
600
- * fields with their current context state rather than replacing it entirely.
601
- *
602
- * @see {@link McpUiHostContext} for the full context structure
603
- */
604
- export interface McpUiHostContextChangedNotification {
605
- method: "ui/notifications/host-context-changed";
606
- /** Partial context update containing only changed fields */
607
- params: McpUiHostContext;
608
- }
609
- /**
610
- * Runtime validation schema for {@link McpUiHostContextChangedNotification}.
611
- * @internal
612
- */
613
- export declare const McpUiHostContextChangedNotificationSchema: z.ZodObject<{
614
- method: z.ZodLiteral<"ui/notifications/host-context-changed">;
615
- params: z.ZodType<McpUiHostContext, unknown, z.core.$ZodTypeInternals<McpUiHostContext, unknown>>;
616
- }, z.core.$strip>;
617
- /**
618
- * Request for graceful shutdown of the Guest UI (Host → Guest UI).
619
- *
620
- * The host MUST send this request before tearing down the UI resource, for any
621
- * reason including user action, resource reallocation, or app closure. This gives
622
- * the Guest UI an opportunity to save state, cancel pending operations, or show
623
- * confirmation dialogs.
624
- *
625
- * The host SHOULD wait for the response before unmounting the iframe to prevent
626
- * data loss.
627
- *
628
- * @see {@link app-bridge.AppBridge.sendResourceTeardown} for the host method that sends this
629
- */
630
- export interface McpUiResourceTeardownRequest {
631
- method: "ui/resource-teardown";
632
- params: {};
633
- }
634
- /**
635
- * Runtime validation schema for {@link McpUiResourceTeardownRequest}.
636
- * @internal
637
- */
638
- export declare const McpUiResourceTeardownRequestSchema: z.ZodObject<{
639
- method: z.ZodLiteral<"ui/resource-teardown">;
640
- params: z.ZodObject<{}, z.core.$strip>;
641
- }, z.core.$strip>;
642
- /**
643
- * Result from graceful shutdown request.
644
- *
645
- * Empty result indicates the Guest UI has completed cleanup and is ready to be
646
- * torn down.
647
- *
648
- * @see {@link McpUiResourceTeardownRequest}
649
- */
650
- export interface McpUiResourceTeardownResult {
651
- }
652
- /**
653
- * Runtime validation schema for {@link McpUiResourceTeardownResult}.
654
- * @internal
655
- */
656
- export declare const McpUiResourceTeardownResultSchema: z.ZodType<McpUiResourceTeardownResult>;
657
- /**
658
- * Capabilities supported by the host application.
659
- *
660
- * Hosts declare these capabilities during the initialization handshake. Guest UIs
661
- * can check capabilities before attempting to use specific features.
662
- *
663
- * @example Check if host supports opening links
664
- * ```typescript
665
- * const result = await app.connect(transport);
666
- * if (result.hostCapabilities.openLinks) {
667
- * await app.sendOpenLink({ url: "https://example.com" });
668
- * }
669
- * ```
670
- *
671
- * @see {@link McpUiInitializeResult} for the initialization result that includes these capabilities
672
- */
673
- export interface McpUiHostCapabilities {
674
- /** Experimental features (structure TBD) */
675
- experimental?: {};
676
- /** Host supports opening external URLs via {@link app.App.sendOpenLink} */
677
- openLinks?: {};
678
- /** Host can proxy tool calls to the MCP server */
679
- serverTools?: {
680
- /** Host supports tools/list_changed notifications */
681
- listChanged?: boolean;
682
- };
683
- /** Host can proxy resource reads to the MCP server */
684
- serverResources?: {
685
- /** Host supports resources/list_changed notifications */
686
- listChanged?: boolean;
687
- };
688
- /** Host accepts log messages via {@link app.App.sendLog} */
689
- logging?: {};
690
- }
691
- /**
692
- * Runtime validation schema for {@link McpUiHostCapabilities}.
693
- * @internal
694
- */
695
- export declare const McpUiHostCapabilitiesSchema: z.ZodType<McpUiHostCapabilities>;
696
- /**
697
- * Capabilities provided by the Guest UI (App).
698
- *
699
- * Apps declare these capabilities during the initialization handshake to indicate
700
- * what features they provide to the host.
701
- *
702
- * @example Declare tool capabilities
703
- * ```typescript
704
- * const app = new App(
705
- * { name: "MyApp", version: "1.0.0" },
706
- * { tools: { listChanged: true } }
707
- * );
708
- * ```
709
- *
710
- * @see {@link McpUiInitializeRequest} for the initialization request that includes these capabilities
711
- */
712
- export interface McpUiAppCapabilities {
713
- /** Experimental features (structure TBD) */
714
- experimental?: {};
715
- /**
716
- * App exposes MCP-style tools that the host can call.
717
- * These are app-specific tools, not proxied from the server.
718
- */
719
- tools?: {
720
- /** App supports tools/list_changed notifications */
721
- listChanged?: boolean;
722
- };
723
- }
724
- /**
725
- * Runtime validation schema for {@link McpUiAppCapabilities}.
726
- * @internal
727
- */
728
- export declare const McpUiAppCapabilitiesSchema: z.ZodType<McpUiAppCapabilities>;
729
- /**
730
- * Initialization request sent from Guest UI to Host.
731
- *
732
- * This is the first message sent by the Guest UI after loading. The host responds
733
- * with {@link McpUiInitializeResult} containing host capabilities and context.
734
- * After receiving the response, the Guest UI MUST send
735
- * {@link McpUiInitializedNotification}.
736
- *
737
- * This replaces the custom iframe-ready pattern used in pre-SEP MCP-UI.
738
- *
739
- * @see {@link app.App.connect} for the method that sends this request
740
- */
741
- export interface McpUiInitializeRequest {
742
- method: "ui/initialize";
743
- params: {
744
- /** App identification (name and version) */
745
- appInfo: Implementation;
746
- /** Features and capabilities this app provides */
747
- appCapabilities: McpUiAppCapabilities;
748
- /** Protocol version this app supports */
749
- protocolVersion: string;
750
- };
751
- }
752
- /**
753
- * Runtime validation schema for {@link McpUiInitializeRequest}.
754
- * @internal
755
- */
756
- export declare const McpUiInitializeRequestSchema: z.ZodObject<{
757
- method: z.ZodLiteral<"ui/initialize">;
758
- params: z.ZodObject<{
759
- appInfo: z.ZodObject<{
760
- version: z.ZodString;
761
- websiteUrl: z.ZodOptional<z.ZodString>;
762
- icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
763
- src: z.ZodString;
764
- mimeType: z.ZodOptional<z.ZodString>;
765
- sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
766
- }, z.core.$strip>>>;
767
- name: z.ZodString;
768
- title: z.ZodOptional<z.ZodString>;
769
- }, z.core.$strip>;
770
- appCapabilities: z.ZodType<McpUiAppCapabilities, unknown, z.core.$ZodTypeInternals<McpUiAppCapabilities, unknown>>;
771
- protocolVersion: z.ZodString;
772
- }, z.core.$strip>;
773
- }, z.core.$strip>;
774
- /**
775
- * Initialization result returned from Host to Guest UI.
776
- *
777
- * Contains the negotiated protocol version, host information, capabilities,
778
- * and rich context about the host environment.
779
- *
780
- * @see {@link McpUiInitializeRequest}
781
- */
782
- export interface McpUiInitializeResult {
783
- /** Negotiated protocol version string (e.g., "2025-11-21") */
784
- protocolVersion: string;
785
- /** Host application identification and version */
786
- hostInfo: Implementation;
787
- /** Features and capabilities provided by the host */
788
- hostCapabilities: McpUiHostCapabilities;
789
- /** Rich context about the host environment */
790
- hostContext: McpUiHostContext;
791
- /**
792
- * Index signature required for MCP SDK `Protocol` class compatibility.
793
- * Note: The schema intentionally omits this to enforce strict validation.
794
- */
795
- [key: string]: unknown;
796
- }
797
- /**
798
- * Runtime validation schema for {@link McpUiInitializeResult}.
799
- * @internal
800
- */
801
- export declare const McpUiInitializeResultSchema: z.ZodType<McpUiInitializeResult>;
802
- /**
803
- * Notification that Guest UI has completed initialization (Guest UI → Host).
804
- *
805
- * The Guest UI MUST send this notification after receiving
806
- * {@link McpUiInitializeResult} and completing any setup. The host waits for this
807
- * notification before sending tool input and other data to the Guest UI.
808
- *
809
- * @see {@link app.App.connect} for the method that sends this notification
810
- */
811
- export interface McpUiInitializedNotification {
812
- method: "ui/notifications/initialized";
813
- params?: {};
814
- }
815
- /**
816
- * Runtime validation schema for {@link McpUiInitializedNotification}.
817
- * @internal
818
- */
819
- export declare const McpUiInitializedNotificationSchema: z.ZodObject<{
820
- method: z.ZodLiteral<"ui/notifications/initialized">;
821
- params: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
822
- }, z.core.$strip>;
823
- /**
824
- * Content Security Policy configuration for UI resources.
825
- *
826
- * Servers declare which external origins their UI needs to access.
827
- * Hosts use this to enforce appropriate CSP headers.
828
- */
829
- export declare const McpUiResourceCspSchema: z.ZodObject<{
830
- connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
831
- resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
832
- }, z.core.$strip>;
833
- export type McpUiResourceCsp = z.infer<typeof McpUiResourceCspSchema>;
834
- /**
835
- * UI Resource metadata for security and rendering configuration.
836
- *
837
- * Included in the `_meta.ui` field of UI resource content returned via `resources/read`.
4
+ * This file re-exports types from spec.types.ts and schemas from generated/schema.ts.
5
+ * Compile-time verification is handled by generated/schema.test.ts.
838
6
  *
839
- * @see {@link McpUiResourceCspSchema} for CSP configuration
7
+ * @see spec.types.ts for the source of truth TypeScript interfaces
8
+ * @see generated/schema.ts for auto-generated Zod schemas
9
+ * @see generated/schema.test.ts for compile-time verification
840
10
  */
841
- export declare const McpUiResourceMetaSchema: z.ZodObject<{
842
- csp: z.ZodOptional<z.ZodObject<{
843
- connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
844
- resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
845
- }, z.core.$strip>>;
846
- domain: z.ZodOptional<z.ZodString>;
847
- prefersBorder: z.ZodOptional<z.ZodBoolean>;
848
- }, z.core.$strip>;
849
- export type McpUiResourceMeta = z.infer<typeof McpUiResourceMetaSchema>;
11
+ 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";
12
+ 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";