Skip to main content
This guide uses <mcp-iframe> to connect a parent-side MCP client to an MCP server in a child frame. The element republishes the child’s tools on the parent’s document.modelContext and, when the parent provides MCP-B extensions, also republishes prompts and resources.
Native cross-document discovery is a separate browser mechanism. The parent delegates the tools feature with <iframe allow="tools">, the child registers a tool with exposedTo, and the parent discovers it with getTools({ fromOrigins }). That path does not use MCP transports, add MCP-B name prefixes, or bridge prompts and resources.

Prerequisites

  • You control the parent and child applications.
  • The parent exposes document.modelContext. Use @mcp-b/global when you also need prompts and resources.
  • The child runs an MCP server connected to IframeChildTransport. @mcp-b/global supplies both pieces automatically when it runs inside an iframe. A standalone document.modelContext implementation is not enough for the MCP-B bridge.

Install the packages

Install @mcp-b/global in the child application. Install both packages in the parent application:
Install iframe bridge packages
1

Configure the child MCP server

Configure the parent origin before importing @mcp-b/global in the child page:
child-app.html
Inside an iframe, @mcp-b/global creates an MCP server, connects it through IframeChildTransport, and continues to let application code use document.modelContext normally. Set allowedOrigins to the exact parent origins. Its convenience default is ['*'], which accepts every parent origin.
2

Add the bridge to the parent

Use the same child origin for src and target-origin. The id becomes the parent-side item prefix:
parent.html
The child tool calculate is registered on the parent as calculator_calculate. target-origin restricts messages sent by the parent; the child’s allowedOrigins independently restricts messages it accepts.The allow="tools" attribute delegates the native WebMCP feature to a cross-origin child. It does not create or authorize the MCP-B transport.
3

Verify the parent tool

After mcp-iframe-ready fires, inspect the parent context:
List parent tools
Use a different id for every <mcp-iframe> so bridged names remain unique. The element refreshes its registrations when the child advertises supported list_changed notifications.
Opaque iframe origins require target-origin="*". That disables parent-side origin validation, so prefer a non-opaque iframe and exact origins. Do not use a wildcard merely to work around an origin mismatch.