@modelcontextprotocol/ext-apps 0.0.6 → 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.
@@ -0,0 +1,339 @@
1
+ /**
2
+ * MCP Apps Protocol Types (spec.types.ts)
3
+ *
4
+ * This file contains pure TypeScript interface definitions for the MCP Apps protocol.
5
+ * These types are the source of truth and are used to generate Zod schemas via ts-to-zod.
6
+ *
7
+ * - Use `@description` JSDoc tags to generate `.describe()` calls on schemas
8
+ * - Run `npm run generate:schemas` to regenerate schemas from these types
9
+ *
10
+ * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx
11
+ */
12
+ import type { CallToolResult, ContentBlock, Implementation, RequestId, Tool } from "@modelcontextprotocol/sdk/types.js";
13
+ /**
14
+ * Current protocol version supported by this SDK.
15
+ *
16
+ * The SDK automatically handles version negotiation during initialization.
17
+ * Apps and hosts don't need to manage protocol versions manually.
18
+ */
19
+ export declare const LATEST_PROTOCOL_VERSION = "2025-11-21";
20
+ /**
21
+ * @description Color theme preference for the host environment.
22
+ */
23
+ export type McpUiTheme = "light" | "dark";
24
+ /**
25
+ * @description Display mode for UI presentation.
26
+ */
27
+ export type McpUiDisplayMode = "inline" | "fullscreen" | "pip";
28
+ /**
29
+ * @description Request to open an external URL in the host's default browser.
30
+ * @see {@link app.App.sendOpenLink} for the method that sends this request
31
+ */
32
+ export interface McpUiOpenLinkRequest {
33
+ method: "ui/open-link";
34
+ params: {
35
+ /** @description URL to open in the host's browser */
36
+ url: string;
37
+ };
38
+ }
39
+ /**
40
+ * @description Result from opening a URL.
41
+ * @see {@link McpUiOpenLinkRequest}
42
+ */
43
+ export interface McpUiOpenLinkResult {
44
+ /** @description True if the host failed to open the URL (e.g., due to security policy). */
45
+ isError?: boolean;
46
+ /**
47
+ * Index signature required for MCP SDK `Protocol` class compatibility.
48
+ * Note: The schema intentionally omits this to enforce strict validation.
49
+ */
50
+ [key: string]: unknown;
51
+ }
52
+ /**
53
+ * @description Request to send a message to the host's chat interface.
54
+ * @see {@link app.App.sendMessage} for the method that sends this request
55
+ */
56
+ export interface McpUiMessageRequest {
57
+ method: "ui/message";
58
+ params: {
59
+ /** @description Message role, currently only "user" is supported. */
60
+ role: "user";
61
+ /** @description Message content blocks (text, image, etc.). */
62
+ content: ContentBlock[];
63
+ };
64
+ }
65
+ /**
66
+ * @description Result from sending a message.
67
+ * @see {@link McpUiMessageRequest}
68
+ */
69
+ export interface McpUiMessageResult {
70
+ /** @description True if the host rejected or failed to deliver the message. */
71
+ isError?: boolean;
72
+ /**
73
+ * Index signature required for MCP SDK `Protocol` class compatibility.
74
+ * Note: The schema intentionally omits this to enforce strict validation.
75
+ */
76
+ [key: string]: unknown;
77
+ }
78
+ /**
79
+ * @description Notification that the sandbox proxy iframe is ready to receive content.
80
+ * @internal
81
+ * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx#sandbox-proxy
82
+ */
83
+ export interface McpUiSandboxProxyReadyNotification {
84
+ method: "ui/notifications/sandbox-proxy-ready";
85
+ params: {};
86
+ }
87
+ /**
88
+ * @description Notification containing HTML resource for the sandbox proxy to load.
89
+ * @internal
90
+ * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx#sandbox-proxy
91
+ */
92
+ export interface McpUiSandboxResourceReadyNotification {
93
+ method: "ui/notifications/sandbox-resource-ready";
94
+ params: {
95
+ /** @description HTML content to load into the inner iframe. */
96
+ html: string;
97
+ /** @description Optional override for the inner iframe's sandbox attribute. */
98
+ sandbox?: string;
99
+ /** @description CSP configuration from resource metadata. */
100
+ csp?: {
101
+ /** @description Origins for network requests (fetch/XHR/WebSocket). */
102
+ connectDomains?: string[];
103
+ /** @description Origins for static resources (scripts, images, styles, fonts). */
104
+ resourceDomains?: string[];
105
+ };
106
+ };
107
+ }
108
+ /**
109
+ * @description Notification of UI size changes (bidirectional: Guest <-> Host).
110
+ * @see {@link app.App.sendSizeChanged} for the method to send this from Guest UI
111
+ */
112
+ export interface McpUiSizeChangedNotification {
113
+ method: "ui/notifications/size-changed";
114
+ params: {
115
+ /** @description New width in pixels. */
116
+ width?: number;
117
+ /** @description New height in pixels. */
118
+ height?: number;
119
+ };
120
+ }
121
+ /**
122
+ * @description Notification containing complete tool arguments (Host -> Guest UI).
123
+ */
124
+ export interface McpUiToolInputNotification {
125
+ method: "ui/notifications/tool-input";
126
+ params: {
127
+ /** @description Complete tool call arguments as key-value pairs. */
128
+ arguments?: Record<string, unknown>;
129
+ };
130
+ }
131
+ /**
132
+ * @description Notification containing partial/streaming tool arguments (Host -> Guest UI).
133
+ */
134
+ export interface McpUiToolInputPartialNotification {
135
+ method: "ui/notifications/tool-input-partial";
136
+ params: {
137
+ /** @description Partial tool call arguments (incomplete, may change). */
138
+ arguments?: Record<string, unknown>;
139
+ };
140
+ }
141
+ /**
142
+ * @description Notification containing tool execution result (Host -> Guest UI).
143
+ */
144
+ export interface McpUiToolResultNotification {
145
+ method: "ui/notifications/tool-result";
146
+ /** @description Standard MCP tool execution result. */
147
+ params: CallToolResult;
148
+ }
149
+ /**
150
+ * @description Notification that tool execution was cancelled (Host -> Guest UI).
151
+ * Host MUST send this if tool execution was cancelled for any reason (user action,
152
+ * sampling error, classifier intervention, etc.).
153
+ */
154
+ export interface McpUiToolCancelledNotification {
155
+ method: "ui/notifications/tool-cancelled";
156
+ params: {
157
+ /** @description Optional reason for the cancellation (e.g., "user action", "timeout"). */
158
+ reason?: string;
159
+ };
160
+ }
161
+ /**
162
+ * @description Rich context about the host environment provided to Guest UIs.
163
+ */
164
+ export interface McpUiHostContext {
165
+ /** @description Metadata of the tool call that instantiated this App. */
166
+ toolInfo?: {
167
+ /** @description JSON-RPC id of the tools/call request. */
168
+ id: RequestId;
169
+ /** @description Tool definition including name, inputSchema, etc. */
170
+ tool: Tool;
171
+ };
172
+ /** @description Current color theme preference. */
173
+ theme?: McpUiTheme;
174
+ /** @description How the UI is currently displayed. */
175
+ displayMode?: McpUiDisplayMode;
176
+ /** @description Display modes the host supports. */
177
+ availableDisplayModes?: string[];
178
+ /** @description Current and maximum dimensions available to the UI. */
179
+ viewport?: {
180
+ /** @description Current viewport width in pixels. */
181
+ width: number;
182
+ /** @description Current viewport height in pixels. */
183
+ height: number;
184
+ /** @description Maximum available height in pixels (if constrained). */
185
+ maxHeight?: number;
186
+ /** @description Maximum available width in pixels (if constrained). */
187
+ maxWidth?: number;
188
+ };
189
+ /** @description User's language and region preference in BCP 47 format. */
190
+ locale?: string;
191
+ /** @description User's timezone in IANA format. */
192
+ timeZone?: string;
193
+ /** @description Host application identifier. */
194
+ userAgent?: string;
195
+ /** @description Platform type for responsive design decisions. */
196
+ platform?: "web" | "desktop" | "mobile";
197
+ /** @description Device input capabilities. */
198
+ deviceCapabilities?: {
199
+ /** @description Whether the device supports touch input. */
200
+ touch?: boolean;
201
+ /** @description Whether the device supports hover interactions. */
202
+ hover?: boolean;
203
+ };
204
+ /** @description Mobile safe area boundaries in pixels. */
205
+ safeAreaInsets?: {
206
+ /** @description Top safe area inset in pixels. */
207
+ top: number;
208
+ /** @description Right safe area inset in pixels. */
209
+ right: number;
210
+ /** @description Bottom safe area inset in pixels. */
211
+ bottom: number;
212
+ /** @description Left safe area inset in pixels. */
213
+ left: number;
214
+ };
215
+ }
216
+ /**
217
+ * @description Notification that host context has changed (Host -> Guest UI).
218
+ * @see {@link McpUiHostContext} for the full context structure
219
+ */
220
+ export interface McpUiHostContextChangedNotification {
221
+ method: "ui/notifications/host-context-changed";
222
+ /** @description Partial context update containing only changed fields. */
223
+ params: McpUiHostContext;
224
+ }
225
+ /**
226
+ * @description Request for graceful shutdown of the Guest UI (Host -> Guest UI).
227
+ * @see {@link app-bridge.AppBridge.sendResourceTeardown} for the host method that sends this
228
+ */
229
+ export interface McpUiResourceTeardownRequest {
230
+ method: "ui/resource-teardown";
231
+ params: {};
232
+ }
233
+ /**
234
+ * @description Result from graceful shutdown request.
235
+ * @see {@link McpUiResourceTeardownRequest}
236
+ */
237
+ export interface McpUiResourceTeardownResult {
238
+ /**
239
+ * Index signature required for MCP SDK `Protocol` class compatibility.
240
+ */
241
+ [key: string]: unknown;
242
+ }
243
+ /**
244
+ * @description Capabilities supported by the host application.
245
+ * @see {@link McpUiInitializeResult} for the initialization result that includes these capabilities
246
+ */
247
+ export interface McpUiHostCapabilities {
248
+ /** @description Experimental features (structure TBD). */
249
+ experimental?: {};
250
+ /** @description Host supports opening external URLs. */
251
+ openLinks?: {};
252
+ /** @description Host can proxy tool calls to the MCP server. */
253
+ serverTools?: {
254
+ /** @description Host supports tools/list_changed notifications. */
255
+ listChanged?: boolean;
256
+ };
257
+ /** @description Host can proxy resource reads to the MCP server. */
258
+ serverResources?: {
259
+ /** @description Host supports resources/list_changed notifications. */
260
+ listChanged?: boolean;
261
+ };
262
+ /** @description Host accepts log messages. */
263
+ logging?: {};
264
+ }
265
+ /**
266
+ * @description Capabilities provided by the Guest UI (App).
267
+ * @see {@link McpUiInitializeRequest} for the initialization request that includes these capabilities
268
+ */
269
+ export interface McpUiAppCapabilities {
270
+ /** @description Experimental features (structure TBD). */
271
+ experimental?: {};
272
+ /** @description App exposes MCP-style tools that the host can call. */
273
+ tools?: {
274
+ /** @description App supports tools/list_changed notifications. */
275
+ listChanged?: boolean;
276
+ };
277
+ }
278
+ /**
279
+ * @description Initialization request sent from Guest UI to Host.
280
+ * @see {@link app.App.connect} for the method that sends this request
281
+ */
282
+ export interface McpUiInitializeRequest {
283
+ method: "ui/initialize";
284
+ params: {
285
+ /** @description App identification (name and version). */
286
+ appInfo: Implementation;
287
+ /** @description Features and capabilities this app provides. */
288
+ appCapabilities: McpUiAppCapabilities;
289
+ /** @description Protocol version this app supports. */
290
+ protocolVersion: string;
291
+ };
292
+ }
293
+ /**
294
+ * @description Initialization result returned from Host to Guest UI.
295
+ * @see {@link McpUiInitializeRequest}
296
+ */
297
+ export interface McpUiInitializeResult {
298
+ /** @description Negotiated protocol version string (e.g., "2025-11-21"). */
299
+ protocolVersion: string;
300
+ /** @description Host application identification and version. */
301
+ hostInfo: Implementation;
302
+ /** @description Features and capabilities provided by the host. */
303
+ hostCapabilities: McpUiHostCapabilities;
304
+ /** @description Rich context about the host environment. */
305
+ hostContext: McpUiHostContext;
306
+ /**
307
+ * Index signature required for MCP SDK `Protocol` class compatibility.
308
+ * Note: The schema intentionally omits this to enforce strict validation.
309
+ */
310
+ [key: string]: unknown;
311
+ }
312
+ /**
313
+ * @description Notification that Guest UI has completed initialization (Guest UI -> Host).
314
+ * @see {@link app.App.connect} for the method that sends this notification
315
+ */
316
+ export interface McpUiInitializedNotification {
317
+ method: "ui/notifications/initialized";
318
+ params?: {};
319
+ }
320
+ /**
321
+ * @description Content Security Policy configuration for UI resources.
322
+ */
323
+ export interface McpUiResourceCsp {
324
+ /** @description Origins for network requests (fetch/XHR/WebSocket). */
325
+ connectDomains?: string[];
326
+ /** @description Origins for static resources (scripts, images, styles, fonts). */
327
+ resourceDomains?: string[];
328
+ }
329
+ /**
330
+ * @description UI Resource metadata for security and rendering configuration.
331
+ */
332
+ export interface McpUiResourceMeta {
333
+ /** @description Content Security Policy configuration. */
334
+ csp?: McpUiResourceCsp;
335
+ /** @description Dedicated origin for widget sandbox. */
336
+ domain?: string;
337
+ /** @description Visual boundary preference - true if UI prefers a visible border. */
338
+ prefersBorder?: boolean;
339
+ }