@modelcontextprotocol/ext-apps 0.3.1 → 0.4.1
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.
- package/LICENSE +196 -1
- package/README.md +32 -10
- package/dist/src/app-bridge.d.ts +131 -72
- package/dist/src/app-bridge.js +10 -10
- package/dist/src/app-with-deps.js +9 -9
- package/dist/src/app.d.ts +75 -24
- package/dist/src/app.js +18 -18
- package/dist/src/generated/schema.d.ts +230 -29
- package/dist/src/generated/schema.test.d.ts +5 -2
- package/dist/src/message-transport.d.ts +20 -22
- package/dist/src/react/index.js +17 -17
- package/dist/src/react/react-with-deps.js +17 -17
- package/dist/src/react/useApp.d.ts +22 -17
- package/dist/src/react/useAutoResize.d.ts +5 -3
- package/dist/src/react/useDocumentTheme.d.ts +3 -1
- package/dist/src/react/useHostStyles.d.ts +19 -18
- package/dist/src/server/index.d.ts +106 -13
- package/dist/src/server/index.js +19 -19
- package/dist/src/spec.types.d.ts +85 -21
- package/dist/src/styles.d.ts +5 -5
- package/dist/src/types.d.ts +11 -10
- package/package.json +6 -4
|
@@ -23,7 +23,7 @@ export declare const McpUiStyleVariableKeySchema: z.ZodUnion<readonly [z.ZodLite
|
|
|
23
23
|
export declare const McpUiStylesSchema: z.ZodRecord<z.ZodUnion<readonly [z.ZodLiteral<"--color-background-primary">, z.ZodLiteral<"--color-background-secondary">, z.ZodLiteral<"--color-background-tertiary">, z.ZodLiteral<"--color-background-inverse">, z.ZodLiteral<"--color-background-ghost">, z.ZodLiteral<"--color-background-info">, z.ZodLiteral<"--color-background-danger">, z.ZodLiteral<"--color-background-success">, z.ZodLiteral<"--color-background-warning">, z.ZodLiteral<"--color-background-disabled">, z.ZodLiteral<"--color-text-primary">, z.ZodLiteral<"--color-text-secondary">, z.ZodLiteral<"--color-text-tertiary">, z.ZodLiteral<"--color-text-inverse">, z.ZodLiteral<"--color-text-ghost">, z.ZodLiteral<"--color-text-info">, z.ZodLiteral<"--color-text-danger">, z.ZodLiteral<"--color-text-success">, z.ZodLiteral<"--color-text-warning">, z.ZodLiteral<"--color-text-disabled">, z.ZodLiteral<"--color-text-ghost">, z.ZodLiteral<"--color-border-primary">, z.ZodLiteral<"--color-border-secondary">, z.ZodLiteral<"--color-border-tertiary">, z.ZodLiteral<"--color-border-inverse">, z.ZodLiteral<"--color-border-ghost">, z.ZodLiteral<"--color-border-info">, z.ZodLiteral<"--color-border-danger">, z.ZodLiteral<"--color-border-success">, z.ZodLiteral<"--color-border-warning">, z.ZodLiteral<"--color-border-disabled">, z.ZodLiteral<"--color-ring-primary">, z.ZodLiteral<"--color-ring-secondary">, z.ZodLiteral<"--color-ring-inverse">, z.ZodLiteral<"--color-ring-info">, z.ZodLiteral<"--color-ring-danger">, z.ZodLiteral<"--color-ring-success">, z.ZodLiteral<"--color-ring-warning">, z.ZodLiteral<"--font-sans">, z.ZodLiteral<"--font-mono">, z.ZodLiteral<"--font-weight-normal">, z.ZodLiteral<"--font-weight-medium">, z.ZodLiteral<"--font-weight-semibold">, z.ZodLiteral<"--font-weight-bold">, z.ZodLiteral<"--font-text-xs-size">, z.ZodLiteral<"--font-text-sm-size">, z.ZodLiteral<"--font-text-md-size">, z.ZodLiteral<"--font-text-lg-size">, z.ZodLiteral<"--font-heading-xs-size">, z.ZodLiteral<"--font-heading-sm-size">, z.ZodLiteral<"--font-heading-md-size">, z.ZodLiteral<"--font-heading-lg-size">, z.ZodLiteral<"--font-heading-xl-size">, z.ZodLiteral<"--font-heading-2xl-size">, z.ZodLiteral<"--font-heading-3xl-size">, z.ZodLiteral<"--font-text-xs-line-height">, z.ZodLiteral<"--font-text-sm-line-height">, z.ZodLiteral<"--font-text-md-line-height">, z.ZodLiteral<"--font-text-lg-line-height">, z.ZodLiteral<"--font-heading-xs-line-height">, z.ZodLiteral<"--font-heading-sm-line-height">, z.ZodLiteral<"--font-heading-md-line-height">, z.ZodLiteral<"--font-heading-lg-line-height">, z.ZodLiteral<"--font-heading-xl-line-height">, z.ZodLiteral<"--font-heading-2xl-line-height">, z.ZodLiteral<"--font-heading-3xl-line-height">, z.ZodLiteral<"--border-radius-xs">, z.ZodLiteral<"--border-radius-sm">, z.ZodLiteral<"--border-radius-md">, z.ZodLiteral<"--border-radius-lg">, z.ZodLiteral<"--border-radius-xl">, z.ZodLiteral<"--border-radius-full">, z.ZodLiteral<"--border-width-regular">, z.ZodLiteral<"--shadow-hairline">, z.ZodLiteral<"--shadow-sm">, z.ZodLiteral<"--shadow-md">, z.ZodLiteral<"--shadow-lg">]>, z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
24
24
|
/**
|
|
25
25
|
* @description Request to open an external URL in the host's default browser.
|
|
26
|
-
* @see {@link app
|
|
26
|
+
* @see {@link app!App.openLink} for the method that sends this request
|
|
27
27
|
*/
|
|
28
28
|
export declare const McpUiOpenLinkRequestSchema: z.ZodObject<{
|
|
29
29
|
method: z.ZodLiteral<"ui/open-link">;
|
|
@@ -55,24 +55,28 @@ export declare const McpUiSandboxProxyReadyNotificationSchema: z.ZodObject<{
|
|
|
55
55
|
params: z.ZodObject<{}, z.core.$strip>;
|
|
56
56
|
}, z.core.$strip>;
|
|
57
57
|
/**
|
|
58
|
-
* @description
|
|
59
|
-
* @internal
|
|
60
|
-
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx#sandbox-proxy
|
|
58
|
+
* @description Content Security Policy configuration for UI resources.
|
|
61
59
|
*/
|
|
62
|
-
export declare const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
export declare const McpUiResourceCspSchema: z.ZodObject<{
|
|
61
|
+
connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
+
resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
frameDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
baseUriDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
/**
|
|
67
|
+
* @description Sandbox permissions requested by the UI resource.
|
|
68
|
+
* Hosts MAY honor these by setting appropriate iframe `allow` attributes.
|
|
69
|
+
* Apps SHOULD NOT assume permissions are granted; use JS feature detection as fallback.
|
|
70
|
+
*/
|
|
71
|
+
export declare const McpUiResourcePermissionsSchema: z.ZodObject<{
|
|
72
|
+
camera: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
73
|
+
microphone: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
74
|
+
geolocation: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
75
|
+
clipboardWrite: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
72
76
|
}, z.core.$strip>;
|
|
73
77
|
/**
|
|
74
|
-
* @description Notification of UI size changes (
|
|
75
|
-
* @see {@link app
|
|
78
|
+
* @description Notification of UI size changes (Guest UI -> Host).
|
|
79
|
+
* @see {@link app!App.sendSizeChanged} for the method to send this from Guest UI
|
|
76
80
|
*/
|
|
77
81
|
export declare const McpUiSizeChangedNotificationSchema: z.ZodObject<{
|
|
78
82
|
method: z.ZodLiteral<"ui/notifications/size-changed">;
|
|
@@ -127,7 +131,7 @@ export declare const McpUiHostStylesSchema: z.ZodObject<{
|
|
|
127
131
|
}, z.core.$strip>;
|
|
128
132
|
/**
|
|
129
133
|
* @description Request for graceful shutdown of the Guest UI (Host -> Guest UI).
|
|
130
|
-
* @see {@link app-bridge
|
|
134
|
+
* @see {@link app-bridge!AppBridge.teardownResource} for the host method that sends this
|
|
131
135
|
*/
|
|
132
136
|
export declare const McpUiResourceTeardownRequestSchema: z.ZodObject<{
|
|
133
137
|
method: z.ZodLiteral<"ui/resource-teardown">;
|
|
@@ -138,6 +142,14 @@ export declare const McpUiResourceTeardownRequestSchema: z.ZodObject<{
|
|
|
138
142
|
* @see {@link McpUiResourceTeardownRequest}
|
|
139
143
|
*/
|
|
140
144
|
export declare const McpUiResourceTeardownResultSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
145
|
+
export declare const McpUiSupportedContentBlockModalitiesSchema: z.ZodObject<{
|
|
146
|
+
text: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
147
|
+
image: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
148
|
+
audio: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
149
|
+
resource: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
150
|
+
resourceLink: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
151
|
+
structuredContent: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
152
|
+
}, z.core.$strip>;
|
|
141
153
|
/**
|
|
142
154
|
* @description Capabilities supported by the host application.
|
|
143
155
|
* @see {@link McpUiInitializeResult} for the initialization result that includes these capabilities
|
|
@@ -152,9 +164,39 @@ export declare const McpUiHostCapabilitiesSchema: z.ZodObject<{
|
|
|
152
164
|
listChanged: z.ZodOptional<z.ZodBoolean>;
|
|
153
165
|
}, z.core.$strip>>;
|
|
154
166
|
logging: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
167
|
+
sandbox: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
169
|
+
camera: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
170
|
+
microphone: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
171
|
+
geolocation: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
172
|
+
clipboardWrite: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
173
|
+
}, z.core.$strip>>;
|
|
174
|
+
csp: z.ZodOptional<z.ZodObject<{
|
|
175
|
+
connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
176
|
+
resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
177
|
+
frameDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
178
|
+
baseUriDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
179
|
+
}, z.core.$strip>>;
|
|
180
|
+
}, z.core.$strip>>;
|
|
181
|
+
updateModelContext: z.ZodOptional<z.ZodObject<{
|
|
182
|
+
text: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
183
|
+
image: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
184
|
+
audio: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
185
|
+
resource: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
186
|
+
resourceLink: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
187
|
+
structuredContent: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
188
|
+
}, z.core.$strip>>;
|
|
189
|
+
message: z.ZodOptional<z.ZodObject<{
|
|
190
|
+
text: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
191
|
+
image: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
192
|
+
audio: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
193
|
+
resource: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
194
|
+
resourceLink: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
195
|
+
structuredContent: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
196
|
+
}, z.core.$strip>>;
|
|
155
197
|
}, z.core.$strip>;
|
|
156
198
|
/**
|
|
157
|
-
* @description Capabilities provided by the Guest UI (App).
|
|
199
|
+
* @description Capabilities provided by the Guest UI ({@link app!App}).
|
|
158
200
|
* @see {@link McpUiInitializeRequest} for the initialization request that includes these capabilities
|
|
159
201
|
*/
|
|
160
202
|
export declare const McpUiAppCapabilitiesSchema: z.ZodObject<{
|
|
@@ -165,19 +207,12 @@ export declare const McpUiAppCapabilitiesSchema: z.ZodObject<{
|
|
|
165
207
|
}, z.core.$strip>;
|
|
166
208
|
/**
|
|
167
209
|
* @description Notification that Guest UI has completed initialization (Guest UI -> Host).
|
|
168
|
-
* @see {@link app
|
|
210
|
+
* @see {@link app!App.connect} for the method that sends this notification
|
|
169
211
|
*/
|
|
170
212
|
export declare const McpUiInitializedNotificationSchema: z.ZodObject<{
|
|
171
213
|
method: z.ZodLiteral<"ui/notifications/initialized">;
|
|
172
214
|
params: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
173
215
|
}, z.core.$strip>;
|
|
174
|
-
/**
|
|
175
|
-
* @description Content Security Policy configuration for UI resources.
|
|
176
|
-
*/
|
|
177
|
-
export declare const McpUiResourceCspSchema: z.ZodObject<{
|
|
178
|
-
connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
179
|
-
resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
180
|
-
}, z.core.$strip>;
|
|
181
216
|
/**
|
|
182
217
|
* @description UI Resource metadata for security and rendering configuration.
|
|
183
218
|
*/
|
|
@@ -185,6 +220,14 @@ export declare const McpUiResourceMetaSchema: z.ZodObject<{
|
|
|
185
220
|
csp: z.ZodOptional<z.ZodObject<{
|
|
186
221
|
connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
187
222
|
resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
223
|
+
frameDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
224
|
+
baseUriDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
225
|
+
}, z.core.$strip>>;
|
|
226
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
227
|
+
camera: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
228
|
+
microphone: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
229
|
+
geolocation: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
230
|
+
clipboardWrite: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
188
231
|
}, z.core.$strip>>;
|
|
189
232
|
domain: z.ZodOptional<z.ZodString>;
|
|
190
233
|
prefersBorder: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -193,7 +236,7 @@ export declare const McpUiResourceMetaSchema: z.ZodObject<{
|
|
|
193
236
|
* @description Request to change the display mode of the UI.
|
|
194
237
|
* The host will respond with the actual display mode that was set,
|
|
195
238
|
* which may differ from the requested mode if not supported.
|
|
196
|
-
* @see {@link app
|
|
239
|
+
* @see {@link app!App.requestDisplayMode} for the method that sends this request
|
|
197
240
|
*/
|
|
198
241
|
export declare const McpUiRequestDisplayModeRequestSchema: z.ZodObject<{
|
|
199
242
|
method: z.ZodLiteral<"ui/request-display-mode">;
|
|
@@ -221,7 +264,7 @@ export declare const McpUiToolMetaSchema: z.ZodObject<{
|
|
|
221
264
|
}, z.core.$strip>;
|
|
222
265
|
/**
|
|
223
266
|
* @description Request to send a message to the host's chat interface.
|
|
224
|
-
* @see {@link app
|
|
267
|
+
* @see {@link app!App.sendMessage} for the method that sends this request
|
|
225
268
|
*/
|
|
226
269
|
export declare const McpUiMessageRequestSchema: z.ZodObject<{
|
|
227
270
|
method: z.ZodLiteral<"ui/message">;
|
|
@@ -315,6 +358,30 @@ export declare const McpUiMessageRequestSchema: z.ZodObject<{
|
|
|
315
358
|
}, z.core.$strip>]>>;
|
|
316
359
|
}, z.core.$strip>;
|
|
317
360
|
}, z.core.$strip>;
|
|
361
|
+
/**
|
|
362
|
+
* @description Notification containing HTML resource for the sandbox proxy to load.
|
|
363
|
+
* @internal
|
|
364
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx#sandbox-proxy
|
|
365
|
+
*/
|
|
366
|
+
export declare const McpUiSandboxResourceReadyNotificationSchema: z.ZodObject<{
|
|
367
|
+
method: z.ZodLiteral<"ui/notifications/sandbox-resource-ready">;
|
|
368
|
+
params: z.ZodObject<{
|
|
369
|
+
html: z.ZodString;
|
|
370
|
+
sandbox: z.ZodOptional<z.ZodString>;
|
|
371
|
+
csp: z.ZodOptional<z.ZodObject<{
|
|
372
|
+
connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
373
|
+
resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
374
|
+
frameDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
375
|
+
baseUriDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
376
|
+
}, z.core.$strip>>;
|
|
377
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
378
|
+
camera: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
379
|
+
microphone: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
380
|
+
geolocation: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
381
|
+
clipboardWrite: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
382
|
+
}, z.core.$strip>>;
|
|
383
|
+
}, z.core.$strip>;
|
|
384
|
+
}, z.core.$strip>;
|
|
318
385
|
/**
|
|
319
386
|
* @description Notification containing tool execution result (Host -> Guest UI).
|
|
320
387
|
*/
|
|
@@ -579,9 +646,113 @@ export declare const McpUiHostContextChangedNotificationSchema: z.ZodObject<{
|
|
|
579
646
|
}, z.core.$strip>>;
|
|
580
647
|
}, z.core.$loose>;
|
|
581
648
|
}, z.core.$strip>;
|
|
649
|
+
/**
|
|
650
|
+
* @description Request to update the agent's context without requiring a follow-up action (Guest UI -> Host).
|
|
651
|
+
*
|
|
652
|
+
* Unlike `notifications/message` which is for debugging/logging, this request is intended
|
|
653
|
+
* to update the Host's model context. Each request overwrites the previous context sent by the Guest UI.
|
|
654
|
+
* Unlike messages, context updates do not trigger follow-ups.
|
|
655
|
+
*
|
|
656
|
+
* The host will typically defer sending the context to the model until the next user message
|
|
657
|
+
* (including `ui/message`), and will only send the last update received.
|
|
658
|
+
*
|
|
659
|
+
* @see {@link app.App.updateModelContext} for the method that sends this request
|
|
660
|
+
*/
|
|
661
|
+
export declare const McpUiUpdateModelContextRequestSchema: z.ZodObject<{
|
|
662
|
+
method: z.ZodLiteral<"ui/update-model-context">;
|
|
663
|
+
params: z.ZodObject<{
|
|
664
|
+
content: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
665
|
+
type: z.ZodLiteral<"text">;
|
|
666
|
+
text: z.ZodString;
|
|
667
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
668
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
669
|
+
user: "user";
|
|
670
|
+
assistant: "assistant";
|
|
671
|
+
}>>>;
|
|
672
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
673
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
674
|
+
}, z.core.$strip>>;
|
|
675
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
676
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
677
|
+
type: z.ZodLiteral<"image">;
|
|
678
|
+
data: z.ZodString;
|
|
679
|
+
mimeType: z.ZodString;
|
|
680
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
681
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
682
|
+
user: "user";
|
|
683
|
+
assistant: "assistant";
|
|
684
|
+
}>>>;
|
|
685
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
686
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
687
|
+
}, z.core.$strip>>;
|
|
688
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
689
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
690
|
+
type: z.ZodLiteral<"audio">;
|
|
691
|
+
data: z.ZodString;
|
|
692
|
+
mimeType: z.ZodString;
|
|
693
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
694
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
695
|
+
user: "user";
|
|
696
|
+
assistant: "assistant";
|
|
697
|
+
}>>>;
|
|
698
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
699
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
700
|
+
}, z.core.$strip>>;
|
|
701
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
702
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
703
|
+
uri: z.ZodString;
|
|
704
|
+
description: z.ZodOptional<z.ZodString>;
|
|
705
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
706
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
707
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
708
|
+
user: "user";
|
|
709
|
+
assistant: "assistant";
|
|
710
|
+
}>>>;
|
|
711
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
712
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
713
|
+
}, z.core.$strip>>;
|
|
714
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
715
|
+
icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
716
|
+
src: z.ZodString;
|
|
717
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
718
|
+
sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
719
|
+
theme: z.ZodOptional<z.ZodEnum<{
|
|
720
|
+
light: "light";
|
|
721
|
+
dark: "dark";
|
|
722
|
+
}>>;
|
|
723
|
+
}, z.core.$strip>>>;
|
|
724
|
+
name: z.ZodString;
|
|
725
|
+
title: z.ZodOptional<z.ZodString>;
|
|
726
|
+
type: z.ZodLiteral<"resource_link">;
|
|
727
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
728
|
+
type: z.ZodLiteral<"resource">;
|
|
729
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
730
|
+
uri: z.ZodString;
|
|
731
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
732
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
733
|
+
text: z.ZodString;
|
|
734
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
735
|
+
uri: z.ZodString;
|
|
736
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
737
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
738
|
+
blob: z.ZodString;
|
|
739
|
+
}, z.core.$strip>]>;
|
|
740
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
741
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
742
|
+
user: "user";
|
|
743
|
+
assistant: "assistant";
|
|
744
|
+
}>>>;
|
|
745
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
746
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
747
|
+
}, z.core.$strip>>;
|
|
748
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
749
|
+
}, z.core.$strip>]>>>;
|
|
750
|
+
structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
751
|
+
}, z.core.$strip>;
|
|
752
|
+
}, z.core.$strip>;
|
|
582
753
|
/**
|
|
583
754
|
* @description Initialization request sent from Guest UI to Host.
|
|
584
|
-
* @see {@link app
|
|
755
|
+
* @see {@link app!App.connect} for the method that sends this request
|
|
585
756
|
*/
|
|
586
757
|
export declare const McpUiInitializeRequestSchema: z.ZodObject<{
|
|
587
758
|
method: z.ZodLiteral<"ui/initialize">;
|
|
@@ -643,6 +814,36 @@ export declare const McpUiInitializeResultSchema: z.ZodObject<{
|
|
|
643
814
|
listChanged: z.ZodOptional<z.ZodBoolean>;
|
|
644
815
|
}, z.core.$strip>>;
|
|
645
816
|
logging: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
817
|
+
sandbox: z.ZodOptional<z.ZodObject<{
|
|
818
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
819
|
+
camera: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
820
|
+
microphone: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
821
|
+
geolocation: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
822
|
+
clipboardWrite: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
823
|
+
}, z.core.$strip>>;
|
|
824
|
+
csp: z.ZodOptional<z.ZodObject<{
|
|
825
|
+
connectDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
826
|
+
resourceDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
827
|
+
frameDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
828
|
+
baseUriDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
829
|
+
}, z.core.$strip>>;
|
|
830
|
+
}, z.core.$strip>>;
|
|
831
|
+
updateModelContext: z.ZodOptional<z.ZodObject<{
|
|
832
|
+
text: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
833
|
+
image: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
834
|
+
audio: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
835
|
+
resource: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
836
|
+
resourceLink: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
837
|
+
structuredContent: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
838
|
+
}, z.core.$strip>>;
|
|
839
|
+
message: z.ZodOptional<z.ZodObject<{
|
|
840
|
+
text: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
841
|
+
image: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
842
|
+
audio: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
843
|
+
resource: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
844
|
+
resourceLink: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
845
|
+
structuredContent: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
846
|
+
}, z.core.$strip>>;
|
|
646
847
|
}, z.core.$strip>;
|
|
647
848
|
hostContext: z.ZodObject<{
|
|
648
849
|
toolInfo: z.ZodOptional<z.ZodObject<{
|
|
@@ -8,7 +8,8 @@ export type McpUiOpenLinkRequestSchemaInferredType = z.infer<typeof generated.Mc
|
|
|
8
8
|
export type McpUiOpenLinkResultSchemaInferredType = z.infer<typeof generated.McpUiOpenLinkResultSchema>;
|
|
9
9
|
export type McpUiMessageResultSchemaInferredType = z.infer<typeof generated.McpUiMessageResultSchema>;
|
|
10
10
|
export type McpUiSandboxProxyReadyNotificationSchemaInferredType = z.infer<typeof generated.McpUiSandboxProxyReadyNotificationSchema>;
|
|
11
|
-
export type
|
|
11
|
+
export type McpUiResourceCspSchemaInferredType = z.infer<typeof generated.McpUiResourceCspSchema>;
|
|
12
|
+
export type McpUiResourcePermissionsSchemaInferredType = z.infer<typeof generated.McpUiResourcePermissionsSchema>;
|
|
12
13
|
export type McpUiSizeChangedNotificationSchemaInferredType = z.infer<typeof generated.McpUiSizeChangedNotificationSchema>;
|
|
13
14
|
export type McpUiToolInputNotificationSchemaInferredType = z.infer<typeof generated.McpUiToolInputNotificationSchema>;
|
|
14
15
|
export type McpUiToolInputPartialNotificationSchemaInferredType = z.infer<typeof generated.McpUiToolInputPartialNotificationSchema>;
|
|
@@ -17,18 +18,20 @@ export type McpUiHostCssSchemaInferredType = z.infer<typeof generated.McpUiHostC
|
|
|
17
18
|
export type McpUiHostStylesSchemaInferredType = z.infer<typeof generated.McpUiHostStylesSchema>;
|
|
18
19
|
export type McpUiResourceTeardownRequestSchemaInferredType = z.infer<typeof generated.McpUiResourceTeardownRequestSchema>;
|
|
19
20
|
export type McpUiResourceTeardownResultSchemaInferredType = z.infer<typeof generated.McpUiResourceTeardownResultSchema>;
|
|
21
|
+
export type McpUiSupportedContentBlockModalitiesSchemaInferredType = z.infer<typeof generated.McpUiSupportedContentBlockModalitiesSchema>;
|
|
20
22
|
export type McpUiHostCapabilitiesSchemaInferredType = z.infer<typeof generated.McpUiHostCapabilitiesSchema>;
|
|
21
23
|
export type McpUiAppCapabilitiesSchemaInferredType = z.infer<typeof generated.McpUiAppCapabilitiesSchema>;
|
|
22
24
|
export type McpUiInitializedNotificationSchemaInferredType = z.infer<typeof generated.McpUiInitializedNotificationSchema>;
|
|
23
|
-
export type McpUiResourceCspSchemaInferredType = z.infer<typeof generated.McpUiResourceCspSchema>;
|
|
24
25
|
export type McpUiResourceMetaSchemaInferredType = z.infer<typeof generated.McpUiResourceMetaSchema>;
|
|
25
26
|
export type McpUiRequestDisplayModeRequestSchemaInferredType = z.infer<typeof generated.McpUiRequestDisplayModeRequestSchema>;
|
|
26
27
|
export type McpUiRequestDisplayModeResultSchemaInferredType = z.infer<typeof generated.McpUiRequestDisplayModeResultSchema>;
|
|
27
28
|
export type McpUiToolVisibilitySchemaInferredType = z.infer<typeof generated.McpUiToolVisibilitySchema>;
|
|
28
29
|
export type McpUiToolMetaSchemaInferredType = z.infer<typeof generated.McpUiToolMetaSchema>;
|
|
29
30
|
export type McpUiMessageRequestSchemaInferredType = z.infer<typeof generated.McpUiMessageRequestSchema>;
|
|
31
|
+
export type McpUiSandboxResourceReadyNotificationSchemaInferredType = z.infer<typeof generated.McpUiSandboxResourceReadyNotificationSchema>;
|
|
30
32
|
export type McpUiToolResultNotificationSchemaInferredType = z.infer<typeof generated.McpUiToolResultNotificationSchema>;
|
|
31
33
|
export type McpUiHostContextSchemaInferredType = z.infer<typeof generated.McpUiHostContextSchema>;
|
|
32
34
|
export type McpUiHostContextChangedNotificationSchemaInferredType = z.infer<typeof generated.McpUiHostContextChangedNotificationSchema>;
|
|
35
|
+
export type McpUiUpdateModelContextRequestSchemaInferredType = z.infer<typeof generated.McpUiUpdateModelContextRequestSchema>;
|
|
33
36
|
export type McpUiInitializeRequestSchemaInferredType = z.infer<typeof generated.McpUiInitializeRequestSchema>;
|
|
34
37
|
export type McpUiInitializeResultSchemaInferredType = z.infer<typeof generated.McpUiInitializeResultSchema>;
|
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
import { JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
2
2
|
import { Transport, TransportSendOptions } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
3
3
|
/**
|
|
4
|
-
* JSON-RPC transport using window.postMessage for iframe↔parent communication.
|
|
4
|
+
* JSON-RPC transport using `window.postMessage` for iframe↔parent communication.
|
|
5
5
|
*
|
|
6
6
|
* This transport enables bidirectional communication between MCP Apps running in
|
|
7
|
-
* iframes and their host applications using the browser's postMessage API. It
|
|
8
|
-
* implements the MCP SDK's Transport interface.
|
|
7
|
+
* iframes and their host applications using the browser's `postMessage` API. It
|
|
8
|
+
* implements the MCP SDK's `Transport` interface.
|
|
9
9
|
*
|
|
10
10
|
* ## Security
|
|
11
11
|
*
|
|
12
|
-
* The `eventSource` parameter
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* security.
|
|
12
|
+
* The `eventSource` parameter is required and validates the message source window
|
|
13
|
+
* by checking `event.source`. For guest UIs, pass `window.parent`.
|
|
14
|
+
* For hosts, pass `iframe.contentWindow` to validate the iframe source.
|
|
16
15
|
*
|
|
17
16
|
* ## Usage
|
|
18
17
|
*
|
|
19
|
-
* **Guest UI
|
|
18
|
+
* **Guest UI**:
|
|
20
19
|
* ```typescript
|
|
21
|
-
* const transport = new PostMessageTransport(window.parent);
|
|
20
|
+
* const transport = new PostMessageTransport(window.parent, window.parent);
|
|
22
21
|
* await app.connect(transport);
|
|
23
22
|
* ```
|
|
24
23
|
*
|
|
25
|
-
* **Host
|
|
24
|
+
* **Host**:
|
|
26
25
|
* ```typescript
|
|
27
26
|
* const iframe = document.getElementById('app-iframe') as HTMLIFrameElement;
|
|
28
27
|
* const transport = new PostMessageTransport(
|
|
29
28
|
* iframe.contentWindow!,
|
|
30
|
-
* iframe.contentWindow
|
|
29
|
+
* iframe.contentWindow!
|
|
31
30
|
* );
|
|
32
31
|
* await bridge.connect(transport);
|
|
33
32
|
* ```
|
|
34
33
|
*
|
|
35
|
-
* @see {@link app
|
|
36
|
-
* @see {@link app-bridge
|
|
34
|
+
* @see {@link app!App.connect} for Guest UI usage
|
|
35
|
+
* @see {@link app-bridge!AppBridge.connect} for Host usage
|
|
37
36
|
*/
|
|
38
37
|
export declare class PostMessageTransport implements Transport {
|
|
39
38
|
private eventTarget;
|
|
@@ -42,22 +41,21 @@ export declare class PostMessageTransport implements Transport {
|
|
|
42
41
|
/**
|
|
43
42
|
* Create a new PostMessageTransport.
|
|
44
43
|
*
|
|
45
|
-
* @param eventTarget - Target window to send messages to (default: window.parent)
|
|
46
|
-
* @param eventSource -
|
|
47
|
-
*
|
|
48
|
-
* receive from parent), but hosts should validate the iframe source.
|
|
44
|
+
* @param eventTarget - Target window to send messages to (default: `window.parent`)
|
|
45
|
+
* @param eventSource - Source window for message validation. For guests, pass
|
|
46
|
+
* `window.parent`. For hosts, pass `iframe.contentWindow`.
|
|
49
47
|
*
|
|
50
48
|
* @example Guest UI connecting to parent
|
|
51
49
|
* ```typescript
|
|
52
|
-
* const transport = new PostMessageTransport(window.parent);
|
|
50
|
+
* const transport = new PostMessageTransport(window.parent, window.parent);
|
|
53
51
|
* ```
|
|
54
52
|
*
|
|
55
|
-
* @example Host connecting to iframe
|
|
53
|
+
* @example Host connecting to iframe
|
|
56
54
|
* ```typescript
|
|
57
55
|
* const iframe = document.getElementById('app') as HTMLIFrameElement;
|
|
58
56
|
* const transport = new PostMessageTransport(
|
|
59
57
|
* iframe.contentWindow!,
|
|
60
|
-
* iframe.contentWindow
|
|
58
|
+
* iframe.contentWindow!
|
|
61
59
|
* );
|
|
62
60
|
* ```
|
|
63
61
|
*/
|
|
@@ -72,7 +70,7 @@ export declare class PostMessageTransport implements Transport {
|
|
|
72
70
|
/**
|
|
73
71
|
* Send a JSON-RPC message to the target window.
|
|
74
72
|
*
|
|
75
|
-
* Messages are sent using postMessage with "*" origin, meaning they are visible
|
|
73
|
+
* Messages are sent using `postMessage` with `"*"` origin, meaning they are visible
|
|
76
74
|
* to all frames. The receiver should validate the message source for security.
|
|
77
75
|
*
|
|
78
76
|
* @param message - JSON-RPC message to send
|
|
@@ -114,7 +112,7 @@ export declare class PostMessageTransport implements Transport {
|
|
|
114
112
|
* Optional session identifier for this transport connection.
|
|
115
113
|
*
|
|
116
114
|
* Set by the MCP SDK to track the connection session. Not required for
|
|
117
|
-
* PostMessageTransport functionality.
|
|
115
|
+
* `PostMessageTransport` functionality.
|
|
118
116
|
*/
|
|
119
117
|
sessionId?: string;
|
|
120
118
|
/**
|