feat: enhance sandbox capability negotiation (#158)

* feat: enhance sandbox capability negotiation

* Update specification/draft/apps.mdx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* add all csp and permissions to host capabilities + update SEP

* feat: add clipboard-write permission support

Adds clipboardWrite to McpUiResourcePermissions for clipboard access.
Maps to Permission Policy 'clipboard-write' feature.

* rm files added by mistake

* refactor: change McpUiResourcePermissions properties to empty objects

* chore: remove scratch files and redundant cross-env dependency

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Olivier Chafik <ochafik@anthropic.com>
This commit is contained in:
Ido Salomon 2026-01-12 17:10:27 +02:00 • committed by GitHub
commit 9acc52cb96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -211,6 +211,40 @@ export const McpUiResourceCspSchema = z.object({
.describe("Allowed base URIs for the document (base-uri directive)."),
});
/**
* @description Sandbox permissions requested by the UI resource.
* Hosts MAY honor these by setting appropriate iframe `allow` attributes.
* Apps SHOULD NOT assume permissions are granted; use JS feature detection as fallback.
*/
export const McpUiResourcePermissionsSchema = z.object({
/** @description Request camera access (Permission Policy `camera` feature). */
camera: z
.object({})
.optional()
.describe("Request camera access (Permission Policy `camera` feature)."),
/** @description Request microphone access (Permission Policy `microphone` feature). */
microphone: z
.object({})
.optional()
.describe(
"Request microphone access (Permission Policy `microphone` feature).",
),
/** @description Request geolocation access (Permission Policy `geolocation` feature). */
geolocation: z
.object({})
.optional()
.describe(
"Request geolocation access (Permission Policy `geolocation` feature).",
),
/** @description Request clipboard write access (Permission Policy `clipboard-write` feature). */
clipboardWrite: z
.object({})
.optional()
.describe(
"Request clipboard write access (Permission Policy `clipboard-write` feature).",
),
});
/**
* @description Notification of UI size changes (bidirectional: Guest <-> Host).
* @see {@link app.App.sendSizeChanged} for the method to send this from Guest UI
@ -363,6 +397,20 @@ export const McpUiHostCapabilitiesSchema = z.object({
.describe("Host can proxy resource reads to the MCP server."),
/** @description Host accepts log messages. */
logging: z.object({}).optional().describe("Host accepts log messages."),
/** @description Sandbox configuration applied by the host. */
sandbox: z
.object({
/** @description Permissions granted by the host (camera, microphone, geolocation). */
permissions: McpUiResourcePermissionsSchema.optional().describe(
"Permissions granted by the host (camera, microphone, geolocation).",
),
/** @description CSP domains approved by the host. */
csp: McpUiResourceCspSchema.optional().describe(
"CSP domains approved by the host.",
),
})
.optional()
.describe("Sandbox configuration applied by the host."),
});
/**
@ -405,6 +453,10 @@ export const McpUiResourceMetaSchema = z.object({
csp: McpUiResourceCspSchema.optional().describe(
"Content Security Policy configuration.",
),
/** @description Sandbox permissions requested by the UI. */
permissions: McpUiResourcePermissionsSchema.optional().describe(
"Sandbox permissions requested by the UI.",
),
/** @description Dedicated origin for widget sandbox. */
domain: z
.string()
@ -514,6 +566,10 @@ export const McpUiSandboxResourceReadyNotificationSchema = z.object({
csp: McpUiResourceCspSchema.optional().describe(
"CSP configuration from resource metadata.",
),
/** @description Sandbox permissions from resource metadata. */
permissions: McpUiResourcePermissionsSchema.optional().describe(
"Sandbox permissions from resource metadata.",
),
}),
});