ext-apps/examples/basic-host
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Anton Pidkuiko MacBook 2755438dba
Add Three.js marketing example server
New example demonstrating interactive 3D scene rendering with:
- show_threejs_scene tool with streaming code preview
- learn_threejs documentation tool
- Full WidgetProps interface for MCP App integration
- Reusable mcp-app-wrapper.tsx pattern

Also adds bun.lockb to .gitignore.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-08 21:19:42 +00:00
..
src Add Three.js marketing example server 2025-12-08 21:19:42 +00: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 handle server errors (#91) 2025-12-08 18:45:31 +01: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.