@modelcontextprotocol/ext-apps 0.4.1 → 1.0.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.
- package/README.md +448 -30
- package/dist/docs/patterns.d.ts +9 -0
- package/dist/src/app-bridge.d.ts +187 -194
- package/dist/src/app-bridge.examples.d.ts +9 -0
- package/dist/src/app-bridge.js +17 -17
- package/dist/src/app-with-deps.js +9 -9
- package/dist/src/app.d.ts +224 -197
- package/dist/src/app.examples.d.ts +9 -0
- package/dist/src/app.js +10 -10
- package/dist/src/generated/schema.d.ts +47 -35
- package/dist/src/generated/schema.test.d.ts +1 -0
- package/dist/src/message-transport.d.ts +17 -17
- package/dist/src/message-transport.examples.d.ts +9 -0
- package/dist/src/react/index.d.ts +8 -10
- package/dist/src/react/index.examples.d.ts +6 -0
- package/dist/src/react/index.js +8 -8
- package/dist/src/react/react-with-deps.js +8 -8
- package/dist/src/react/useApp.d.ts +45 -36
- package/dist/src/react/useApp.examples.d.ts +6 -0
- package/dist/src/react/useAutoResize.d.ts +10 -9
- package/dist/src/react/useAutoResize.examples.d.ts +6 -0
- package/dist/src/react/useDocumentTheme.d.ts +11 -15
- package/dist/src/react/useDocumentTheme.examples.d.ts +6 -0
- package/dist/src/react/useHostStyles.d.ts +33 -42
- package/dist/src/react/useHostStyles.examples.d.ts +6 -0
- package/dist/src/server/index.d.ts +169 -88
- package/dist/src/server/index.examples.d.ts +9 -0
- package/dist/src/server/index.js +9 -9
- package/dist/src/spec.types.d.ts +55 -39
- package/dist/src/styles.d.ts +71 -28
- package/dist/src/styles.examples.d.ts +9 -0
- package/dist/src/types.d.ts +1 -1
- package/package.json +25 -8
|
@@ -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!App.openLink} for the method that sends this request
|
|
26
|
+
* @see {@link app!App.openLink `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">;
|
|
@@ -33,14 +33,14 @@ export declare const McpUiOpenLinkRequestSchema: z.ZodObject<{
|
|
|
33
33
|
}, z.core.$strip>;
|
|
34
34
|
/**
|
|
35
35
|
* @description Result from opening a URL.
|
|
36
|
-
* @see {@link McpUiOpenLinkRequest}
|
|
36
|
+
* @see {@link McpUiOpenLinkRequest `McpUiOpenLinkRequest`}
|
|
37
37
|
*/
|
|
38
38
|
export declare const McpUiOpenLinkResultSchema: z.ZodObject<{
|
|
39
39
|
isError: z.ZodOptional<z.ZodBoolean>;
|
|
40
40
|
}, z.core.$loose>;
|
|
41
41
|
/**
|
|
42
42
|
* @description Result from sending a message.
|
|
43
|
-
* @see {@link McpUiMessageRequest}
|
|
43
|
+
* @see {@link McpUiMessageRequest `McpUiMessageRequest`}
|
|
44
44
|
*/
|
|
45
45
|
export declare const McpUiMessageResultSchema: z.ZodObject<{
|
|
46
46
|
isError: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -48,7 +48,7 @@ export declare const McpUiMessageResultSchema: z.ZodObject<{
|
|
|
48
48
|
/**
|
|
49
49
|
* @description Notification that the sandbox proxy iframe is ready to receive content.
|
|
50
50
|
* @internal
|
|
51
|
-
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/
|
|
51
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx#sandbox-proxy
|
|
52
52
|
*/
|
|
53
53
|
export declare const McpUiSandboxProxyReadyNotificationSchema: z.ZodObject<{
|
|
54
54
|
method: z.ZodLiteral<"ui/notifications/sandbox-proxy-ready">;
|
|
@@ -75,8 +75,8 @@ export declare const McpUiResourcePermissionsSchema: z.ZodObject<{
|
|
|
75
75
|
clipboardWrite: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
76
76
|
}, z.core.$strip>;
|
|
77
77
|
/**
|
|
78
|
-
* @description Notification of UI size changes (
|
|
79
|
-
* @see {@link app!App.sendSizeChanged} for the method to send this from
|
|
78
|
+
* @description Notification of UI size changes (View -> Host).
|
|
79
|
+
* @see {@link app!App.sendSizeChanged `App.sendSizeChanged`} for the method to send this from View
|
|
80
80
|
*/
|
|
81
81
|
export declare const McpUiSizeChangedNotificationSchema: z.ZodObject<{
|
|
82
82
|
method: z.ZodLiteral<"ui/notifications/size-changed">;
|
|
@@ -86,7 +86,7 @@ export declare const McpUiSizeChangedNotificationSchema: z.ZodObject<{
|
|
|
86
86
|
}, z.core.$strip>;
|
|
87
87
|
}, z.core.$strip>;
|
|
88
88
|
/**
|
|
89
|
-
* @description Notification containing complete tool arguments (Host ->
|
|
89
|
+
* @description Notification containing complete tool arguments (Host -> View).
|
|
90
90
|
*/
|
|
91
91
|
export declare const McpUiToolInputNotificationSchema: z.ZodObject<{
|
|
92
92
|
method: z.ZodLiteral<"ui/notifications/tool-input">;
|
|
@@ -95,7 +95,7 @@ export declare const McpUiToolInputNotificationSchema: z.ZodObject<{
|
|
|
95
95
|
}, z.core.$strip>;
|
|
96
96
|
}, z.core.$strip>;
|
|
97
97
|
/**
|
|
98
|
-
* @description Notification containing partial/streaming tool arguments (Host ->
|
|
98
|
+
* @description Notification containing partial/streaming tool arguments (Host -> View).
|
|
99
99
|
*/
|
|
100
100
|
export declare const McpUiToolInputPartialNotificationSchema: z.ZodObject<{
|
|
101
101
|
method: z.ZodLiteral<"ui/notifications/tool-input-partial">;
|
|
@@ -104,7 +104,7 @@ export declare const McpUiToolInputPartialNotificationSchema: z.ZodObject<{
|
|
|
104
104
|
}, z.core.$strip>;
|
|
105
105
|
}, z.core.$strip>;
|
|
106
106
|
/**
|
|
107
|
-
* @description Notification that tool execution was cancelled (Host ->
|
|
107
|
+
* @description Notification that tool execution was cancelled (Host -> View).
|
|
108
108
|
* Host MUST send this if tool execution was cancelled for any reason (user action,
|
|
109
109
|
* sampling error, classifier intervention, etc.).
|
|
110
110
|
*/
|
|
@@ -130,8 +130,8 @@ export declare const McpUiHostStylesSchema: z.ZodObject<{
|
|
|
130
130
|
}, z.core.$strip>>;
|
|
131
131
|
}, z.core.$strip>;
|
|
132
132
|
/**
|
|
133
|
-
* @description Request for graceful shutdown of the
|
|
134
|
-
* @see {@link app-bridge!AppBridge.teardownResource} for the host method that sends this
|
|
133
|
+
* @description Request for graceful shutdown of the View (Host -> View).
|
|
134
|
+
* @see {@link app-bridge!AppBridge.teardownResource `AppBridge.teardownResource`} for the host method that sends this
|
|
135
135
|
*/
|
|
136
136
|
export declare const McpUiResourceTeardownRequestSchema: z.ZodObject<{
|
|
137
137
|
method: z.ZodLiteral<"ui/resource-teardown">;
|
|
@@ -139,7 +139,7 @@ export declare const McpUiResourceTeardownRequestSchema: z.ZodObject<{
|
|
|
139
139
|
}, z.core.$strip>;
|
|
140
140
|
/**
|
|
141
141
|
* @description Result from graceful shutdown request.
|
|
142
|
-
* @see {@link McpUiResourceTeardownRequest}
|
|
142
|
+
* @see {@link McpUiResourceTeardownRequest `McpUiResourceTeardownRequest`}
|
|
143
143
|
*/
|
|
144
144
|
export declare const McpUiResourceTeardownResultSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
145
145
|
export declare const McpUiSupportedContentBlockModalitiesSchema: z.ZodObject<{
|
|
@@ -152,7 +152,7 @@ export declare const McpUiSupportedContentBlockModalitiesSchema: z.ZodObject<{
|
|
|
152
152
|
}, z.core.$strip>;
|
|
153
153
|
/**
|
|
154
154
|
* @description Capabilities supported by the host application.
|
|
155
|
-
* @see {@link McpUiInitializeResult} for the initialization result that includes these capabilities
|
|
155
|
+
* @see {@link McpUiInitializeResult `McpUiInitializeResult`} for the initialization result that includes these capabilities
|
|
156
156
|
*/
|
|
157
157
|
export declare const McpUiHostCapabilitiesSchema: z.ZodObject<{
|
|
158
158
|
experimental: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
@@ -196,18 +196,19 @@ export declare const McpUiHostCapabilitiesSchema: z.ZodObject<{
|
|
|
196
196
|
}, z.core.$strip>>;
|
|
197
197
|
}, z.core.$strip>;
|
|
198
198
|
/**
|
|
199
|
-
* @description Capabilities provided by the
|
|
200
|
-
* @see {@link McpUiInitializeRequest} for the initialization request that includes these capabilities
|
|
199
|
+
* @description Capabilities provided by the View ({@link app!App `App`}).
|
|
200
|
+
* @see {@link McpUiInitializeRequest `McpUiInitializeRequest`} for the initialization request that includes these capabilities
|
|
201
201
|
*/
|
|
202
202
|
export declare const McpUiAppCapabilitiesSchema: z.ZodObject<{
|
|
203
203
|
experimental: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
204
204
|
tools: z.ZodOptional<z.ZodObject<{
|
|
205
205
|
listChanged: z.ZodOptional<z.ZodBoolean>;
|
|
206
206
|
}, z.core.$strip>>;
|
|
207
|
+
availableDisplayModes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>>>;
|
|
207
208
|
}, z.core.$strip>;
|
|
208
209
|
/**
|
|
209
|
-
* @description Notification that
|
|
210
|
-
* @see {@link app!App.connect} for the method that sends this notification
|
|
210
|
+
* @description Notification that View has completed initialization (View -> Host).
|
|
211
|
+
* @see {@link app!App.connect `App.connect`} for the method that sends this notification
|
|
211
212
|
*/
|
|
212
213
|
export declare const McpUiInitializedNotificationSchema: z.ZodObject<{
|
|
213
214
|
method: z.ZodLiteral<"ui/notifications/initialized">;
|
|
@@ -236,7 +237,7 @@ export declare const McpUiResourceMetaSchema: z.ZodObject<{
|
|
|
236
237
|
* @description Request to change the display mode of the UI.
|
|
237
238
|
* The host will respond with the actual display mode that was set,
|
|
238
239
|
* which may differ from the requested mode if not supported.
|
|
239
|
-
* @see {@link app!App.requestDisplayMode} for the method that sends this request
|
|
240
|
+
* @see {@link app!App.requestDisplayMode `App.requestDisplayMode`} for the method that sends this request
|
|
240
241
|
*/
|
|
241
242
|
export declare const McpUiRequestDisplayModeRequestSchema: z.ZodObject<{
|
|
242
243
|
method: z.ZodLiteral<"ui/request-display-mode">;
|
|
@@ -246,7 +247,7 @@ export declare const McpUiRequestDisplayModeRequestSchema: z.ZodObject<{
|
|
|
246
247
|
}, z.core.$strip>;
|
|
247
248
|
/**
|
|
248
249
|
* @description Result from requesting a display mode change.
|
|
249
|
-
* @see {@link McpUiRequestDisplayModeRequest}
|
|
250
|
+
* @see {@link McpUiRequestDisplayModeRequest `McpUiRequestDisplayModeRequest`}
|
|
250
251
|
*/
|
|
251
252
|
export declare const McpUiRequestDisplayModeResultSchema: z.ZodObject<{
|
|
252
253
|
mode: z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>;
|
|
@@ -262,9 +263,19 @@ export declare const McpUiToolMetaSchema: z.ZodObject<{
|
|
|
262
263
|
resourceUri: z.ZodOptional<z.ZodString>;
|
|
263
264
|
visibility: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"model">, z.ZodLiteral<"app">]>>>;
|
|
264
265
|
}, z.core.$strip>;
|
|
266
|
+
/**
|
|
267
|
+
* @description MCP Apps capability settings advertised by clients to servers.
|
|
268
|
+
*
|
|
269
|
+
* Clients advertise these capabilities via the `extensions` field in their
|
|
270
|
+
* capabilities during MCP initialization. Servers can check for MCP Apps
|
|
271
|
+
* support using {@link server-helpers!getUiCapability}.
|
|
272
|
+
*/
|
|
273
|
+
export declare const McpUiClientCapabilitiesSchema: z.ZodObject<{
|
|
274
|
+
mimeTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
275
|
+
}, z.core.$strip>;
|
|
265
276
|
/**
|
|
266
277
|
* @description Request to send a message to the host's chat interface.
|
|
267
|
-
* @see {@link app!App.sendMessage} for the method that sends this request
|
|
278
|
+
* @see {@link app!App.sendMessage `App.sendMessage`} for the method that sends this request
|
|
268
279
|
*/
|
|
269
280
|
export declare const McpUiMessageRequestSchema: z.ZodObject<{
|
|
270
281
|
method: z.ZodLiteral<"ui/message">;
|
|
@@ -361,7 +372,7 @@ export declare const McpUiMessageRequestSchema: z.ZodObject<{
|
|
|
361
372
|
/**
|
|
362
373
|
* @description Notification containing HTML resource for the sandbox proxy to load.
|
|
363
374
|
* @internal
|
|
364
|
-
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/
|
|
375
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx#sandbox-proxy
|
|
365
376
|
*/
|
|
366
377
|
export declare const McpUiSandboxResourceReadyNotificationSchema: z.ZodObject<{
|
|
367
378
|
method: z.ZodLiteral<"ui/notifications/sandbox-resource-ready">;
|
|
@@ -383,7 +394,7 @@ export declare const McpUiSandboxResourceReadyNotificationSchema: z.ZodObject<{
|
|
|
383
394
|
}, z.core.$strip>;
|
|
384
395
|
}, z.core.$strip>;
|
|
385
396
|
/**
|
|
386
|
-
* @description Notification containing tool execution result (Host ->
|
|
397
|
+
* @description Notification containing tool execution result (Host -> View).
|
|
387
398
|
*/
|
|
388
399
|
export declare const McpUiToolResultNotificationSchema: z.ZodObject<{
|
|
389
400
|
method: z.ZodLiteral<"ui/notifications/tool-result">;
|
|
@@ -485,7 +496,7 @@ export declare const McpUiToolResultNotificationSchema: z.ZodObject<{
|
|
|
485
496
|
}, z.core.$loose>;
|
|
486
497
|
}, z.core.$strip>;
|
|
487
498
|
/**
|
|
488
|
-
* @description Rich context about the host environment provided to
|
|
499
|
+
* @description Rich context about the host environment provided to views.
|
|
489
500
|
*/
|
|
490
501
|
export declare const McpUiHostContextSchema: z.ZodObject<{
|
|
491
502
|
toolInfo: z.ZodOptional<z.ZodObject<{
|
|
@@ -538,7 +549,7 @@ export declare const McpUiHostContextSchema: z.ZodObject<{
|
|
|
538
549
|
}, z.core.$strip>>;
|
|
539
550
|
}, z.core.$strip>>;
|
|
540
551
|
displayMode: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>>;
|
|
541
|
-
availableDisplayModes: z.ZodOptional<z.ZodArray<z.
|
|
552
|
+
availableDisplayModes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>>>;
|
|
542
553
|
containerDimensions: z.ZodOptional<z.ZodIntersection<z.ZodUnion<readonly [z.ZodObject<{
|
|
543
554
|
height: z.ZodNumber;
|
|
544
555
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -564,8 +575,8 @@ export declare const McpUiHostContextSchema: z.ZodObject<{
|
|
|
564
575
|
}, z.core.$strip>>;
|
|
565
576
|
}, z.core.$loose>;
|
|
566
577
|
/**
|
|
567
|
-
* @description Notification that host context has changed (Host ->
|
|
568
|
-
* @see {@link McpUiHostContext} for the full context structure
|
|
578
|
+
* @description Notification that host context has changed (Host -> View).
|
|
579
|
+
* @see {@link McpUiHostContext `McpUiHostContext`} for the full context structure
|
|
569
580
|
*/
|
|
570
581
|
export declare const McpUiHostContextChangedNotificationSchema: z.ZodObject<{
|
|
571
582
|
method: z.ZodLiteral<"ui/notifications/host-context-changed">;
|
|
@@ -620,7 +631,7 @@ export declare const McpUiHostContextChangedNotificationSchema: z.ZodObject<{
|
|
|
620
631
|
}, z.core.$strip>>;
|
|
621
632
|
}, z.core.$strip>>;
|
|
622
633
|
displayMode: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>>;
|
|
623
|
-
availableDisplayModes: z.ZodOptional<z.ZodArray<z.
|
|
634
|
+
availableDisplayModes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>>>;
|
|
624
635
|
containerDimensions: z.ZodOptional<z.ZodIntersection<z.ZodUnion<readonly [z.ZodObject<{
|
|
625
636
|
height: z.ZodNumber;
|
|
626
637
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -647,16 +658,16 @@ export declare const McpUiHostContextChangedNotificationSchema: z.ZodObject<{
|
|
|
647
658
|
}, z.core.$loose>;
|
|
648
659
|
}, z.core.$strip>;
|
|
649
660
|
/**
|
|
650
|
-
* @description Request to update the agent's context without requiring a follow-up action (
|
|
661
|
+
* @description Request to update the agent's context without requiring a follow-up action (View -> Host).
|
|
651
662
|
*
|
|
652
663
|
* 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
|
|
664
|
+
* to update the Host's model context. Each request overwrites the previous context sent by the View.
|
|
654
665
|
* Unlike messages, context updates do not trigger follow-ups.
|
|
655
666
|
*
|
|
656
667
|
* The host will typically defer sending the context to the model until the next user message
|
|
657
668
|
* (including `ui/message`), and will only send the last update received.
|
|
658
669
|
*
|
|
659
|
-
* @see {@link app.App.updateModelContext} for the method that sends this request
|
|
670
|
+
* @see {@link app.App.updateModelContext `App.updateModelContext`} for the method that sends this request
|
|
660
671
|
*/
|
|
661
672
|
export declare const McpUiUpdateModelContextRequestSchema: z.ZodObject<{
|
|
662
673
|
method: z.ZodLiteral<"ui/update-model-context">;
|
|
@@ -751,8 +762,8 @@ export declare const McpUiUpdateModelContextRequestSchema: z.ZodObject<{
|
|
|
751
762
|
}, z.core.$strip>;
|
|
752
763
|
}, z.core.$strip>;
|
|
753
764
|
/**
|
|
754
|
-
* @description Initialization request sent from
|
|
755
|
-
* @see {@link app!App.connect} for the method that sends this request
|
|
765
|
+
* @description Initialization request sent from View to Host.
|
|
766
|
+
* @see {@link app!App.connect `App.connect`} for the method that sends this request
|
|
756
767
|
*/
|
|
757
768
|
export declare const McpUiInitializeRequestSchema: z.ZodObject<{
|
|
758
769
|
method: z.ZodLiteral<"ui/initialize">;
|
|
@@ -778,13 +789,14 @@ export declare const McpUiInitializeRequestSchema: z.ZodObject<{
|
|
|
778
789
|
tools: z.ZodOptional<z.ZodObject<{
|
|
779
790
|
listChanged: z.ZodOptional<z.ZodBoolean>;
|
|
780
791
|
}, z.core.$strip>>;
|
|
792
|
+
availableDisplayModes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>>>;
|
|
781
793
|
}, z.core.$strip>;
|
|
782
794
|
protocolVersion: z.ZodString;
|
|
783
795
|
}, z.core.$strip>;
|
|
784
796
|
}, z.core.$strip>;
|
|
785
797
|
/**
|
|
786
|
-
* @description Initialization result returned from Host to
|
|
787
|
-
* @see {@link McpUiInitializeRequest}
|
|
798
|
+
* @description Initialization result returned from Host to View.
|
|
799
|
+
* @see {@link McpUiInitializeRequest `McpUiInitializeRequest`}
|
|
788
800
|
*/
|
|
789
801
|
export declare const McpUiInitializeResultSchema: z.ZodObject<{
|
|
790
802
|
protocolVersion: z.ZodString;
|
|
@@ -896,7 +908,7 @@ export declare const McpUiInitializeResultSchema: z.ZodObject<{
|
|
|
896
908
|
}, z.core.$strip>>;
|
|
897
909
|
}, z.core.$strip>>;
|
|
898
910
|
displayMode: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>>;
|
|
899
|
-
availableDisplayModes: z.ZodOptional<z.ZodArray<z.
|
|
911
|
+
availableDisplayModes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"inline">, z.ZodLiteral<"fullscreen">, z.ZodLiteral<"pip">]>>>;
|
|
900
912
|
containerDimensions: z.ZodOptional<z.ZodIntersection<z.ZodUnion<readonly [z.ZodObject<{
|
|
901
913
|
height: z.ZodNumber;
|
|
902
914
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -27,6 +27,7 @@ export type McpUiRequestDisplayModeRequestSchemaInferredType = z.infer<typeof ge
|
|
|
27
27
|
export type McpUiRequestDisplayModeResultSchemaInferredType = z.infer<typeof generated.McpUiRequestDisplayModeResultSchema>;
|
|
28
28
|
export type McpUiToolVisibilitySchemaInferredType = z.infer<typeof generated.McpUiToolVisibilitySchema>;
|
|
29
29
|
export type McpUiToolMetaSchemaInferredType = z.infer<typeof generated.McpUiToolMetaSchema>;
|
|
30
|
+
export type McpUiClientCapabilitiesSchemaInferredType = z.infer<typeof generated.McpUiClientCapabilitiesSchema>;
|
|
30
31
|
export type McpUiMessageRequestSchemaInferredType = z.infer<typeof generated.McpUiMessageRequestSchema>;
|
|
31
32
|
export type McpUiSandboxResourceReadyNotificationSchemaInferredType = z.infer<typeof generated.McpUiSandboxResourceReadyNotificationSchema>;
|
|
32
33
|
export type McpUiToolResultNotificationSchemaInferredType = z.infer<typeof generated.McpUiToolResultNotificationSchema>;
|
|
@@ -10,29 +10,29 @@ import { Transport, TransportSendOptions } from "@modelcontextprotocol/sdk/share
|
|
|
10
10
|
* ## Security
|
|
11
11
|
*
|
|
12
12
|
* The `eventSource` parameter is required and validates the message source window
|
|
13
|
-
* by checking `event.source`. For
|
|
13
|
+
* by checking `event.source`. For views, pass `window.parent`.
|
|
14
14
|
* For hosts, pass `iframe.contentWindow` to validate the iframe source.
|
|
15
15
|
*
|
|
16
16
|
* ## Usage
|
|
17
17
|
*
|
|
18
|
-
* **
|
|
19
|
-
* ```
|
|
18
|
+
* **View**:
|
|
19
|
+
* ```ts source="./message-transport.examples.ts#PostMessageTransport_view"
|
|
20
20
|
* const transport = new PostMessageTransport(window.parent, window.parent);
|
|
21
21
|
* await app.connect(transport);
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
24
24
|
* **Host**:
|
|
25
|
-
* ```
|
|
26
|
-
* const iframe = document.getElementById(
|
|
25
|
+
* ```ts source="./message-transport.examples.ts#PostMessageTransport_host"
|
|
26
|
+
* const iframe = document.getElementById("app-iframe") as HTMLIFrameElement;
|
|
27
27
|
* const transport = new PostMessageTransport(
|
|
28
28
|
* iframe.contentWindow!,
|
|
29
|
-
* iframe.contentWindow
|
|
29
|
+
* iframe.contentWindow!,
|
|
30
30
|
* );
|
|
31
31
|
* await bridge.connect(transport);
|
|
32
32
|
* ```
|
|
33
33
|
*
|
|
34
|
-
* @see {@link app!App.connect} for
|
|
35
|
-
* @see {@link app-bridge!AppBridge.connect} for Host usage
|
|
34
|
+
* @see {@link app!App.connect `App.connect`} for View usage
|
|
35
|
+
* @see {@link app-bridge!AppBridge.connect `AppBridge.connect`} for Host usage
|
|
36
36
|
*/
|
|
37
37
|
export declare class PostMessageTransport implements Transport {
|
|
38
38
|
private eventTarget;
|
|
@@ -42,20 +42,20 @@ export declare class PostMessageTransport implements Transport {
|
|
|
42
42
|
* Create a new PostMessageTransport.
|
|
43
43
|
*
|
|
44
44
|
* @param eventTarget - Target window to send messages to (default: `window.parent`)
|
|
45
|
-
* @param eventSource - Source window for message validation. For
|
|
45
|
+
* @param eventSource - Source window for message validation. For views, pass
|
|
46
46
|
* `window.parent`. For hosts, pass `iframe.contentWindow`.
|
|
47
47
|
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```
|
|
48
|
+
* @example View connecting to parent
|
|
49
|
+
* ```ts source="./message-transport.examples.ts#PostMessageTransport_constructor_view"
|
|
50
50
|
* const transport = new PostMessageTransport(window.parent, window.parent);
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
53
53
|
* @example Host connecting to iframe
|
|
54
|
-
* ```
|
|
55
|
-
* const iframe = document.getElementById(
|
|
54
|
+
* ```ts source="./message-transport.examples.ts#PostMessageTransport_constructor_host"
|
|
55
|
+
* const iframe = document.getElementById("app-iframe") as HTMLIFrameElement;
|
|
56
56
|
* const transport = new PostMessageTransport(
|
|
57
57
|
* iframe.contentWindow!,
|
|
58
|
-
* iframe.contentWindow
|
|
58
|
+
* iframe.contentWindow!,
|
|
59
59
|
* );
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
@@ -80,13 +80,13 @@ export declare class PostMessageTransport implements Transport {
|
|
|
80
80
|
/**
|
|
81
81
|
* Stop listening for messages and cleanup.
|
|
82
82
|
*
|
|
83
|
-
* Removes the message event listener and calls the {@link onclose} callback if set.
|
|
83
|
+
* Removes the message event listener and calls the {@link onclose `onclose`} callback if set.
|
|
84
84
|
*/
|
|
85
85
|
close(): Promise<void>;
|
|
86
86
|
/**
|
|
87
87
|
* Called when the transport is closed.
|
|
88
88
|
*
|
|
89
|
-
* Set this handler to be notified when {@link close} is called.
|
|
89
|
+
* Set this handler to be notified when {@link close `close`} is called.
|
|
90
90
|
*/
|
|
91
91
|
onclose?: () => void;
|
|
92
92
|
/**
|
|
@@ -101,7 +101,7 @@ export declare class PostMessageTransport implements Transport {
|
|
|
101
101
|
/**
|
|
102
102
|
* Called when a valid JSON-RPC message is received.
|
|
103
103
|
*
|
|
104
|
-
* This handler is invoked after message validation succeeds. The {@link start}
|
|
104
|
+
* This handler is invoked after message validation succeeds. The {@link start `start`}
|
|
105
105
|
* method must be called before messages will be received.
|
|
106
106
|
*
|
|
107
107
|
* @param message - The validated JSON-RPC message
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-checked examples for {@link PostMessageTransport `PostMessageTransport`}.
|
|
3
|
+
*
|
|
4
|
+
* These examples are included in the API documentation via `@includeCode` tags.
|
|
5
|
+
* Each function's region markers define the code snippet that appears in the docs.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -3,27 +3,25 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This module provides React hooks and utilities for easily building
|
|
5
5
|
* interactive MCP Apps using React. This is optional - the core SDK
|
|
6
|
-
* ({@link App}, {@link PostMessageTransport}) is framework-agnostic and can be
|
|
6
|
+
* ({@link App `App`}, {@link PostMessageTransport `PostMessageTransport`}) is framework-agnostic and can be
|
|
7
7
|
* used with any UI framework or vanilla JavaScript.
|
|
8
8
|
*
|
|
9
9
|
* ## Main Exports
|
|
10
10
|
*
|
|
11
|
-
* - {@link useApp} - React hook to create and connect an MCP App
|
|
12
|
-
* - {@link useHostStyleVariables} - React hook to apply host style variables and theme
|
|
13
|
-
* - {@link useHostFonts} - React hook to apply host fonts
|
|
14
|
-
* - {@link useDocumentTheme} - React hook for reactive document theme
|
|
15
|
-
* - {@link useAutoResize} - React hook for manual auto-resize control (rarely needed)
|
|
11
|
+
* - {@link useApp `useApp`} - React hook to create and connect an MCP App
|
|
12
|
+
* - {@link useHostStyleVariables `useHostStyleVariables`} - React hook to apply host style variables and theme
|
|
13
|
+
* - {@link useHostFonts `useHostFonts`} - React hook to apply host fonts
|
|
14
|
+
* - {@link useDocumentTheme `useDocumentTheme`} - React hook for reactive document theme
|
|
15
|
+
* - {@link useAutoResize `useAutoResize`} - React hook for manual auto-resize control (rarely needed)
|
|
16
16
|
*
|
|
17
17
|
* @module @modelcontextprotocol/ext-apps/react
|
|
18
18
|
*
|
|
19
19
|
* @example Basic React App
|
|
20
|
-
* ```tsx
|
|
21
|
-
* import { useApp } from '@modelcontextprotocol/ext-apps/react';
|
|
22
|
-
*
|
|
20
|
+
* ```tsx source="./index.examples.tsx#index_basicReactApp"
|
|
23
21
|
* function MyApp() {
|
|
24
22
|
* const { app, isConnected, error } = useApp({
|
|
25
23
|
* appInfo: { name: "MyApp", version: "1.0.0" },
|
|
26
|
-
* capabilities: {}
|
|
24
|
+
* capabilities: {},
|
|
27
25
|
* });
|
|
28
26
|
*
|
|
29
27
|
* if (error) return <div>Error: {error.message}</div>;
|