-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Question
Should MCP-UI <iframe /> instances in Goose allow-forms on the sandbox?
Use case: https://x.com/kentcdodds/status/1956134483020931415
Currently
When the <MCPUIResourceRenderer /> component in Goose receives raw HTML from an embedded resource in a tool response, it renders an <iframe /> like this:
<iframe
srcdoc="<html>...</html>"
sandbox="allow-scripts"
title="..."
style="...">
</iframe>When the <MCPUIResourceRenderer /> component in Goose receives an external URL from an embedded resource in a tool response, it renders an <iframe /> like this:
<iframe
src="..."
sandbox="allow-scripts allow-same-origin"
title="..."
style="...">
</iframe>This iframe comes from @mcp-ui/client, which automatically sets the iframe sandbox:
- for raw HTML:
allow-scripts - for external URL:
allow-scripts allow-same-origin
Possible Config
We have the ability to override the sandbox permissions by setting htmlProps.iframeProps.sandbox to a string (refer to: https://x.com/idosal1/status/1956139895078183102).
This allows Goose to provide a more strict or more lenient CSP — coming soon is a more ergonomic approach MCP-UI-Org/mcp-ui#83.
// MCPUIResourceRenderer.tsx
import { UIResourceRenderer } from '@mcp-ui/client';
// ...
<UIResourceRenderer
resource={content.resource}
onUIAction={handleUIAction}
htmlProps={{
iframeProps: {
sandbox: 'allow-forms allow-scripts',
},
// other htmlProps are present in the source code but removed here for focused discussion
}}
/>
// ...<!-- assuming raw HTML is returned by the tool response, the above JSX would yield... -->
<iframe
srcdoc="<html>...</html>"
sandbox="allow-forms allow-scripts"
title="..."
style="...">
</iframe>Possible outcomes
Support allow-forms
If we want to add allow-forms to the sandbox of the MCP-UI <iframe />, this will be a quick implementation
Provide guidance for an alternative path
If we don't allow-forms, we need to document why not, and propose alternative solutions such as:
- MCP-UI resources should be stateful and post via fetch api
- MCP-UI resources should communicate a response to Goose via MCP UI actions (post messages)
References
- MCP-UI: Allow Configuring Sandboxing Allow Configuring Sandboxing MCP-UI-Org/mcp-ui#68 (comment)
- MCP-UI: feat: add sandbox permissions instead of an override feat: add sandbox permissions instead of an override MCP-UI-Org/mcp-ui#83