@modelcontextprotocol/ext-apps 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -417
- package/dist/src/app-bridge.d.ts +14 -0
- package/dist/src/app-bridge.js +25 -8
- package/dist/src/app-with-deps.js +24 -7
- package/dist/src/app.d.ts +15 -21
- package/dist/src/app.js +26 -9
- package/dist/src/generated/schema.d.ts +9 -0
- package/dist/src/react/index.js +23 -6
- package/dist/src/react/react-with-deps.js +23 -6
- package/dist/src/react/useApp.d.ts +2 -2
- package/dist/src/server/index.d.ts +91 -18
- package/dist/src/server/index.js +25 -8
- package/dist/src/spec.types.d.ts +110 -13
- package/dist/src/styles.d.ts +12 -12
- package/package.json +3 -3
package/dist/src/spec.types.d.ts
CHANGED
|
@@ -404,43 +404,137 @@ export interface McpUiInitializedNotification {
|
|
|
404
404
|
}
|
|
405
405
|
/**
|
|
406
406
|
* @description Content Security Policy configuration for UI resources.
|
|
407
|
+
*
|
|
408
|
+
* Servers declare which origins their UI requires. Hosts use this to enforce appropriate CSP headers.
|
|
409
|
+
*
|
|
410
|
+
* > [!IMPORTANT]
|
|
411
|
+
* > MCP App HTML runs in a sandboxed iframe with no same-origin server.
|
|
412
|
+
* > **All** origins must be declared—including where your bundled JS/CSS is
|
|
413
|
+
* > served from (`localhost` in dev, your CDN in production).
|
|
407
414
|
*/
|
|
408
415
|
export interface McpUiResourceCsp {
|
|
409
|
-
/**
|
|
416
|
+
/**
|
|
417
|
+
* @description Origins for network requests (fetch/XHR/WebSocket).
|
|
418
|
+
*
|
|
419
|
+
* - Maps to CSP `connect-src` directive
|
|
420
|
+
* - Empty or omitted → no network connections (secure default)
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts
|
|
424
|
+
* ["https://api.weather.com", "wss://realtime.service.com"]
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
410
427
|
connectDomains?: string[];
|
|
411
|
-
/**
|
|
428
|
+
/**
|
|
429
|
+
* @description Origins for static resources (images, scripts, stylesheets, fonts, media).
|
|
430
|
+
*
|
|
431
|
+
* - Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives
|
|
432
|
+
* - Wildcard subdomains supported: `https://*.example.com`
|
|
433
|
+
* - Empty or omitted → no network resources (secure default)
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```ts
|
|
437
|
+
* ["https://cdn.jsdelivr.net", "https://*.cloudflare.com"]
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
412
440
|
resourceDomains?: string[];
|
|
413
|
-
/**
|
|
441
|
+
/**
|
|
442
|
+
* @description Origins for nested iframes.
|
|
443
|
+
*
|
|
444
|
+
* - Maps to CSP `frame-src` directive
|
|
445
|
+
* - Empty or omitted → no nested iframes allowed (`frame-src 'none'`)
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* ["https://www.youtube.com", "https://player.vimeo.com"]
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
414
452
|
frameDomains?: string[];
|
|
415
|
-
/**
|
|
453
|
+
/**
|
|
454
|
+
* @description Allowed base URIs for the document.
|
|
455
|
+
*
|
|
456
|
+
* - Maps to CSP `base-uri` directive
|
|
457
|
+
* - Empty or omitted → only same origin allowed (`base-uri 'self'`)
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* ["https://cdn.example.com"]
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
416
464
|
baseUriDomains?: string[];
|
|
417
465
|
}
|
|
418
466
|
/**
|
|
419
467
|
* @description Sandbox permissions requested by the UI resource.
|
|
468
|
+
*
|
|
469
|
+
* Servers declare which browser capabilities their UI needs.
|
|
420
470
|
* Hosts MAY honor these by setting appropriate iframe `allow` attributes.
|
|
421
471
|
* Apps SHOULD NOT assume permissions are granted; use JS feature detection as fallback.
|
|
422
472
|
*/
|
|
423
473
|
export interface McpUiResourcePermissions {
|
|
424
|
-
/**
|
|
474
|
+
/**
|
|
475
|
+
* @description Request camera access.
|
|
476
|
+
*
|
|
477
|
+
* Maps to Permission Policy `camera` feature.
|
|
478
|
+
*/
|
|
425
479
|
camera?: {};
|
|
426
|
-
/**
|
|
480
|
+
/**
|
|
481
|
+
* @description Request microphone access.
|
|
482
|
+
*
|
|
483
|
+
* Maps to Permission Policy `microphone` feature.
|
|
484
|
+
*/
|
|
427
485
|
microphone?: {};
|
|
428
|
-
/**
|
|
486
|
+
/**
|
|
487
|
+
* @description Request geolocation access.
|
|
488
|
+
*
|
|
489
|
+
* Maps to Permission Policy `geolocation` feature.
|
|
490
|
+
*/
|
|
429
491
|
geolocation?: {};
|
|
430
|
-
/**
|
|
492
|
+
/**
|
|
493
|
+
* @description Request clipboard write access.
|
|
494
|
+
*
|
|
495
|
+
* Maps to Permission Policy `clipboard-write` feature.
|
|
496
|
+
*/
|
|
431
497
|
clipboardWrite?: {};
|
|
432
498
|
}
|
|
433
499
|
/**
|
|
434
500
|
* @description UI Resource metadata for security and rendering configuration.
|
|
435
501
|
*/
|
|
436
502
|
export interface McpUiResourceMeta {
|
|
437
|
-
/** @description Content Security Policy configuration. */
|
|
503
|
+
/** @description Content Security Policy configuration for UI resources. */
|
|
438
504
|
csp?: McpUiResourceCsp;
|
|
439
|
-
/** @description Sandbox permissions requested by the UI. */
|
|
505
|
+
/** @description Sandbox permissions requested by the UI resource. */
|
|
440
506
|
permissions?: McpUiResourcePermissions;
|
|
441
|
-
/**
|
|
507
|
+
/**
|
|
508
|
+
* @description Dedicated origin for view sandbox.
|
|
509
|
+
*
|
|
510
|
+
* Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
511
|
+
*
|
|
512
|
+
* **Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
|
|
513
|
+
* - Hash-based subdomains (e.g., `{hash}.claudemcpcontent.com`)
|
|
514
|
+
* - URL-derived subdomains (e.g., `www-example-com.oaiusercontent.com`)
|
|
515
|
+
*
|
|
516
|
+
* If omitted, host uses default sandbox origin (typically per-conversation).
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```ts
|
|
520
|
+
* "a904794854a047f6.claudemcpcontent.com"
|
|
521
|
+
* ```
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```ts
|
|
525
|
+
* "www-example-com.oaiusercontent.com"
|
|
526
|
+
* ```
|
|
527
|
+
*/
|
|
442
528
|
domain?: string;
|
|
443
|
-
/**
|
|
529
|
+
/**
|
|
530
|
+
* @description Visual boundary preference - true if view prefers a visible border.
|
|
531
|
+
*
|
|
532
|
+
* Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
533
|
+
*
|
|
534
|
+
* - `true`: request visible border + background
|
|
535
|
+
* - `false`: request no visible border + background
|
|
536
|
+
* - omitted: host decides border
|
|
537
|
+
*/
|
|
444
538
|
prefersBorder?: boolean;
|
|
445
539
|
}
|
|
446
540
|
/**
|
|
@@ -481,7 +575,10 @@ export interface McpUiToolMeta {
|
|
|
481
575
|
* URI of the UI resource to display for this tool, if any.
|
|
482
576
|
* This is converted to `_meta["ui/resourceUri"]`.
|
|
483
577
|
*
|
|
484
|
-
* @example
|
|
578
|
+
* @example
|
|
579
|
+
* ```ts
|
|
580
|
+
* "ui://weather/view.html"
|
|
581
|
+
* ```
|
|
485
582
|
*/
|
|
486
583
|
resourceUri?: string;
|
|
487
584
|
/**
|
package/dist/src/styles.d.ts
CHANGED
|
@@ -31,9 +31,9 @@ export declare function getDocumentTheme(): McpUiTheme;
|
|
|
31
31
|
* @example Apply theme from host context
|
|
32
32
|
* ```ts source="./styles.examples.ts#applyDocumentTheme_fromHostContext"
|
|
33
33
|
* // Apply when host context changes
|
|
34
|
-
* app.onhostcontextchanged = (
|
|
35
|
-
* if (
|
|
36
|
-
* applyDocumentTheme(
|
|
34
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
35
|
+
* if (ctx.theme) {
|
|
36
|
+
* applyDocumentTheme(ctx.theme);
|
|
37
37
|
* }
|
|
38
38
|
* };
|
|
39
39
|
*
|
|
@@ -77,9 +77,9 @@ export declare function applyDocumentTheme(theme: McpUiTheme): void;
|
|
|
77
77
|
* document.body.style.background = "var(--color-background-primary)";
|
|
78
78
|
*
|
|
79
79
|
* // Apply when host context changes
|
|
80
|
-
* app.onhostcontextchanged = (
|
|
81
|
-
* if (
|
|
82
|
-
* applyHostStyleVariables(
|
|
80
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
81
|
+
* if (ctx.styles?.variables) {
|
|
82
|
+
* applyHostStyleVariables(ctx.styles.variables);
|
|
83
83
|
* }
|
|
84
84
|
* };
|
|
85
85
|
*
|
|
@@ -94,10 +94,10 @@ export declare function applyDocumentTheme(theme: McpUiTheme): void;
|
|
|
94
94
|
*
|
|
95
95
|
* @example Apply to a specific element
|
|
96
96
|
* ```ts source="./styles.examples.ts#applyHostStyleVariables_toElement"
|
|
97
|
-
* app.onhostcontextchanged = (
|
|
97
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
98
98
|
* const container = document.getElementById("app-root");
|
|
99
|
-
* if (container &&
|
|
100
|
-
* applyHostStyleVariables(
|
|
99
|
+
* if (container && ctx.styles?.variables) {
|
|
100
|
+
* applyHostStyleVariables(ctx.styles.variables, container);
|
|
101
101
|
* }
|
|
102
102
|
* };
|
|
103
103
|
* ```
|
|
@@ -135,9 +135,9 @@ export declare function applyHostStyleVariables(styles: McpUiStyles, root?: HTML
|
|
|
135
135
|
* @example Apply fonts from host context
|
|
136
136
|
* ```ts source="./styles.examples.ts#applyHostFonts_fromHostContext"
|
|
137
137
|
* // Apply when host context changes
|
|
138
|
-
* app.onhostcontextchanged = (
|
|
139
|
-
* if (
|
|
140
|
-
* applyHostFonts(
|
|
138
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
139
|
+
* if (ctx.styles?.css?.fonts) {
|
|
140
|
+
* applyHostFonts(ctx.styles.css.fonts);
|
|
141
141
|
* }
|
|
142
142
|
* };
|
|
143
143
|
*
|
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": "1.
|
|
8
|
+
"version": "1.1.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",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"prettier": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --check",
|
|
70
70
|
"prettier:fix": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --write",
|
|
71
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"
|
|
72
|
+
"update-lock:docker": "rm -rf node_modules package-lock.json examples/*/node_modules && docker run --rm --platform linux/amd64 -v $(pwd):/work -w /work -e HOME=/tmp node:latest npm i --registry=https://registry.npmjs.org/ --ignore-scripts && rm -rf node_modules examples/*/node_modules && npm i --registry=https://registry.npmjs.org/"
|
|
73
73
|
},
|
|
74
74
|
"author": "Olivier Chafik",
|
|
75
75
|
"devDependencies": {
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"ts-to-zod": "^5.1.0",
|
|
100
100
|
"tsx": "^4.21.0",
|
|
101
101
|
"typedoc": "^0.28.14",
|
|
102
|
-
"typedoc-github-theme": "^0.
|
|
102
|
+
"typedoc-github-theme": "^0.4.0",
|
|
103
103
|
"typescript": "^5.9.3",
|
|
104
104
|
"zod": "^4.1.13"
|
|
105
105
|
},
|