Skip to content

feat(native): render inline MCP apps with a Rust host bridge - #104

Merged
rynfar merged 2 commits into
nativefrom
nw/98-mcp-apps
Nov 3, 2026
Merged

rynfar merged 2 commits into
nativefrom
nw/98-mcp-apps

Conversation

@rynfar

@rynfar rynfar commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

MCP app tool results currently remain generic tool rows in the native transcript. This ports TR-MCPAPP's inline first slice, retaining the producing environment, thread and item when forwarding app requests.

The protocol host is pure Rust in crates/core/src/mcp_apps, with tests ported from host.test.ts. It handles initialize, ping, tool/resource requests, browser links, initialization and sizing notifications, result normalization, request bounds and JSON-RPC refusals. The client exposes all four mcpApps.* RPCs on the network runtime. Cached frames retain only their environment identity; each request resolves the current connected handle for that environment and refuses when it is disconnected or another environment is active. Tool calls preflight toolInfo; tools that need confirmation are refused in this slice. Host styles come from the native theme tokens.

The transcript loads the signed app resource into #91's WebKit view, preserving its navigation/IPC isolation, nonpersistent store and disabled script windows. Each response keeps the sandbox and the app's filtered CSP. A capture-phase transport listener sends outgoing page messages only to IPC; host messages reach the SDK with the accepted parent source, without echoing either direction. Inline sizing starts at 320px and clamps notifications to 80–2000px. Links require recent AppKit input in the app. Page/view caches are bounded; closing has a Show app action. TR-MCPAPP stays partial.

Validation:

  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (includes the authenticated connection replacement regression)
  • cargo build -p t3-native --features snapshot
  • node --test conformance/mcp-app/transport.check.ts (the exact injected bootstrap in a message-event harness with SDK-style parent/source validation and unsupported-request replies)
  • Theme generation, parity sync (42 tests), TypeScript conformance --check
  • vp run check:changed fork/native
  • Read-only smoke probe against 14658, with an isolated copied native home
  • cargo run -p t3-core --example mcp_app_host produces the deterministic initialize/input/result/size/ping/tool/resource/refusal transcript

Local evidence (intentionally not uploaded per the worker brief):

  • Before: /private/tmp/nw98-evidence/mcp-before.png
  • After, dark: /private/tmp/nw98-evidence/mcp-after.png
  • After, light: /private/tmp/nw98-evidence/mcp-after-light.png
  • Host transcript: /private/tmp/nw98-evidence/host-transcript.txt
  • Smoke probe: /private/tmp/nw98-evidence/smoke-probe.txt

The captures use --mcp-fixture apps/native/conformance/mcp-app/weather.html in the existing Replay showcase thread. They show the real transcript row, border and default-height fallback card. The offscreen renderer cannot host WebKit. No live provider-produced MCP app, WebKit page execution, real MCP tool/resource success, or system-browser open was observed; protocol and server request forwarding are verified with the pure-host and in-process WebSocket tests. No server data was changed and no paid provider was used.

Remaining gaps: fullscreen/pip, ui/message, ui/update-model-context UI (RPC only), ui/download-file, step-aside/confirm dialogs (non-read-only tools refused), theme changes while open, device permission grants, and the host-initiated resource-teardown acknowledgement/timeout handshake.

Refs #98.

Built with GPT-6.1 Sol in Codex

@rynfar
rynfar merged commit f93ac7b into native Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant