Skip to main content
@mcp-b/mcp-iframe runs an MCP client in the parent, connects it to an MCP server inside the iframe, and republishes the child’s capabilities on the parent. It wraps that transport flow in a custom element so applications do not have to wire the client and transport classes themselves.

When to use this package

  • You want a parent page to mirror an iframe MCP server’s capabilities.
  • You prefer a declarative element over manual IframeParentTransport and IframeChildTransport setup.
  • You want namespaced tool forwarding tied to an element ID.

When not to use this package

  • You need low-level control over message flow or custom transport wiring. Use @mcp-b/transports.
  • The iframe does not run an MCP server connected through IframeChildTransport. A standalone document.modelContext implementation is not sufficient.
  • You only need native tool discovery across a document tree. Use the browser’s allow="tools" and getTools({ fromOrigins }) surfaces instead.

MCP-B bridge versus native discovery

allow="tools" delegates the native browser feature. It does not create the MCP server or authorize transport messages.

Where it sits in the package graph

This package sits on top of the iframe transport pair from @mcp-b/transports. The parent element creates an IframeParentTransport; the child server must use the matching IframeChildTransport. It is a browser-facing convenience layer, not a separate transport protocol.

First step

Load @mcp-b/global inside the child and configure transport.iframeServer.allowedOrigins for the parent origin. The global runtime creates and connects the child MCP server automatically. Then import @mcp-b/mcp-iframe in the parent and add <mcp-iframe>. The reference page documents the complete contract.

Reference

Element registration, attributes, methods, and event contract.

Bridge tools across iframes

Set up a parent-child iframe bridge step by step.

Transports overview

Inspect the underlying iframe transport classes.

Global runtime reference

Configure the child server transport and its allowed parent origins.

WebMCP API sources

Use native cross-document discovery without an MCP-B bridge.

WebMCP resources and status

Background on cross-document exposure questions that still affect iframe behavior.