# McpUiWidget

Themed sandboxed MCP ui:// widget frame — an allow-scripts-only iframe keyed on the active theme so theme changes force a full remount.

[All components](https://rickylabs.github.io/netscript/design-system/components/) · [Theme builder](https://rickylabs.github.io/netscript/create/) · [Implementation source](https://github.com/rickylabs/netscript/blob/main/packages/fresh-ui/registry/islands/McpUiWidget.tsx)

## Live preview

[Open live mcp-ui-widget preview](https://rickylabs.github.io/netscript/assets/fresh-ui/preview/?component=mcp-ui-widget&theme=studio-utility)

The example frame is static. Connect a resolved host widget URL in your application.

## Install

```bash
netscript ui:add mcp-ui-widget
```

## Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

```tsx
import { useState } from 'preact/hooks';
import McpUiWidget from '@app/islands/ui/McpUiWidget.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><McpUiWidget src="./widget/" theme="studio-utility" title="Host-provided MCP widget" /></div><p role="status">{notice}</p></>);
}
```

## Props

Generated from native `deno doc --json --private` over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

| Owner | Prop | Type | Optional | Description |
| --- | --- | --- | --- | --- |
| `McpUiWidgetProps` | `src` | `string` | No | The resolved `ui://` source served by the FA3 sandbox route (an absolute URL or an app-relative path to that handler). This is the frame origin; it must never be a same-origin application route. |
| `McpUiWidgetProps` | `theme` | `string` | No | Active theme name. The iframe is keyed on this value for remount-on-change. |
| `McpUiWidgetProps` | `title` | `string` | Yes | Accessible title for the frame. Defaults to `"MCP UI widget"`. |
| `McpUiWidgetProps` | `sandbox` | `string` | Yes | Optional sandbox override. `allow-same-origin` is always stripped and `allow-scripts` is always guaranteed, so the frame stays restrictive on every render path. Defaults to {@link MCP_UI_WIDGET_DEFAULT_SANDBOX}. |

## Keyboard

Presentation component; no component-specific keyboard interactions.

## Tokens

Semantic contract roles: `border/default`, `radius/card`.

CSS custom properties referenced directly: `--ns-border`, `--ns-border-width`, `--ns-radius-card`, `--ns-radius-lg`, `--ns-surface`, `--ns-surface-raised`.

## Contract and compatibility

Accessibility pattern: noninteractive presentation

- Native DOM attributes pass through where the implementation accepts them.

Design contract values marked planned are not implementation props. The props above describe what ships today.
