Skip to main content
The <mcp-iframe> custom element wraps an iframe and automatically exposes its tools, resources, and prompts to the parent page’s navigator.modelContext.

Installation

Requires @mcp-b/global polyfill in both parent and child pages.

Quick Start

Parent page — import to auto-register the element:
Child page — register tools via @mcp-b/global:

Item Prefixing

Items are exposed with the element’s id as prefix to prevent naming conflicts:

Attributes

Standard iframe attributes (src, width, height, sandbox, etc.) are mirrored to the internal iframe.

MCP-Specific Attributes

Events

Properties & Methods

Multiple Iframes

Each iframe uses its id as prefix:
Exposes: calc:add, calc:multiply, todos:create, todos:list, etc.

Cross-Origin

For cross-origin iframes, set target-origin explicitly:
The child must configure IframeChildTransport with allowed origins. See Security Guide for details.

Custom Registration

Transports

Underlying IframeParentTransport

@mcp-b/global

Model Context API polyfill

Security

Origin validation

MCP UI Apps

Building embeddable apps