@modelcontextprotocol/ext-apps 0.2.2 → 0.3.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.
@@ -28,7 +28,7 @@ export type McpUiDisplayMode = "inline" | "fullscreen" | "pip";
28
28
  /**
29
29
  * @description CSS variable keys available to MCP apps for theming.
30
30
  */
31
- export type McpUiStyleVariableKey = "--color-background-primary" | "--color-background-secondary" | "--color-background-tertiary" | "--color-background-inverse" | "--color-background-ghost" | "--color-background-info" | "--color-background-danger" | "--color-background-success" | "--color-background-warning" | "--color-background-disabled" | "--color-text-primary" | "--color-text-secondary" | "--color-text-tertiary" | "--color-text-inverse" | "--color-text-info" | "--color-text-danger" | "--color-text-success" | "--color-text-warning" | "--color-text-disabled" | "--color-text-ghost" | "--color-border-primary" | "--color-border-secondary" | "--color-border-tertiary" | "--color-border-inverse" | "--color-border-ghost" | "--color-border-info" | "--color-border-danger" | "--color-border-success" | "--color-border-warning" | "--color-border-disabled" | "--color-ring-primary" | "--color-ring-secondary" | "--color-ring-inverse" | "--color-ring-info" | "--color-ring-danger" | "--color-ring-success" | "--color-ring-warning" | "--font-sans" | "--font-mono" | "--font-weight-normal" | "--font-weight-medium" | "--font-weight-semibold" | "--font-weight-bold" | "--font-text-xs-size" | "--font-text-sm-size" | "--font-text-md-size" | "--font-text-lg-size" | "--font-heading-xs-size" | "--font-heading-sm-size" | "--font-heading-md-size" | "--font-heading-lg-size" | "--font-heading-xl-size" | "--font-heading-2xl-size" | "--font-heading-3xl-size" | "--font-text-xs-line-height" | "--font-text-sm-line-height" | "--font-text-md-line-height" | "--font-text-lg-line-height" | "--font-heading-xs-line-height" | "--font-heading-sm-line-height" | "--font-heading-md-line-height" | "--font-heading-lg-line-height" | "--font-heading-xl-line-height" | "--font-heading-2xl-line-height" | "--font-heading-3xl-line-height" | "--border-radius-xs" | "--border-radius-sm" | "--border-radius-md" | "--border-radius-lg" | "--border-radius-xl" | "--border-radius-full" | "--border-width-regular" | "--shadow-hairline" | "--shadow-sm" | "--shadow-md" | "--shadow-lg";
31
+ export type McpUiStyleVariableKey = "--color-background-primary" | "--color-background-secondary" | "--color-background-tertiary" | "--color-background-inverse" | "--color-background-ghost" | "--color-background-info" | "--color-background-danger" | "--color-background-success" | "--color-background-warning" | "--color-background-disabled" | "--color-text-primary" | "--color-text-secondary" | "--color-text-tertiary" | "--color-text-inverse" | "--color-text-ghost" | "--color-text-info" | "--color-text-danger" | "--color-text-success" | "--color-text-warning" | "--color-text-disabled" | "--color-text-ghost" | "--color-border-primary" | "--color-border-secondary" | "--color-border-tertiary" | "--color-border-inverse" | "--color-border-ghost" | "--color-border-info" | "--color-border-danger" | "--color-border-success" | "--color-border-warning" | "--color-border-disabled" | "--color-ring-primary" | "--color-ring-secondary" | "--color-ring-inverse" | "--color-ring-info" | "--color-ring-danger" | "--color-ring-success" | "--color-ring-warning" | "--font-sans" | "--font-mono" | "--font-weight-normal" | "--font-weight-medium" | "--font-weight-semibold" | "--font-weight-bold" | "--font-text-xs-size" | "--font-text-sm-size" | "--font-text-md-size" | "--font-text-lg-size" | "--font-heading-xs-size" | "--font-heading-sm-size" | "--font-heading-md-size" | "--font-heading-lg-size" | "--font-heading-xl-size" | "--font-heading-2xl-size" | "--font-heading-3xl-size" | "--font-text-xs-line-height" | "--font-text-sm-line-height" | "--font-text-md-line-height" | "--font-text-lg-line-height" | "--font-heading-xs-line-height" | "--font-heading-sm-line-height" | "--font-heading-md-line-height" | "--font-heading-lg-line-height" | "--font-heading-xl-line-height" | "--font-heading-2xl-line-height" | "--font-heading-3xl-line-height" | "--border-radius-xs" | "--border-radius-sm" | "--border-radius-md" | "--border-radius-lg" | "--border-radius-xl" | "--border-radius-full" | "--border-width-regular" | "--shadow-hairline" | "--shadow-sm" | "--shadow-md" | "--shadow-lg";
32
32
  /**
33
33
  * @description Style variables for theming MCP apps.
34
34
  *
@@ -197,7 +197,7 @@ export interface McpUiHostContext {
197
197
  /** @description Metadata of the tool call that instantiated this App. */
