ext-apps/examples/basic-host
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jonathan Hefner 8bb58f332a Update MIME type to text/html;profile=mcp-app
Apply MIME type change from commit 0af1532 to all examples and docs.
The profile parameter follows RFC 6838 recommendations for custom
media types, as MCP Apps is a profile of HTML rather than a new syntax.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:50:30 -06:00
..
src Update MIME type to text/html;profile=mcp-app 2025-12-04 14:50:30 -06:00
index.html Add basic-host and basic-server-react examples 2025-12-04 14:28:27 -06:00
package.json Add basic-host and basic-server-react examples 2025-12-04 14:28:27 -06:00
README.md Add basic-host and basic-server-react examples 2025-12-04 14:28:27 -06:00
sandbox.html Add basic-host and basic-server-react examples 2025-12-04 14:28:27 -06:00
serve.ts Add basic-host and basic-server-react examples 2025-12-04 14:28:27 -06:00
tsconfig.json Add basic-host and basic-server-react examples 2025-12-04 14:28:27 -06:00
vite.config.ts Add basic-host and basic-server-react examples 2025-12-04 14:28:27 -06:00

Example: Basic Host

A reference implementation showing how to build an MCP Host application that connects to MCP servers and renders tool UIs in a secure sandbox.

This basic host can also be used to test MCP Apps during local development.

Key Files

Getting Started

npm install
npm run dev
# Open http://localhost:8080

Architecture

This example uses a double-iframe sandbox pattern for secure UI isolation:

Host (port 8080)
  └── Outer iframe (port 8081) - sandbox proxy
        └── Inner iframe (srcdoc) - untrusted tool UI

Why two iframes?

  • The outer iframe runs on a separate origin (port 8081) preventing direct access to the host
  • The inner iframe receives HTML via srcdoc and is restricted by sandbox attributes
  • Messages flow through the outer iframe which validates and relays them bidirectionally

This architecture ensures that even if tool UI code is malicious, it cannot access the host application's DOM, cookies, or JavaScript context.