modelcontextprotocol / modelcontextprotocol/ext-apps

bug: Safari/WebKit event.source identity mismatch in sandbox.ts relay breaks PostMessageTransport

Open
#633 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.9k
Forks
387
Avg merge
3h 21m
Merged PRs (30d)
6

Description

Problem

In examples/basic-host/src/sandbox.ts, the relay compares event.source to inner.contentWindow to validate that incoming messages originated from the sandboxed iframe. On Safari (WebKit), this comparison fails because WebKit reports event.source === window (the outer window) rather than the iframe's contentWindow, even when the message genuinely originated from the iframe.

This means the host silently drops all messages from the View on Safari, causing the bridge to never initialize.

Steps to Reproduce

  1. Run examples/basic-host in Safari
  2. Observe that App.connect() / ui/initialize is sent but the host relay discards it due to the failed event.source check

Expected Behavior

Messages from the sandboxed iframe should be relayed correctly on all browsers, including Safari/WebKit.

Environment

  • Browser: Safari (WebKit)
  • File: examples/basic-host/src/sandbox.ts

Notes

Originally surfaced in #543. This is a separate issue from the construction-timing race addressed in that PR — it is a WebKit source-identity quirk specific to the sandbox relay, as noted by @ochafik.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in examples/basic-host/src/sandbox.ts and inspect the relay's event.source check against inner.contentWindow. Run examples/basic-host in Safari and verify that the App.connect()/ui/initialize messages are no longer discarded. Done means the sandboxed View initializes and messages relay correctly in Safari/WebKit without breaking source validation in other browsers.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.