Skip to content

Add an MCP App runtime for front components - #32461

Draft
FelixMalfait wants to merge 2 commits into
mainfrom
felix/wizardly-sagan-upeo1x
Draft

FelixMalfait wants to merge 2 commits into
mainfrom
felix/wizardly-sagan-upeo1x

Conversation

@FelixMalfait

@FelixMalfait FelixMalfait commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Stack (MCP Apps, Twenty as an MCP Apps server), merge in order: 1. runtime → 2. resources → 3. tool binding → 4. generic mode → 5. findMany through a view → 6. View Cards app.

What

Front components can now render inside MCP Apps hosts (Claude, ChatGPT, VS Code…), not only inside Twenty. This PR adds the runtime that runs in the host's iframe.

Why a second runtime

MCP Apps hosts render a tool's UI in a sandboxed iframe whose CSP forbids blob workers and blob/data module imports, so the worker renderer cannot run there. Since the iframe already is the sandbox, this runtime renders the component on its real DOM: component bundles are DOM-agnostic and fall back to plain React JSX when no remote-dom tag map is installed.

Changes

  • src/mcp-app/bootFrontComponentMcpApp.ts connects the ext-apps App and turns tool input, result and cancellation notifications into the execution context's toolCall. It maps the host's theme and locale and installs the host communication API over MCP:
    • Twenty pages open in Twenty through openLink (navigate, openSidePanelPage).
    • unmountFrontComponent requests teardown.
    • closeSidePanel leaves fullscreen.
    • Actions with no MCP equivalent reject with FRONT_COMPONENT_MCP_APP_HOST_ACTION_UNAVAILABLE, as previews do.
  • The reader's application token and public variables come from an app-only session tool (Migrate to Typescript, add prettier and add linter #3 in the stack), called on boot and on token refresh, so the document stays cacheable and user-agnostic.
  • The runtime/server contract (session tool name, boot config, session) lives in twenty-shared/application.
  • The server does not build the renderer, so mcp-app:generate bundles the runtime into a JSON module the server links into each document. A test fails when it drifts from its source, as with the AI front component SDK module.
  • Environment utilities and host API state move out of remote/worker because both renderers share them; setWorkerEnvironmentVariables becomes setFrontComponentEnvironmentVariables.

Regenerating the runtime

npx nx build twenty-ui
npx nx run twenty-front-component-renderer:mcp-app:generate

https://claude.ai/code/session_01BC19MT31DvLYvxzeBBUKWi


Generated by Claude Code

MCP Apps hosts (Claude, ChatGPT, VS Code...) render a tool's UI in a
sandboxed iframe whose CSP forbids blob workers and blob or data module
imports, so the worker renderer cannot run there. The iframe already is
the sandbox, so this runtime renders the component on its real DOM:
component bundles are DOM-agnostic and fall back to plain React JSX when
no remote-dom tag map is installed.

- `src/mcp-app/bootFrontComponentMcpApp.ts` connects the ext-apps `App`,
  turns tool input, result and cancellation notifications into the
  execution context's `toolCall`, maps the host theme and locale, and
  installs the host communication API over MCP: Twenty pages open in
  Twenty through `openLink`, `unmountFrontComponent` requests teardown,
  `closeSidePanel` leaves fullscreen, and actions without an MCP
  equivalent reject with `FRONT_COMPONENT_MCP_APP_HOST_ACTION_UNAVAILABLE`,
  as previews do.
- The reader's application token and public variables come from an
  app-only session tool, called on boot and on token refresh, so the
  document itself stays cacheable and user-agnostic.
- The contract between this runtime and the server (session tool name,
  boot config, session) lives in `twenty-shared/application`.
- The server does not build the renderer, so the runtime is bundled by
  `mcp-app:generate` into a JSON module the server links into each
  document, with a test that fails when it drifts from its source, as
  the AI front component SDK module does.
- The environment utilities and host API state move out of
  `remote/worker` since both renderers now share them;
  `setWorkerEnvironmentVariables` becomes
  `setFrontComponentEnvironmentVariables`.
@socket-security

socket-security Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​modelcontextprotocol/​ext-apps@​2.1.09910010095100

View full report