198
198
  toolInfo?: {
199
199
  /** @description JSON-RPC id of the tools/call request. */
200
- id: RequestId;
200
+ id?: RequestId;
201
201
  /** @description Tool definition including name, inputSchema, etc. */
202
202
  tool: Tool;
203
203
  };
@@ -209,17 +209,23 @@ export interface McpUiHostContext {
209
209
  displayMode?: McpUiDisplayMode;
210
210
  /** @description Display modes the host supports. */
211
211
  availableDisplayModes?: string[];
212
- /** @description Current and maximum dimensions available to the UI. */
213
- viewport?: {
214
- /** @description Current viewport width in pixels. */
215
- width: number;
216
- /** @description Current viewport height in pixels. */
212
+ /**
213
+ * @description Container dimensions. Represents the dimensions of the iframe or other
214
+ * container holding the app. Specify either width or maxWidth, and either height or maxHeight.
215
+ */
216
+ containerDimensions?: ({
217
+ /** @description Fixed container height in pixels. */
217
218
  height: number;
218
- /** @description Maximum available height in pixels (if constrained). */
219
- maxHeight?: number;
220
- /** @description Maximum available width in pixels (if constrained). */
221
- maxWidth?: number;
222
- };
219
+ } | {
220
+ /** @description Maximum container height in pixels. */
221
+ maxHeight?: number | undefined;
222
+ }) & ({
223
+ /** @description Fixed container width in pixels. */
224
+ width: number;
225
+ } | {
226
+ /** @description Maximum container width in pixels. */
227
+ maxWidth?: number | undefined;
228
+ });
223
229
  /** @description User's language and region preference in BCP 47 format. */
224
230
  locale?: string;
225
231
  /** @description User's timezone in IANA format. */
@@ -406,12 +412,12 @@ export type McpUiToolVisibility = "model" | "app";
406
412
  */
407
413
  export interface McpUiToolMeta {
408
414
  /**
409
- * URI of the UI resource to display for this tool.
415
+ * URI of the UI resource to display for this tool, if any.
410
416
  * This is converted to `_meta["ui/resourceUri"]`.
411
417
  *
412
418
  * @example "ui://weather/widget.html"
413
419
  */
414
- resourceUri: string;
420
+ resourceUri?: string;
415
421
  /**
416
422
  * @description Who can access this tool. Default: ["model", "app"]
417
423
  * - "model": Tool visible to and callable by the agent
@@ -419,3 +425,33 @@ export interface McpUiToolMeta {
419
425
  */
420
426
  visibility?: McpUiToolVisibility[];
421
427
  }
428
+ /**
429
+ * Method string constants for MCP Apps protocol messages.
430
+ *
431
+ * These constants provide a type-safe way to check message methods without
432
+ * accessing internal Zod schema properties. External libraries should use
433
+ * these constants instead of accessing `schema.shape.method._def.values[0]`.
434
+ *
435
+ * @example
436
+ * ```typescript
437
+ * import { SANDBOX_PROXY_READY_METHOD } from '@modelcontextprotocol/ext-apps';
438
+ *
439
+ * if (event.data.method === SANDBOX_PROXY_READY_METHOD) {
440
+ * // Handle sandbox proxy ready notification
441
+ * }
442
+ * ```
443
+ */
444
+ export declare const OPEN_LINK_METHOD: McpUiOpenLinkRequest["method"];
445
+ export declare const MESSAGE_METHOD: McpUiMessageRequest["method"];
446
+ export declare const SANDBOX_PROXY_READY_METHOD: McpUiSandboxProxyReadyNotification["method"];
447
+ export declare const SANDBOX_RESOURCE_READY_METHOD: McpUiSandboxResourceReadyNotification["method"];
448
+ export declare const SIZE_CHANGED_METHOD: McpUiSizeChangedNotification["method"];
449
+ export declare const TOOL_INPUT_METHOD: McpUiToolInputNotification["method"];
450
+ export declare const TOOL_INPUT_PARTIAL_METHOD: McpUiToolInputPartialNotification["method"];
451
+ export declare const TOOL_RESULT_METHOD: McpUiToolResultNotification["method"];
452
+ export declare const TOOL_CANCELLED_METHOD: McpUiToolCancelledNotification["method"];
453
+ export declare const HOST_CONTEXT_CHANGED_METHOD: McpUiHostContextChangedNotification["method"];
454
+ export declare const RESOURCE_TEARDOWN_METHOD: McpUiResourceTeardownRequest["method"];
455
+ export declare const INITIALIZE_METHOD: McpUiInitializeRequest["method"];
456
+ export declare const INITIALIZED_METHOD: McpUiInitializedNotification["method"];
457
+ export declare const REQUEST_DISPLAY_MODE_METHOD: McpUiRequestDisplayModeRequest["method"];
@@ -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, type McpUiTheme, type McpUiDisplayMode, type McpUiStyleVariableKey, type McpUiStyles, type McpUiHostCss, type McpUiHostStyles, type McpUiOpenLinkRequest, type McpUiOpenLinkResult, type McpUiMessageRequest, type McpUiMessageResult, type McpUiSandboxProxyReadyNotification, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, type McpUiToolCancelledNotification, type McpUiHostContext, type McpUiHostContextChangedNotification, type McpUiResourceTeardownRequest, type McpUiResourceTeardownResult, type McpUiHostCapabilities, type McpUiAppCapabilities, type McpUiInitializeRequest, type McpUiInitializeResult, type McpUiInitializedNotification, type McpUiResourceCsp, type McpUiResourceMeta, 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 McpUiSandboxProxyReadyNotification, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, type McpUiToolCancelledNotification, type McpUiHostContext, type McpUiHostContextChangedNotification, type McpUiResourceTeardownRequest, type McpUiResourceTeardownResult, type McpUiHostCapabilities, type McpUiAppCapabilities, type McpUiInitializeRequest, type McpUiInitializeResult, type McpUiInitializedNotification, type McpUiResourceCsp, type McpUiResourceMeta, type McpUiRequestDisplayModeRequest, type McpUiRequestDisplayModeResult, type McpUiToolVisibility, type McpUiToolMeta, } from "./spec.types.js";
12
12
  import type { McpUiInitializeRequest, McpUiOpenLinkRequest, McpUiMessageRequest, 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, McpUiSandboxProxyReadyNotificationSchema, McpUiSandboxResourceReadyNotificationSchema, McpUiSizeChangedNotificationSchema, McpUiToolInputNotificationSchema, McpUiToolInputPartialNotificationSchema, McpUiToolResultNotificationSchema, McpUiToolCancelledNotificationSchema, McpUiHostContextSchema, McpUiHostContextChangedNotificationSchema, McpUiResourceTeardownRequestSchema, McpUiResourceTeardownResultSchema, McpUiHostCapabilitiesSchema, McpUiAppCapabilitiesSchema, McpUiInitializeRequestSchema, McpUiInitializeResultSchema, McpUiInitializedNotificationSchema, McpUiResourceCspSchema, 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.2.2",
8
+ "version": "0.3.1",
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",
@@ -15,10 +15,18 @@
15
15
  "types": "./dist/src/app.d.ts",
16
16
  "default": "./dist/src/app.js"
17
17
  },
