Skip to content

feat(embed): add the @a2ui/embed/mcp iframe runtime - #4299

Draft
josemontespg wants to merge 1 commit into
embed/2-serverfrom
embed/3-view
Draft

josemontespg wants to merge 1 commit into
embed/2-serverfrom
embed/3-view

Conversation

@josemontespg

@josemontespg josemontespg commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Problem: Rendering A2UI v1.0 payloads inside a sandboxed MCP Apps host iframe requires atomic batch validation, ordered a2ui_action routing, debounced ui/update-model-context synchronization, host theme and size adaptation (including top-layer modals), and zero CSP violations under default-src 'none'.

This PR adds startEmbedApp in @a2ui/embed/mcp. It connects to the host with @modelcontextprotocol/ext-apps, renders validated batches with @a2ui/lit, routes actions and follow-ups, shares sendDataModel changes within maxBytes, keeps open modals visible inside resized frames, and runs Zod in jitless mode.

Changes

  1. src/mcp/start_embed_app.ts, surface_session.ts, embed_view.ts, and action_queue.ts: host connection, atomic batch rendering, and ordered action dispatch.
  2. src/mcp/model_context.ts: debounced and byte-capped ui/update-model-context updates for sendDataModel surfaces.
  3. src/mcp/dialog_height.ts, theme.ts, and zod_jitless.ts: modal height tracking (measuring .a2ui-modal-content inside top-layer <dialog open>), host theme mapping, and CSP-safe Zod setup.
  4. tests/, README.md, and CHANGELOG.md: AppBridge test host, fixture app, and Karma tests under the default MCP Apps CSP.

Verification

  1. WIREIT_CACHE=none yarn workspace @a2ui/embed test: 158 Node tests and 29 Karma tests pass with zero CSP violations.
  2. yarn workspace @a2ui/embed lint, yarn workspace @a2ui/embed format:check, and ./scripts/fix_licenses.py --check pass.

@josemontespg
josemontespg added this pull request to stack #4301 November 18, 2026 21:14

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the MCP App runtime (@a2ui/embed/mcp) and the startEmbedApp function, enabling A2UI rendering inside an MCP Apps host iframe with support for host themes, model context synchronization, and action queue management. The feedback highlights three key issues: a race condition in TaskQueue.run that could bypass the concurrency limit, a dependency mismatch where zod/v4/core is imported but Zod v3 is declared in package.json, and a promise chaining issue in ready initialization that fails to catch errors thrown during host context application.

Comment thread typescript/embed/src/mcp/zod_jitless.ts Resolved

This branch has not been deployed

No deployments
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