modelcontextprotocol / modelcontextprotocol/ext-apps
bug: Safari/WebKit event.source identity mismatch in sandbox.ts relay breaks PostMessageTransport
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
- Run
examples/basic-hostin Safari - Observe that
App.connect()/ui/initializeis sent but the host relay discards it due to the failedevent.sourcecheck
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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