18
+ "./app-with-deps": {
19
+ "types": "./dist/src/app.d.ts",
20
+ "default": "./dist/src/app-with-deps.js"
21
+ },
18
22
  "./react": {
19
23
  "types": "./dist/src/react/index.d.ts",
20
24
  "default": "./dist/src/react/index.js"
21
25
  },
26
+ "./react-with-deps": {
27
+ "types": "./dist/src/react/index.d.ts",
28
+ "default": "./dist/src/react/react-with-deps.js"
29
+ },
22
30
  "./app-bridge": {
23
31
  "types": "./dist/src/app-bridge.d.ts",
24
32
  "default": "./dist/src/app-bridge.js"
@@ -37,16 +45,18 @@
37
45
  ],
38
46
  "scripts": {
39
47
  "postinstall": "node scripts/setup-bun.mjs || echo 'setup-bun.mjs failed or not available'",
48
+ "start": "npm run examples:start",
40
49
  "generate:schemas": "tsx scripts/generate-schemas.ts && prettier --write \"src/generated/**/*\"",
41
50
  "build": "npm run generate:schemas && node scripts/run-bun.mjs build.bun.ts",
42
51
  "prepack": "npm run build",
43
- "build:all": "npm run build && npm run examples:build",
52
+ "build:all": "npm run examples:build",
44
53
  "test": "bun test src",
45
54
  "test:e2e": "playwright test",
46
55
  "test:e2e:update": "playwright test --update-snapshots",
47
56
  "test:e2e:ui": "playwright test --ui",
48
57
  "test:e2e:docker": "docker run --rm -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'npm i -g bun && npm ci && npx playwright test'",
49
58
  "test:e2e:docker:update": "docker run --rm -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'npm i -g bun && npm ci && npx playwright test --update-snapshots'",
59
+ "preexamples:build": "npm run build",
50
60
  "examples:build": "bun examples/run-all.ts build",
51
61
  "examples:start": "NODE_ENV=development npm run build && bun examples/run-all.ts start",
52
62
  "examples:dev": "NODE_ENV=development bun examples/run-all.ts dev",
@@ -55,7 +65,8 @@
55
65
  "docs": "typedoc",
56
66
  "docs:watch": "typedoc --watch",
57
67
  "prettier": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --check",
58
- "prettier:fix": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --write"
68
+ "prettier:fix": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --write",
69
+ "check:versions": "node scripts/check-versions.mjs"
59
70
  },