@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

🔍 Visual Regression Review — twenty-ui

✅ 10 visual change(s) reviewed — all explained by this PR.

Changed: 11 · Added: 0 · Removed: 0 · Unchanged: 1531

10 item(s) to double-check (uncertain / low confidence)
Story Verdict Confidence Explained by
🟡 ui-surfaces-dialog--non-modal-page-interaction uncertain 60% none
🟡 ui-components-codeeditor--auto-height uncertain 55% none
🟡 ui-components-codeeditor--model-lifecycle uncertain 55% none
🟡 ui-components-codeeditor--default uncertain 60% none
🟡 ui-components-codeeditor--editing uncertain 55% none
🟡 ui-components-codeeditor--theme-precedence uncertain 55% none
🟡 ui-components-codeeditor--dark uncertain 55% none
🟡 ui-components-codeeditor--bounded-resizable uncertain 55% none
🟡 ui-components-codeeditor--css-height-resizable uncertain 55% none
🟡 ui-components-codeeditor--resizable uncertain 55% none
Changed stories
Story Diff %
ui-components-codeeditor--default 1%
ui-surfaces-dialog--non-modal-page-interaction 1%
ui-components-codeeditor--auto-height 1%
ui-components-codeeditor--model-lifecycle 1%
ui-components-codeeditor--dark 0%
ui-components-codeeditor--bounded-resizable 0%
ui-components-codeeditor--css-height-resizable 0%
ui-components-codeeditor--editing 0%
ui-components-codeeditor--theme-precedence 0%
ui-components-codeeditor--resizable 0%
ui-components-codeeditor--controlled-value 0%

View run details · advisory mode

@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

🔍 Visual Regression Review — twenty-front

✅ 13 visual change(s) reviewed — all explained by this PR.

Changed: 20 · Added: 0 · Removed: 0 · Unchanged: 2159

8 item(s) to double-check (uncertain / low confidence)
Story Verdict Confidence Explained by
🟡 ui-data-field-input-richtextfieldinput--default uncertain 60% none
🟡 modules-objectrecord-recordform-recordformfieldinputs--address uncertain 60% none
🟡 ui-data-field-form-input-formmultirecordpicker--multiple-selection-and-session-r… uncertain 60% none
🟡 modules-settings-applications-settingsapplicationiframemediapermissionssection--… uncertain 65% none
🟡 modules-recordexport-connection--page-hide uncertain 70% none
🟡 modules-pagelayout-widgets-recordpagenotewidget--dashboard-selection uncertain 60% none
🟡 modules-pagelayout-widgets-recordpagenotewidget--align-text uncertain 60% none
🟡 modules-ai-aichattab--new-chat-suggested-prompt uncertain 70% none
Changed stories
Story Diff %
ui-data-field-input-richtextfieldinput--default 16%
modules-objectrecord-recordform-recordformfieldinputs--address 11%
ui-data-field-form-input-formmultirecordpicker--multiple-selection-and-session-reset 5%
modules-settings-applications-settingsapplicationiframemediapermissionssection--reports-failed-refresh 4%
modules-recordexport-connection--page-hide 2%
modules-pagelayout-widgets-recordpagenotewidget--dashboard-selection 1%
modules-pagelayout-widgets-recordpagenotewidget--align-text 1%
modules-sidepanel-composerpages--calendar-event-without-account-permission 0%
modules-sidepanel-composerpages--calendar-event-without-accounts 0%
modules-ai-aichattab--new-chat-suggested-prompt 0%
modules-sidepanel-recordcreationflow--submit-with-command-enter 0%
modules-sidepanel-recordcreationflow--submit-with-button 0%
modules-sidepanel-recordcreationflow--submit-with-control-enter 0%
modules-sidepanel-recordcreationflow--retry-after-failed-creation 0%
modules-sidepanel-snoozeaichat--day-and-time-picker 0%
modules-sidepanel-composerpages--calendar-event 0%
modules-activities-files-videopreview--player 0%
modules-activity-taskgroups--empty 0%
modules-ai-aichattab--open-original-from-reply 0%
modules-ai-aichattab--reply-to-teammate 0%

View run details · advisory mode

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant