npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcp-b/mcp-iframe

v5.1.0

Published

Custom element for exposing iframe MCP tools, resources, and prompts to parent page

Readme

@mcp-b/mcp-iframe

Custom element for exposing iframe MCP tools, resources, and prompts to the parent page

npm version License: MIT TypeScript

@mcp-b/mcp-iframe provides <mcp-iframe>, a Web Component that wraps an iframe and automatically bridges its MCP tools, resources, and prompts to the parent page's document.modelContext. Tool and prompt names include the element's id. Resource URIs use an mcp-iframe: wrapper that records the element prefix and child URI.

Installation

pnpm add @mcp-b/mcp-iframe

Both pages must expose document.modelContext. The parent needs the MCP-B resource and prompt extensions from @mcp-b/global when the iframe exposes those capabilities. The deprecated navigator.modelContext surface is used only as a fallback for older runtimes.

Use the default element

<mcp-iframe src="./child-app.html" id="my-app"></mcp-iframe>

<script type="module">
  import '@mcp-b/mcp-iframe';

  const el = document.querySelector('mcp-iframe');
  el.addEventListener('mcp-iframe-ready', (e) => {
    console.log('Exposed tools:', e.detail.tools);
    // e.g. ["my-app_calculate", "my-app_get_data"]
  });
</script>

Importing the package root auto-registers <mcp-iframe>. Tools registered inside the iframe (for example, calculate) appear on the parent as my-app_calculate.

To register a custom tag without registering the default tag, use the side-effect-free entry point:

import { registerMCPIframeElement } from '@mcp-b/mcp-iframe/element';

registerMCPIframeElement('my-mcp-frame');

Attributes

| Attribute | Description | | ------------------ | ---------------------------------------------------------------------------------------------------------- | | src | URL of the iframe page | | id | Used as the tool and prompt name prefix | | target-origin | Override the inferred postMessage target origin. Opaque origins require * | | channel | Channel ID for transport (default: mcp-iframe) | | call-timeout | Timeout in ms for tool calls, resource reads, and prompt gets (default: 30000; invalid values fall back) | | prefix-separator | Separator between prefix and name (default: _; allows letters, numbers, _, ., and -) |

Standard iframe attributes (sandbox, allow, width, height, etc.) are also mirrored.

Scoping which tools the parent sees

A child decides what it advertises. Registering a tool with exposedTo narrows it to named embedder origins, and the child only puts it on the wire once the connected parent matches:

await document.modelContext.registerTool(
  { name: 'checkout', description: 'Place the order', execute: placeOrder },
  { exposedTo: ['https://shop.example'] }
);

Embedded anywhere else, that tool never reaches the parent's exposedTools and cannot be called through the element. Tools registered without exposedTo are unaffected and stay visible to whichever parent the child's transport already allows.

Two limits are worth stating plainly:

  • exposedTo can only narrow exposure. The child transport's allowedOrigins is still what decides who may connect at all, and no allowlist widens past it.
  • Enforcement here is the child's own JavaScript, not the browser. That is weaker than native WebMCP, where the user agent enforces exposedTo and a compromised child cannot opt out. Treat it as scoping, not as a security boundary against the child itself.

Events

| Event | Detail | | -------------------------- | ----------------------------------------------------------------------------------------- | | mcp-iframe-ready | { tools, resources, prompts } - Fired when connected | | mcp-iframe-error | { error } - Fired on connection or registration refresh failure | | mcp-iframe-items-changed | { tools, resources, prompts } - Fired after an advertised list change or manual refresh |

Related Packages

  • @mcp-b/global - Full MCP-B browser runtime; any compatible document.modelContext implementation works in the iframe
  • @mcp-b/transports - Transport layer used internally

License

MIT - see LICENSE for details