60
71
  "author": "Olivier Chafik",
61
72
  "devDependencies": {
@@ -71,6 +82,7 @@
71
82
  "express": "^5.1.0",
72
83
  "husky": "^9.1.7",
73
84
  "nodemon": "^3.1.0",
85
+ "prettier": "^3.6.2",
74
86
  "react": "^19.2.0",
75
87
  "react-dom": "^19.2.0",
76
88
  "ts-to-zod": "^5.1.0",
@@ -93,9 +105,6 @@
93
105
  "optional": true
94
106
  }
95
107
  },
96
- "dependencies": {
97
- "prettier": "^3.6.2"
98
- },
99
108
  "optionalDependencies": {
100
109
  "@oven/bun-darwin-aarch64": "^1.2.21",
101
110
  "@oven/bun-darwin-x64": "^1.2.21",
@@ -112,6 +121,7 @@
112
121
  "@rollup/rollup-darwin-x64": "^4.53.3",
113
122
  "@rollup/rollup-linux-arm64-gnu": "^4.53.3",
114
123
  "@rollup/rollup-linux-x64-gnu": "^4.53.3",
124
+ "@rollup/rollup-win32-arm64-msvc": "^4.53.3",
115
125
  "@rollup/rollup-win32-x64-msvc": "^4.53.3"
116
126
  }
117
127
  }