-
Notifications
You must be signed in to change notification settings - Fork 73
feat: add sandbox flags negotiation #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds iframe sandbox flag negotiation capabilities to the MCP Apps SDK, allowing apps to request additional sandbox capabilities beyond the baseline allow-scripts and allow-same-origin flags.
Changes:
- Introduces
McpUiResourceSandboxinterface with negotiable flags for forms, popups, modals, and downloads - Adds
buildSandboxAttribute()helper function to convert structured flags to sandbox attribute strings - Updates the SDK baseline to match spec requirements (
allow-scripts allow-same-origin) with forms now negotiable
Reviewed changes
Copilot reviewed 8 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Exports new McpUiResourceSandbox type and schema |
| src/spec.types.ts | Defines McpUiResourceSandbox interface and updates related types to support sandbox negotiation |
| src/generated/schema.ts | Adds Zod schema for McpUiResourceSandbox with union type support for string overrides |
| src/generated/schema.test.ts | Adds type inference tests for new sandbox schema |
| src/generated/schema.json | JSON schema definition for sandbox flags |
| src/app-bridge.ts | Implements buildSandboxAttribute() helper function with baseline flag handling |
| src/app-bridge.test.ts | Comprehensive unit tests for buildSandboxAttribute() function |
| specification/draft/apps.mdx | Updates documentation to describe sandbox flag negotiation |
| package-lock.json | Dependency lockfile changes (includes unrelated peer flag removals) |
| examples/basic-host/src/sandbox.ts | Updates sandbox proxy to handle structured flags and string overrides |
| examples/basic-host/src/index.tsx | Updates to pass sandbox configuration through initialization flow |
| examples/basic-host/src/implementation.ts | Updates to extract and pass sandbox metadata to proxy loader |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| iframe: HTMLIFrameElement, | ||
| csp?: McpUiResourceCsp, | ||
| permissions?: McpUiResourcePermissions, | ||
| sandbox?: McpUiResourceSandbox, |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter type for sandbox should be McpUiResourceSandbox | string (union type) to match the specification and the type of McpUiSandboxResourceReadyNotification['params']['sandbox']. The spec allows both structured flags objects and raw string overrides. While buildSandboxAttribute() will still work correctly since it only accepts McpUiResourceSandbox | undefined, the function signature should align with the spec to properly accept string values that apps might provide.
Add iframe sandbox flag negotiation, allowing apps to request additional sandbox capabilities beyond the baseline (
allow-scripts,allow-same-origin).Motivation and Context
Completes #58 and a step towards addressing #320. Phase 1: Sandbox Negotiation.
Previously, apps had no mechanism to request sandbox capabilities like form submission, popups, modals, or downloads.
The spec sets the minimum support to
allow-scripts allow-same-origin, which is insufficient for legitimate use cases such as form submissions and print dialogs.This change:
McpUiResourceSandboxinterface with negotiable flags:forms,popups,modals,downloadsallow-scripts allow-same-origin(to fit the spec) and makesallow-formsa negotiable capability.buildSandboxAttribute()helper to convert structured flags to sandbox attribute stringssandboxproperty in favor of the structured change?)How Has This Been Tested?
Unit tests
Breaking Changes
No breaking changes to the spec.
The SDK had an unexpected artifact that's not mentioned in the spec - a raw string
sandboxproperty passed to the inner iframe inMcpUiSandboxResourceReadyNotification. It wasn't used by any example, and it wouldn't have worked in all scenarios on its own. I overrode it with the new flag type to keep things clean (@ochafik WDYT? Did you have something else in mind when adding it?)Basic-host loses its allow-frames (in order to comply with the spec).
Types of changes
Checklist
Additional context
In the next phases of #320, we can add additional permissions and go deeper into intersecting permissions