Skip to content

fix(example): isolate MCP app preview origin - #7999

Merged
BenTaylorDev merged 1 commit into
CopilotKit:mainfrom
pei711:fix/7997-sandbox-origin
Oct 28, 2026
Merged

BenTaylorDev merged 1 commit into
CopilotKit:mainfrom
pei711:fix/7997-sandbox-origin

Conversation

@pei711

@pei711 pei711 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Removes allow-same-origin from the MCP app preview iframe. Connected app HTML keeps script execution and preview messaging but receives an opaque origin, preventing access to the host app's cookies and storage.

Related PRs and Issues

Fixes #7997

Validation

  • Headless Chromium srcDoc origin-isolation probe passed.
  • Repository pre-commit checks and git diff --check passed.
  • Standalone ESLint reports an existing react-hooks/set-state-in-effect finding at unchanged line 29; targeted lint passes with that rule suppressed. tsc --noEmit is blocked by the existing missing ./image.png import in app/page.tsx.

Checklist

  • I have read the Contribution Guide.
  • No user-facing feature documentation is needed for this security fix.
  • This change is not breaking.
  • Allow edits by maintainers is enabled.

Summary by CodeRabbit

  • Changes
    • MCP app previews now run with scripts enabled while no longer sharing the host page’s origin. This changes the permissions available to content displayed in the preview; some preview behavior that relies on same-origin access may differ.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T14:44:49.959118Z
We couldn’t complete this review. Comment @codex review to try again.
7f0bb1f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3cc0e69 and 7f0bb1f.

Files selected for processing: 1
  • examples/showcases/open-mcp-client/apps/web/app/components/McpAppPreview.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The MCP app preview iframe no longer grants allow-same-origin. It retains allow-scripts.

Changes: Preview iframe sandbox

Layer / File(s) Summary
Sandbox permissions
examples/showcases/open-mcp-client/apps/web/app/components/McpAppPreview.tsx
The iframe sandbox retains allow-scripts and no longer grants allow-same-origin.

Priority: Normal

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix · Severity of issue fixed: High

Possibly related issues

  • Issue 6910 describes the same host-origin access problem for MCP Apps. This change removes same-origin access from the open-mcp-client preview.
  • Issue 7119 requests origin isolation for MCP Apps examples. This change applies opaque-origin sandboxing to the preview.

Possibly related PRs

  • CopilotKit/CopilotKit#7896: Both changes remove allow-same-origin from MCP app iframe sandboxing. PR 7896 updates the shared renderer; this PR updates the standalone preview.
Merge Risk: Minimal · up to 7f0bb

The preview now isolates connected app content from the host origin as intended, with no merge-blocking risk identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(example): isolate MCP app preview origin" matches the main change. The PR removes allow-same-origin from the McpAppPreview iframe sandbox, so the preview gets an opaque origin. The titl…
Linked Issues check Passed Issue #7997 requires the open-mcp-client preview iframe to stop inheriting the host origin. The diff changes sandbox="allow-scripts allow-same-origin" to sandbox="allow-scripts" in `McpAppPrevie…
Out of Scope Changes check Passed The pull request changes one sandbox attribute in the exact file and iframe identified by issue #7997. The change directly implements origin isolation. No unrelated changes are present in the reviewed…
Full details: Title check

Explanation

The title "fix(example): isolate MCP app preview origin" matches the main change. The PR removes allow-same-origin from the McpAppPreview iframe sandbox, so the preview gets an opaque origin. The title names the area (example), the component effect (origin isolation), and the fix type. It is specific and concise, and it does not use vague terms.

Full details: Linked Issues check

Explanation

Issue #7997 requires the open-mcp-client preview iframe to stop inheriting the host origin. The diff changes sandbox="allow-scripts allow-same-origin" to sandbox="allow-scripts" in McpAppPreview.tsx. This preserves script execution and removes allow-same-origin, which gives the srcDoc document an opaque origin. No additional coding or test requirement appears in the linked issue.

Full details: Out of Scope Changes check

Explanation

The pull request changes one sandbox attribute in the exact file and iframe identified by issue #7997. The change directly implements origin isolation. No unrelated changes are present in the reviewed diff.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BenTaylorDev BenTaylorDev 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.

Verified: the host side matches on event.source and posts with targetOrigin "*", so the preview's messaging doesn't depend on the iframe's origin, and dropping allow-same-origin gives the app an opaque origin, the same default #7896 set for @copilotkit/mcp-apps-renderer. The public/sandbox.html proxies in the other MCP Apps examples are tracked separately in #7119. Thanks for the quick fix.

I bless the code with a glad heart

@BenTaylorDev
BenTaylorDev added this pull request to the merge queue Oct 28, 2026
Merged via the queue into CopilotKit:main with commit f491212 Oct 28, 2026
19 checks passed
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.

open-mcp-client example: the MCP app preview iframe runs on the host origin (srcdoc + allow-same-origin)

2 participants