@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
package/dist/src/spec.types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - Use `@description` JSDoc tags to generate `.describe()` calls on schemas
|
|
8
8
|
* - Run `npm run generate:schemas` to regenerate schemas from these types
|
|
9
9
|
*
|
|
10
|
-
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/
|
|
10
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx
|
|
11
11
|
*/
|
|
12
12
|
import type { CallToolResult, ContentBlock, Implementation, RequestId, Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
13
13
|
/**
|
|
@@ -16,7 +16,7 @@ import type { CallToolResult, ContentBlock, Implementation, RequestId, Tool } fr
|
|
|
16
16
|
* The SDK automatically handles version negotiation during initialization.
|
|
17
17
|
* Apps and hosts don't need to manage protocol versions manually.
|
|
18
18
|
*/
|
|
19
|
-
export declare const LATEST_PROTOCOL_VERSION = "
|
|
19
|
+
export declare const LATEST_PROTOCOL_VERSION = "2026-01-26";
|
|
20
20
|
/**
|
|
21
21
|
* @description Color theme preference for the host environment.
|
|
22
22
|
*/
|
|
@@ -41,7 +41,7 @@ export type McpUiStyleVariableKey = "--color-background-primary" | "--color-back
|
|
|
41
41
|
export type McpUiStyles = Record<McpUiStyleVariableKey, string | undefined>;
|
|
42
42
|
/**
|
|
43
43
|
* @description Request to open an external URL in the host's default browser.
|
|
44
|
-
* @see {@link app!App.openLink} for the method that sends this request
|
|
44
|
+
* @see {@link app!App.openLink `App.openLink`} for the method that sends this request
|
|
45
45
|
*/
|
|
46
46
|
export interface McpUiOpenLinkRequest {
|
|
47
47
|
method: "ui/open-link";
|
|
@@ -52,7 +52,7 @@ export interface McpUiOpenLinkRequest {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* @description Result from opening a URL.
|
|
55
|
-
* @see {@link McpUiOpenLinkRequest}
|
|
55
|
+
* @see {@link McpUiOpenLinkRequest `McpUiOpenLinkRequest`}
|
|
56
56
|
*/
|
|
57
57
|
export interface McpUiOpenLinkResult {
|
|
58
58
|
/** @description True if the host failed to open the URL (e.g., due to security policy). */
|
|
@@ -65,7 +65,7 @@ export interface McpUiOpenLinkResult {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* @description Request to send a message to the host's chat interface.
|
|
68
|
-
* @see {@link app!App.sendMessage} for the method that sends this request
|
|
68
|
+
* @see {@link app!App.sendMessage `App.sendMessage`} for the method that sends this request
|
|
69
69
|
*/
|
|
70
70
|
export interface McpUiMessageRequest {
|
|
71
71
|
method: "ui/message";
|
|
@@ -78,7 +78,7 @@ export interface McpUiMessageRequest {
|
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* @description Result from sending a message.
|
|
81
|
-
* @see {@link McpUiMessageRequest}
|
|
81
|
+
* @see {@link McpUiMessageRequest `McpUiMessageRequest`}
|
|
82
82
|
*/
|
|
83
83
|
export interface McpUiMessageResult {
|
|
84
84
|
/** @description True if the host rejected or failed to deliver the message. */
|
|
@@ -92,7 +92,7 @@ export interface McpUiMessageResult {
|
|
|
92
92
|
/**
|
|
93
93
|
* @description Notification that the sandbox proxy iframe is ready to receive content.
|
|
94
94
|
* @internal
|
|
95
|
-
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/
|
|
95
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx#sandbox-proxy
|
|
96
96
|
*/
|
|
97
97
|
export interface McpUiSandboxProxyReadyNotification {
|
|
98
98
|
method: "ui/notifications/sandbox-proxy-ready";
|
|
@@ -101,7 +101,7 @@ export interface McpUiSandboxProxyReadyNotification {
|
|
|
101
101
|
/**
|
|
102
102
|
* @description Notification containing HTML resource for the sandbox proxy to load.
|
|
103
103
|
* @internal
|
|
104
|
-
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/
|
|
104
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx#sandbox-proxy
|
|
105
105
|
*/
|
|
106
106
|
export interface McpUiSandboxResourceReadyNotification {
|
|
107
107
|
method: "ui/notifications/sandbox-resource-ready";
|
|
@@ -117,8 +117,8 @@ export interface McpUiSandboxResourceReadyNotification {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
|
-
* @description Notification of UI size changes (
|
|
121
|
-
* @see {@link app!App.sendSizeChanged} for the method to send this from
|
|
120
|
+
* @description Notification of UI size changes (View -> Host).
|
|
121
|
+
* @see {@link app!App.sendSizeChanged `App.sendSizeChanged`} for the method to send this from View
|
|
122
122
|
*/
|
|
123
123
|
export interface McpUiSizeChangedNotification {
|
|
124
124
|
method: "ui/notifications/size-changed";
|
|
@@ -130,7 +130,7 @@ export interface McpUiSizeChangedNotification {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
|
-
* @description Notification containing complete tool arguments (Host ->
|
|
133
|
+
* @description Notification containing complete tool arguments (Host -> View).
|
|
134
134
|
*/
|
|
135
135
|
export interface McpUiToolInputNotification {
|
|
136
136
|
method: "ui/notifications/tool-input";
|
|
@@ -140,7 +140,7 @@ export interface McpUiToolInputNotification {
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
* @description Notification containing partial/streaming tool arguments (Host ->
|
|
143
|
+
* @description Notification containing partial/streaming tool arguments (Host -> View).
|
|
144
144
|
*/
|
|
145
145
|
export interface McpUiToolInputPartialNotification {
|
|
146
146
|
method: "ui/notifications/tool-input-partial";
|
|
@@ -150,7 +150,7 @@ export interface McpUiToolInputPartialNotification {
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
|
-
* @description Notification containing tool execution result (Host ->
|
|
153
|
+
* @description Notification containing tool execution result (Host -> View).
|
|
154
154
|
*/
|
|
155
155
|
export interface McpUiToolResultNotification {
|
|
156
156
|
method: "ui/notifications/tool-result";
|
|
@@ -158,7 +158,7 @@ export interface McpUiToolResultNotification {
|
|
|
158
158
|
params: CallToolResult;
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
|
-
* @description Notification that tool execution was cancelled (Host ->
|
|
161
|
+
* @description Notification that tool execution was cancelled (Host -> View).
|
|
162
162
|
* Host MUST send this if tool execution was cancelled for any reason (user action,
|
|
163
163
|
* sampling error, classifier intervention, etc.).
|
|
164
164
|
*/
|
|
@@ -173,7 +173,7 @@ export interface McpUiToolCancelledNotification {
|
|
|
173
173
|
* @description CSS blocks that can be injected by apps.
|
|
174
174
|
*/
|
|
175
175
|
export interface McpUiHostCss {
|
|
176
|
-
/** @description CSS for font loading (`@font-face` rules or `@import` statements). Apps must apply using {@link applyHostFonts}. */
|
|
176
|
+
/** @description CSS for font loading (`@font-face` rules or `@import` statements). Apps must apply using {@link applyHostFonts `applyHostFonts`}. */
|
|
177
177
|
fonts?: string;
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
@@ -186,7 +186,7 @@ export interface McpUiHostStyles {
|
|
|
186
186
|
css?: McpUiHostCss;
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
|
-
* @description Rich context about the host environment provided to
|
|
189
|
+
* @description Rich context about the host environment provided to views.
|
|
190
190
|
*/
|
|
191
191
|
export interface McpUiHostContext {
|
|
192
192
|
/** @description Allow additional properties for forward compatibility. */
|
|
@@ -205,7 +205,7 @@ export interface McpUiHostContext {
|
|
|
205
205
|
/** @description How the UI is currently displayed. */
|
|
206
206
|
displayMode?: McpUiDisplayMode;
|
|
207
207
|
/** @description Display modes the host supports. */
|
|
208
|
-
availableDisplayModes?:
|
|
208
|
+
availableDisplayModes?: McpUiDisplayMode[];
|
|
209
209
|
/**
|
|
210
210
|
* @description Container dimensions. Represents the dimensions of the iframe or other
|
|
211
211
|
* container holding the app. Specify either width or maxWidth, and either height or maxHeight.
|
|
@@ -251,8 +251,8 @@ export interface McpUiHostContext {
|
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
|
-
* @description Notification that host context has changed (Host ->
|
|
255
|
-
* @see {@link McpUiHostContext} for the full context structure
|
|
254
|
+
* @description Notification that host context has changed (Host -> View).
|
|
255
|
+
* @see {@link McpUiHostContext `McpUiHostContext`} for the full context structure
|
|
256
256
|
*/
|
|
257
257
|
export interface McpUiHostContextChangedNotification {
|
|
258
258
|
method: "ui/notifications/host-context-changed";
|
|
@@ -260,16 +260,16 @@ export interface McpUiHostContextChangedNotification {
|
|
|
260
260
|
params: McpUiHostContext;
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
263
|
-
* @description Request to update the agent's context without requiring a follow-up action (
|
|
263
|
+
* @description Request to update the agent's context without requiring a follow-up action (View -> Host).
|
|
264
264
|
*
|
|
265
265
|
* Unlike `notifications/message` which is for debugging/logging, this request is intended
|
|
266
|
-
* to update the Host's model context. Each request overwrites the previous context sent by the
|
|
266
|
+
* to update the Host's model context. Each request overwrites the previous context sent by the View.
|
|
267
267
|
* Unlike messages, context updates do not trigger follow-ups.
|
|
268
268
|
*
|
|
269
269
|
* The host will typically defer sending the context to the model until the next user message
|
|
270
270
|
* (including `ui/message`), and will only send the last update received.
|
|
271
271
|
*
|
|
272
|
-
* @see {@link app.App.updateModelContext} for the method that sends this request
|
|
272
|
+
* @see {@link app.App.updateModelContext `App.updateModelContext`} for the method that sends this request
|
|
273
273
|
*/
|
|
274
274
|
export interface McpUiUpdateModelContextRequest {
|
|
275
275
|
method: "ui/update-model-context";
|
|
@@ -281,8 +281,8 @@ export interface McpUiUpdateModelContextRequest {
|
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
|
-
* @description Request for graceful shutdown of the
|
|
285
|
-
* @see {@link app-bridge!AppBridge.teardownResource} for the host method that sends this
|
|
284
|
+
* @description Request for graceful shutdown of the View (Host -> View).
|
|
285
|
+
* @see {@link app-bridge!AppBridge.teardownResource `AppBridge.teardownResource`} for the host method that sends this
|
|
286
286
|
*/
|
|
287
287
|
export interface McpUiResourceTeardownRequest {
|
|
288
288
|
method: "ui/resource-teardown";
|
|
@@ -290,7 +290,7 @@ export interface McpUiResourceTeardownRequest {
|
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
292
292
|
* @description Result from graceful shutdown request.
|
|
293
|
-
* @see {@link McpUiResourceTeardownRequest}
|
|
293
|
+
* @see {@link McpUiResourceTeardownRequest `McpUiResourceTeardownRequest`}
|
|
294
294
|
*/
|
|
295
295
|
export interface McpUiResourceTeardownResult {
|
|
296
296
|
/**
|
|
@@ -314,7 +314,7 @@ export interface McpUiSupportedContentBlockModalities {
|
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
316
316
|
* @description Capabilities supported by the host application.
|
|
317
|
-
* @see {@link McpUiInitializeResult} for the initialization result that includes these capabilities
|
|
317
|
+
* @see {@link McpUiInitializeResult `McpUiInitializeResult`} for the initialization result that includes these capabilities
|
|
318
318
|
*/
|
|
319
319
|
export interface McpUiHostCapabilities {
|
|
320
320
|
/** @description Experimental features (structure TBD). */
|
|
@@ -342,12 +342,12 @@ export interface McpUiHostCapabilities {
|
|
|
342
342
|
};
|
|
343
343
|
/** @description Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns. */
|
|
344
344
|
updateModelContext?: McpUiSupportedContentBlockModalities;
|
|
345
|
-
/** @description Host supports receiving content messages (ui/message) from the
|
|
345
|
+
/** @description Host supports receiving content messages (ui/message) from the view. */
|
|
346
346
|
message?: McpUiSupportedContentBlockModalities;
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
349
|
-
* @description Capabilities provided by the
|
|
350
|
-
* @see {@link McpUiInitializeRequest} for the initialization request that includes these capabilities
|
|
349
|
+
* @description Capabilities provided by the View ({@link app!App `App`}).
|
|
350
|
+
* @see {@link McpUiInitializeRequest `McpUiInitializeRequest`} for the initialization request that includes these capabilities
|
|
351
351
|
*/
|
|
352
352
|
export interface McpUiAppCapabilities {
|
|
353
353
|
/** @description Experimental features (structure TBD). */
|
|
@@ -357,10 +357,12 @@ export interface McpUiAppCapabilities {
|
|
|
357
357
|
/** @description App supports tools/list_changed notifications. */
|
|
358
358
|
listChanged?: boolean;
|
|
359
359
|
};
|
|
360
|
+
/** @description Display modes the app supports. */
|
|
361
|
+
availableDisplayModes?: McpUiDisplayMode[];
|
|
360
362
|
}
|
|
361
363
|
/**
|
|
362
|
-
* @description Initialization request sent from
|
|
363
|
-
* @see {@link app!App.connect} for the method that sends this request
|
|
364
|
+
* @description Initialization request sent from View to Host.
|
|
365
|
+
* @see {@link app!App.connect `App.connect`} for the method that sends this request
|
|
364
366
|
*/
|
|
365
367
|
export interface McpUiInitializeRequest {
|
|
366
368
|
method: "ui/initialize";
|
|
@@ -374,8 +376,8 @@ export interface McpUiInitializeRequest {
|
|
|
374
376
|
};
|
|
375
377
|
}
|
|
376
378
|
/**
|
|
377
|
-
* @description Initialization result returned from Host to
|
|
378
|
-
* @see {@link McpUiInitializeRequest}
|
|
379
|
+
* @description Initialization result returned from Host to View.
|
|
380
|
+
* @see {@link McpUiInitializeRequest `McpUiInitializeRequest`}
|
|
379
381
|
*/
|
|
380
382
|
export interface McpUiInitializeResult {
|
|
381
383
|
/** @description Negotiated protocol version string (e.g., "2025-11-21"). */
|
|
@@ -393,8 +395,8 @@ export interface McpUiInitializeResult {
|
|
|
393
395
|
[key: string]: unknown;
|
|
394
396
|
}
|
|
395
397
|
/**
|
|
396
|
-
* @description Notification that
|
|
397
|
-
* @see {@link app!App.connect} for the method that sends this notification
|
|
398
|
+
* @description Notification that View has completed initialization (View -> Host).
|
|
399
|
+
* @see {@link app!App.connect `App.connect`} for the method that sends this notification
|
|
398
400
|
*/
|
|
399
401
|
export interface McpUiInitializedNotification {
|
|
400
402
|
method: "ui/notifications/initialized";
|
|
@@ -436,7 +438,7 @@ export interface McpUiResourceMeta {
|
|
|
436
438
|
csp?: McpUiResourceCsp;
|
|
437
439
|
/** @description Sandbox permissions requested by the UI. */
|
|
438
440
|
permissions?: McpUiResourcePermissions;
|
|
439
|
-
/** @description Dedicated origin for
|
|
441
|
+
/** @description Dedicated origin for view sandbox. */
|
|
440
442
|
domain?: string;
|
|
441
443
|
/** @description Visual boundary preference - true if UI prefers a visible border. */
|
|
442
444
|
prefersBorder?: boolean;
|
|
@@ -445,7 +447,7 @@ export interface McpUiResourceMeta {
|
|
|
445
447
|
* @description Request to change the display mode of the UI.
|
|
446
448
|
* The host will respond with the actual display mode that was set,
|
|
447
449
|
* which may differ from the requested mode if not supported.
|
|
448
|
-
* @see {@link app!App.requestDisplayMode} for the method that sends this request
|
|
450
|
+
* @see {@link app!App.requestDisplayMode `App.requestDisplayMode`} for the method that sends this request
|
|
449
451
|
*/
|
|
450
452
|
export interface McpUiRequestDisplayModeRequest {
|
|
451
453
|
method: "ui/request-display-mode";
|
|
@@ -456,7 +458,7 @@ export interface McpUiRequestDisplayModeRequest {
|
|
|
456
458
|
}
|
|
457
459
|
/**
|
|
458
460
|
* @description Result from requesting a display mode change.
|
|
459
|
-
* @see {@link McpUiRequestDisplayModeRequest}
|
|
461
|
+
* @see {@link McpUiRequestDisplayModeRequest `McpUiRequestDisplayModeRequest`}
|
|
460
462
|
*/
|
|
461
463
|
export interface McpUiRequestDisplayModeResult {
|
|
462
464
|
/** @description The display mode that was actually set. May differ from requested if not supported. */
|
|
@@ -479,7 +481,7 @@ export interface McpUiToolMeta {
|
|
|
479
481
|
* URI of the UI resource to display for this tool, if any.
|
|
480
482
|
* This is converted to `_meta["ui/resourceUri"]`.
|
|
481
483
|
*
|
|
482
|
-
* @example "ui://weather/
|
|
484
|
+
* @example "ui://weather/view.html"
|
|
483
485
|
*/
|
|
484
486
|
resourceUri?: string;
|
|
485
487
|
/**
|
|
@@ -519,3 +521,17 @@ export declare const RESOURCE_TEARDOWN_METHOD: McpUiResourceTeardownRequest["met
|
|
|
519
521
|
export declare const INITIALIZE_METHOD: McpUiInitializeRequest["method"];
|
|
520
522
|
export declare const INITIALIZED_METHOD: McpUiInitializedNotification["method"];
|
|
521
523
|
export declare const REQUEST_DISPLAY_MODE_METHOD: McpUiRequestDisplayModeRequest["method"];
|
|
524
|
+
/**
|
|
525
|
+
* @description MCP Apps capability settings advertised by clients to servers.
|
|
526
|
+
*
|
|
527
|
+
* Clients advertise these capabilities via the `extensions` field in their
|
|
528
|
+
* capabilities during MCP initialization. Servers can check for MCP Apps
|
|
529
|
+
* support using {@link server-helpers!getUiCapability}.
|
|
530
|
+
*/
|
|
531
|
+
export interface McpUiClientCapabilities {
|
|
532
|
+
/**
|
|
533
|
+
* @description Array of supported MIME types for UI resources.
|
|
534
|
+
* Must include `"text/html;profile=mcp-app"` for MCP Apps support.
|
|
535
|
+
*/
|
|
536
|
+
mimeTypes?: string[];
|
|
537
|
+
}
|
package/dist/src/styles.d.ts
CHANGED
|
@@ -9,15 +9,13 @@ import { McpUiStyles, McpUiTheme } from "./types";
|
|
|
9
9
|
* @returns The current theme ("light" or "dark")
|
|
10
10
|
*
|
|
11
11
|
* @example Check current theme
|
|
12
|
-
* ```
|
|
13
|
-
* import { getDocumentTheme } from '@modelcontextprotocol/ext-apps';
|
|
14
|
-
*
|
|
12
|
+
* ```ts source="./styles.examples.ts#getDocumentTheme_checkCurrent"
|
|
15
13
|
* const theme = getDocumentTheme();
|
|
16
|
-
*
|
|
14
|
+
* document.body.classList.toggle("dark", theme === "dark");
|
|
17
15
|
* ```
|
|
18
16
|
*
|
|
19
|
-
* @see {@link applyDocumentTheme} to set the theme
|
|
20
|
-
* @see {@link McpUiTheme} for the theme type
|
|
17
|
+
* @see {@link applyDocumentTheme `applyDocumentTheme`} to set the theme
|
|
18
|
+
* @see {@link McpUiTheme `McpUiTheme`} for the theme type
|
|
21
19
|
*/
|
|
22
20
|
export declare function getDocumentTheme(): McpUiTheme;
|
|
23
21
|
/**
|
|
@@ -31,14 +29,21 @@ export declare function getDocumentTheme(): McpUiTheme;
|
|
|
31
29
|
* @param theme - The theme to apply ("light" or "dark")
|
|
32
30
|
*
|
|
33
31
|
* @example Apply theme from host context
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
*
|
|
32
|
+
* ```ts source="./styles.examples.ts#applyDocumentTheme_fromHostContext"
|
|
33
|
+
* // Apply when host context changes
|
|
37
34
|
* app.onhostcontextchanged = (params) => {
|
|
38
35
|
* if (params.theme) {
|
|
39
36
|
* applyDocumentTheme(params.theme);
|
|
40
37
|
* }
|
|
41
38
|
* };
|
|
39
|
+
*
|
|
40
|
+
* // Apply initial theme after connecting
|
|
41
|
+
* app.connect().then(() => {
|
|
42
|
+
* const ctx = app.getHostContext();
|
|
43
|
+
* if (ctx?.theme) {
|
|
44
|
+
* applyDocumentTheme(ctx.theme);
|
|
45
|
+
* }
|
|
46
|
+
* });
|
|
42
47
|
* ```
|
|
43
48
|
*
|
|
44
49
|
* @example Use with CSS selectors
|
|
@@ -51,14 +56,14 @@ export declare function getDocumentTheme(): McpUiTheme;
|
|
|
51
56
|
* }
|
|
52
57
|
* ```
|
|
53
58
|
*
|
|
54
|
-
* @see {@link getDocumentTheme} to read the current theme
|
|
55
|
-
* @see {@link McpUiTheme} for the theme type
|
|
59
|
+
* @see {@link getDocumentTheme `getDocumentTheme`} to read the current theme
|
|
60
|
+
* @see {@link McpUiTheme `McpUiTheme`} for the theme type
|
|
56
61
|
*/
|
|
57
62
|
export declare function applyDocumentTheme(theme: McpUiTheme): void;
|
|
58
63
|
/**
|
|
59
64
|
* Apply host style variables as CSS custom properties on an element.
|
|
60
65
|
*
|
|
61
|
-
* This function takes the `variables` object from {@link McpUiHostContext.styles} and sets
|
|
66
|
+
* This function takes the `variables` object from {@link McpUiHostContext.styles `McpUiHostContext.styles`} and sets
|
|
62
67
|
* each CSS variable on the specified root element (defaults to `document.documentElement`).
|
|
63
68
|
* This allows apps to use the host's theming values via CSS variables like
|
|
64
69
|
* `var(--color-background-primary)`.
|
|
@@ -67,24 +72,51 @@ export declare function applyDocumentTheme(theme: McpUiTheme): void;
|
|
|
67
72
|
* @param root - The element to apply styles to (defaults to `document.documentElement`)
|
|
68
73
|
*
|
|
69
74
|
* @example Apply style variables from host context
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
75
|
+
* ```ts source="./styles.examples.ts#applyHostStyleVariables_fromHostContext"
|
|
76
|
+
* // Use CSS variables in your styles
|
|
77
|
+
* document.body.style.background = "var(--color-background-primary)";
|
|
72
78
|
*
|
|
79
|
+
* // Apply when host context changes
|
|
73
80
|
* app.onhostcontextchanged = (params) => {
|
|
74
81
|
* if (params.styles?.variables) {
|
|
75
82
|
* applyHostStyleVariables(params.styles.variables);
|
|
76
83
|
* }
|
|
77
84
|
* };
|
|
85
|
+
*
|
|
86
|
+
* // Apply initial styles after connecting
|
|
87
|
+
* app.connect().then(() => {
|
|
88
|
+
* const ctx = app.getHostContext();
|
|
89
|
+
* if (ctx?.styles?.variables) {
|
|
90
|
+
* applyHostStyleVariables(ctx.styles.variables);
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
78
93
|
* ```
|
|
79
94
|
*
|
|
80
95
|
* @example Apply to a specific element
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
*
|
|
96
|
+
* ```ts source="./styles.examples.ts#applyHostStyleVariables_toElement"
|
|
97
|
+
* app.onhostcontextchanged = (params) => {
|
|
98
|
+
* const container = document.getElementById("app-root");
|
|
99
|
+
* if (container && params.styles?.variables) {
|
|
100
|
+
* applyHostStyleVariables(params.styles.variables, container);
|
|
101
|
+
* }
|
|
102
|
+
* };
|
|
84
103
|
* ```
|
|
85
104
|
*
|
|
86
|
-
* @
|
|
87
|
-
*
|
|
105
|
+
* @example Use host style variables in CSS
|
|
106
|
+
* ```css
|
|
107
|
+
* body {
|
|
108
|
+
* background-color: var(--color-background-primary);
|
|
109
|
+
* color: var(--color-text-primary);
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* .card {
|
|
113
|
+
* background-color: var(--color-background-secondary);
|
|
114
|
+
* border: 1px solid var(--color-border-primary);
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @see {@link McpUiStyles `McpUiStyles`} for the available CSS variables
|
|
119
|
+
* @see {@link McpUiHostContext `McpUiHostContext`} for the full host context structure
|
|
88
120
|
*/
|
|
89
121
|
export declare function applyHostStyleVariables(styles: McpUiStyles, root?: HTMLElement): void;
|
|
90
122
|
/**
|
|
@@ -101,41 +133,52 @@ export declare function applyHostStyleVariables(styles: McpUiStyles, root?: HTML
|
|
|
101
133
|
* @param fontCss - CSS string containing `@font-face` rules and/or `@import` statements
|
|
102
134
|
*
|
|
103
135
|
* @example Apply fonts from host context
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
|
-
*
|
|
136
|
+
* ```ts source="./styles.examples.ts#applyHostFonts_fromHostContext"
|
|
137
|
+
* // Apply when host context changes
|
|
107
138
|
* app.onhostcontextchanged = (params) => {
|
|
108
139
|
* if (params.styles?.css?.fonts) {
|
|
109
140
|
* applyHostFonts(params.styles.css.fonts);
|
|
110
141
|
* }
|
|
111
142
|
* };
|
|
143
|
+
*
|
|
144
|
+
* // Apply initial fonts after connecting
|
|
145
|
+
* app.connect().then(() => {
|
|
146
|
+
* const ctx = app.getHostContext();
|
|
147
|
+
* if (ctx?.styles?.css?.fonts) {
|
|
148
|
+
* applyHostFonts(ctx.styles.css.fonts);
|
|
149
|
+
* }
|
|
150
|
+
* });
|
|
112
151
|
* ```
|
|
113
152
|
*
|
|
114
153
|
* @example Host providing self-hosted fonts
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
154
|
+
* ```ts source="./styles.examples.ts#applyHostFonts_selfHosted"
|
|
155
|
+
* // Example of what a host might provide:
|
|
156
|
+
* const fontCss = `
|
|
117
157
|
* @font-face {
|
|
118
158
|
* font-family: "Anthropic Sans";
|
|
119
159
|
* src: url("https://assets.anthropic.com/.../Regular.otf") format("opentype");
|
|
120
160
|
* font-weight: 400;
|
|
121
161
|
* }
|
|
122
162
|
* `;
|
|
163
|
+
* applyHostFonts(fontCss);
|
|
123
164
|
* ```
|
|
124
165
|
*
|
|
125
166
|
* @example Host providing Google Fonts
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
167
|
+
* ```ts source="./styles.examples.ts#applyHostFonts_googleFonts"
|
|
168
|
+
* // Example of what a host might provide:
|
|
169
|
+
* const fontCss = `
|
|
128
170
|
* @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
|
|
129
171
|
* `;
|
|
172
|
+
* applyHostFonts(fontCss);
|
|
130
173
|
* ```
|
|
131
174
|
*
|
|
132
175
|
* @example Use host fonts in CSS
|
|
133
176
|
* ```css
|
|
134
177
|
* body {
|
|
135
|
-
* font-family:
|
|
178
|
+
* font-family: var(--font-sans, system-ui, sans-serif);
|
|
136
179
|
* }
|
|
137
180
|
* ```
|
|
138
181
|
*
|
|
139
|
-
* @see {@link McpUiHostContext} for the full host context structure
|
|
182
|
+
* @see {@link McpUiHostContext `McpUiHostContext`} for the full host context structure
|
|
140
183
|
*/
|
|
141
184
|
export declare function applyHostFonts(fontCss: string): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-checked examples for style utilities in {@link ./styles.ts `styles.ts`}.
|
|
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 {};
|
package/dist/src/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @see `generated/schema.ts` for auto-generated Zod schemas
|
|
9
9
|
* @see `generated/schema.test.ts` for compile-time verification
|
|
10
10
|
*/
|
|
11
|
-
export { LATEST_PROTOCOL_VERSION, OPEN_LINK_METHOD, MESSAGE_METHOD, SANDBOX_PROXY_READY_METHOD, SANDBOX_RESOURCE_READY_METHOD, SIZE_CHANGED_METHOD, TOOL_INPUT_METHOD, TOOL_INPUT_PARTIAL_METHOD, TOOL_RESULT_METHOD, TOOL_CANCELLED_METHOD, HOST_CONTEXT_CHANGED_METHOD, RESOURCE_TEARDOWN_METHOD, INITIALIZE_METHOD, INITIALIZED_METHOD, REQUEST_DISPLAY_MODE_METHOD, type McpUiTheme, type McpUiDisplayMode, type McpUiStyleVariableKey, type McpUiStyles, type McpUiHostCss, type McpUiHostStyles, type McpUiOpenLinkRequest, type McpUiOpenLinkResult, type McpUiMessageRequest, type McpUiMessageResult, type McpUiUpdateModelContextRequest, type McpUiSupportedContentBlockModalities, type McpUiSandboxProxyReadyNotification, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, type McpUiToolCancelledNotification, type McpUiHostContext, type McpUiHostContextChangedNotification, type McpUiResourceTeardownRequest, type McpUiResourceTeardownResult, type McpUiHostCapabilities, type McpUiAppCapabilities, type McpUiInitializeRequest, type McpUiInitializeResult, type McpUiInitializedNotification, type McpUiResourceCsp, type McpUiResourcePermissions, type McpUiResourceMeta, type McpUiRequestDisplayModeRequest, type McpUiRequestDisplayModeResult, type McpUiToolVisibility, type McpUiToolMeta, } from "./spec.types.js";
|
|
11
|
+
export { LATEST_PROTOCOL_VERSION, OPEN_LINK_METHOD, MESSAGE_METHOD, SANDBOX_PROXY_READY_METHOD, SANDBOX_RESOURCE_READY_METHOD, SIZE_CHANGED_METHOD, TOOL_INPUT_METHOD, TOOL_INPUT_PARTIAL_METHOD, TOOL_RESULT_METHOD, TOOL_CANCELLED_METHOD, HOST_CONTEXT_CHANGED_METHOD, RESOURCE_TEARDOWN_METHOD, INITIALIZE_METHOD, INITIALIZED_METHOD, REQUEST_DISPLAY_MODE_METHOD, type McpUiTheme, type McpUiDisplayMode, type McpUiStyleVariableKey, type McpUiStyles, type McpUiHostCss, type McpUiHostStyles, type McpUiOpenLinkRequest, type McpUiOpenLinkResult, type McpUiMessageRequest, type McpUiMessageResult, type McpUiUpdateModelContextRequest, type McpUiSupportedContentBlockModalities, type McpUiSandboxProxyReadyNotification, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, type McpUiToolCancelledNotification, type McpUiHostContext, type McpUiHostContextChangedNotification, type McpUiResourceTeardownRequest, type McpUiResourceTeardownResult, type McpUiHostCapabilities, type McpUiAppCapabilities, type McpUiInitializeRequest, type McpUiInitializeResult, type McpUiInitializedNotification, type McpUiResourceCsp, type McpUiResourcePermissions, type McpUiResourceMeta, type McpUiRequestDisplayModeRequest, type McpUiRequestDisplayModeResult, type McpUiToolVisibility, type McpUiToolMeta, type McpUiClientCapabilities, } from "./spec.types.js";
|
|
12
12
|
import type { McpUiInitializeRequest, McpUiOpenLinkRequest, McpUiMessageRequest, McpUiUpdateModelContextRequest, McpUiResourceTeardownRequest, McpUiRequestDisplayModeRequest, McpUiHostContextChangedNotification, McpUiToolInputNotification, McpUiToolInputPartialNotification, McpUiToolResultNotification, McpUiToolCancelledNotification, McpUiSandboxResourceReadyNotification, McpUiInitializedNotification, McpUiSizeChangedNotification, McpUiSandboxProxyReadyNotification, McpUiInitializeResult, McpUiOpenLinkResult, McpUiMessageResult, McpUiResourceTeardownResult, McpUiRequestDisplayModeResult } from "./spec.types.js";
|
|
13
13
|
export { McpUiThemeSchema, McpUiDisplayModeSchema, McpUiHostCssSchema, McpUiHostStylesSchema, McpUiOpenLinkRequestSchema, McpUiOpenLinkResultSchema, McpUiMessageRequestSchema, McpUiMessageResultSchema, McpUiUpdateModelContextRequestSchema, McpUiSupportedContentBlockModalitiesSchema, McpUiSandboxProxyReadyNotificationSchema, McpUiSandboxResourceReadyNotificationSchema, McpUiSizeChangedNotificationSchema, McpUiToolInputNotificationSchema, McpUiToolInputPartialNotificationSchema, McpUiToolResultNotificationSchema, McpUiToolCancelledNotificationSchema, McpUiHostContextSchema, McpUiHostContextChangedNotificationSchema, McpUiResourceTeardownRequestSchema, McpUiResourceTeardownResultSchema, McpUiHostCapabilitiesSchema, McpUiAppCapabilitiesSchema, McpUiInitializeRequestSchema, McpUiInitializeResultSchema, McpUiInitializedNotificationSchema, McpUiResourceCspSchema, McpUiResourcePermissionsSchema, McpUiResourceMetaSchema, McpUiRequestDisplayModeRequestSchema, McpUiRequestDisplayModeResultSchema, McpUiToolVisibilitySchema, McpUiToolMetaSchema, } from "./generated/schema.js";
|
|
14
14
|
import { CallToolRequest, CallToolResult, EmptyResult, ListPromptsRequest, ListPromptsResult, ListResourcesRequest, ListResourcesResult, ListResourceTemplatesRequest, ListResourceTemplatesResult, ListToolsRequest, ListToolsResult, LoggingMessageNotification, PingRequest, PromptListChangedNotification, ReadResourceRequest, ReadResourceResult, ResourceListChangedNotification, ToolListChangedNotification } from "@modelcontextprotocol/sdk/types.js";
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "https://github.com/modelcontextprotocol/ext-apps"
|
|
6
6
|
},
|
|
7
7
|
"homepage": "https://github.com/modelcontextprotocol/ext-apps",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "1.0.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"description": "MCP Apps SDK — Enable MCP servers to display interactive user interfaces in conversational clients.",
|
|
11
11
|
"type": "module",
|
|
@@ -47,15 +47,16 @@
|
|
|
47
47
|
"postinstall": "node scripts/setup-bun.mjs || echo 'setup-bun.mjs failed or not available'",
|
|
48
48
|
"start": "npm run examples:dev",
|
|
49
49
|
"generate:schemas": "tsx scripts/generate-schemas.ts && prettier --write \"src/generated/**/*\"",
|
|
50
|
-
"
|
|
50
|
+
"sync:snippets": "bun scripts/sync-snippets.ts",
|
|
51
|
+
"build": "npm run generate:schemas && npm run sync:snippets && node scripts/run-bun.mjs build.bun.ts",
|
|
51
52
|
"prepack": "npm run build",
|
|
52
53
|
"build:all": "npm run examples:build",
|
|
53
54
|
"test": "bun test src",
|
|
54
55
|
"test:e2e": "playwright test",
|
|
55
56
|
"test:e2e:update": "playwright test --update-snapshots",
|
|
56
57
|
"test:e2e:ui": "playwright test --ui",
|
|
57
|
-
"test:e2e:docker": "docker run --rm -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test'",
|
|
58
|
-
"test:e2e:docker:update": "npm run build:all && docker run --rm -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test --update-snapshots'",
|
|
58
|
+
"test:e2e:docker": "docker run --rm -e EXAMPLE -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test'",
|
|
59
|
+
"test:e2e:docker:update": "npm run build:all && docker run --rm -e EXAMPLE -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test --update-snapshots'",
|
|
59
60
|
"preexamples:build": "npm run build",
|
|
60
61
|
"examples:build": "bun examples/run-all.ts build",
|
|
61
62
|
"examples:start": "NODE_ENV=development npm run build && bun examples/run-all.ts start",
|
|
@@ -64,25 +65,33 @@
|
|
|
64
65
|
"prepare": "node scripts/setup-bun.mjs && npm run build && husky",
|
|
65
66
|
"docs": "typedoc",
|
|
66
67
|
"docs:watch": "typedoc --watch",
|
|
67
|
-
"generate:screenshots": "npm run build:all && docker run --rm -v $(pwd):/work -w /work mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test tests/e2e/generate-grid-screenshots.spec.ts'",
|
|
68
|
+
"generate:screenshots": "npm run build:all && docker run --rm -e EXAMPLE -v $(pwd):/work -w /work mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test tests/e2e/generate-grid-screenshots.spec.ts'",
|
|
68
69
|
"prettier": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --check",
|
|
69
70
|
"prettier:fix": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --write",
|
|
70
|
-
"check:versions": "node scripts/check-versions.mjs"
|
|
71
|
+
"check:versions": "node scripts/check-versions.mjs",
|
|
72
|
+
"update-lock:docker": "rm -rf node_modules package-lock.json && docker run --rm --platform linux/amd64 -v $(pwd):/work -w /work node:latest npm i --registry=https://registry.npmjs.org/ && rm -rf node_modules && npm i"
|
|
71
73
|
},
|
|
72
74
|
"author": "Olivier Chafik",
|
|
73
75
|
"devDependencies": {
|
|
74
|
-
"@
|
|
75
|
-
"@
|
|
76
|
+
"@boneskull/typedoc-plugin-mermaid": "^0.2.0",
|
|
77
|
+
"@modelcontextprotocol/sdk": "1.25.2",
|
|
78
|
+
"@playwright/test": "1.57.0",
|
|
76
79
|
"@types/bun": "^1.3.2",
|
|
77
80
|
"@types/react": "^19.2.2",
|
|
78
81
|
"@types/react-dom": "^19.2.2",
|
|
82
|
+
"@types/node": "20.19.27",
|
|
83
|
+
"caniuse-lite": "1.0.30001763",
|
|
84
|
+
"cheerio": "1.1.2",
|
|
79
85
|
"concurrently": "^9.2.1",
|
|
80
86
|
"cors": "^2.8.5",
|
|
81
87
|
"cross-env": "^10.1.0",
|
|
88
|
+
"electron-to-chromium": "1.5.267",
|
|
82
89
|
"esbuild": "^0.25.12",
|
|
83
90
|
"express": "^5.1.0",
|
|
84
91
|
"husky": "^9.1.7",
|
|
85
92
|
"nodemon": "^3.1.0",
|
|
93
|
+
"playwright": "1.57.0",
|
|
94
|
+
"playwright-core": "1.57.0",
|
|
86
95
|
"prettier": "^3.6.2",
|
|
87
96
|
"react": "^19.2.0",
|
|
88
97
|
"react-dom": "^19.2.0",
|
|
@@ -90,6 +99,7 @@
|
|
|
90
99
|
"ts-to-zod": "^5.1.0",
|
|
91
100
|
"tsx": "^4.21.0",
|
|
92
101
|
"typedoc": "^0.28.14",
|
|
102
|
+
"typedoc-github-theme": "^0.3.1",
|
|
93
103
|
"typescript": "^5.9.3",
|
|
94
104
|
"zod": "^4.1.13"
|
|
95
105
|
},
|
|
@@ -125,5 +135,12 @@
|
|
|
125
135
|
"@rollup/rollup-linux-x64-gnu": "^4.53.3",
|
|
126
136
|
"@rollup/rollup-win32-arm64-msvc": "^4.53.3",
|
|
127
137
|
"@rollup/rollup-win32-x64-msvc": "^4.53.3"
|
|
138
|
+
},
|
|
139
|
+
"overrides": {
|
|
140
|
+
"seroval": "1.4.1",
|
|
141
|
+
"seroval-plugins": "1.4.2",
|
|
142
|
+
"solid-js": "1.9.10",
|
|
143
|
+
"@hono/node-server": "1.19.7",
|
|
144
|
+
"@types/node": "20.19.27"
|
|
128
145
|
}
|
|
129
146
|
}
|