<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/globalwhen you also need prompts and resources. - The child runs an MCP server connected to
IframeChildTransport.@mcp-b/globalsupplies both pieces automatically when it runs inside an iframe. A standalonedocument.modelContextimplementation 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 Inside an iframe,
@mcp-b/global in the child page:child-app.html
@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 The child tool
src and target-origin. The id becomes the
parent-side item prefix:parent.html
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 Use a different
mcp-iframe-ready fires, inspect the parent context:List parent tools
id for every <mcp-iframe> so bridged names remain unique.
The element refreshes its registrations when the child advertises supported
list_changed notifications.Related pages
- mcp-iframe reference for attributes, events, lifecycle, and programmatic registration
- Transports reference for
IframeParentTransportandIframeChildTransport - WebMCP API sources for native
exposedToandfromOrigins - Transports and bridges for the architectural boundary
