webmcp-polyfill

Set up and use the MCP-B polyfill — vanilla JS and React packages that implement navigator.modelContext for browsers without native WebMCP. Use when developing for browsers that don't yet support WebMCP natively.

17 stars

Best use case

webmcp-polyfill is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Set up and use the MCP-B polyfill — vanilla JS and React packages that implement navigator.modelContext for browsers without native WebMCP. Use when developing for browsers that don't yet support WebMCP natively.

Teams using webmcp-polyfill should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/webmcp-polyfill/SKILL.md --create-dirs "https://raw.githubusercontent.com/OrcaQubits/agentic-commerce-skills-plugins/main/dist/antigravity/webmcp-browser-agents/.agent/skills/webmcp-polyfill/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/webmcp-polyfill/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How webmcp-polyfill Compares

Feature / Agentwebmcp-polyfillStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Set up and use the MCP-B polyfill — vanilla JS and React packages that implement navigator.modelContext for browsers without native WebMCP. Use when developing for browsers that don't yet support WebMCP natively.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# MCP-B Polyfill for WebMCP

## Before writing code

**Fetch live docs**:
1. Web-search `site:github.com mcp-b README` for the polyfill repository, packages, and API documentation
2. Web-search `site:npmjs.com mcp-b` for the latest package names and versions
3. Fetch the MCP-B GitHub README for installation, usage, and React hooks API
4. Web-search `mcp-b polyfill react hooks useMcpServer` for React integration patterns
5. Web-search `mcp-b vanilla javascript navigator.modelContext` for vanilla JS usage

## Conceptual Architecture

### What MCP-B Is

MCP-B (Model Context Protocol for Browser) is an open-source polyfill that implements the `navigator.modelContext` API for browsers without native WebMCP support. It allows developers to build and test WebMCP tools today, regardless of native browser support.

### Why Use the Polyfill

- **Chrome Canary only** — Native WebMCP is behind a flag in Chrome 146+ Canary; most users don't have it
- **Cross-browser** — The polyfill works in any modern browser (Chrome, Firefox, Safari, Edge)
- **Development** — Build and test tools before native support rolls out
- **Production** — Ship WebMCP tools to all users, with graceful enhancement when native support arrives

### Package Structure

MCP-B provides multiple packages (fetch the README for exact names, as they may change):
- **Vanilla JS package** — Direct `navigator.modelContext` polyfill
- **React package** — React hooks (`useMcpServer` and related) for declarative tool registration

### Feature Detection

Check for native WebMCP support and fall back to the polyfill:

```js
if (!navigator.modelContext) {
  // Load MCP-B polyfill
  await import("mcp-b"); // or whatever the current package name is
}

// Now navigator.modelContext is available (native or polyfill)
navigator.modelContext.registerTool({ /* ... */ });
```

### Vanilla JS Usage Pattern

```js
// 1. Import polyfill (if needed)
import "mcp-b";

// 2. Register tools using the standard API
navigator.modelContext.registerTool({
  name: "searchProducts",
  description: "Search the catalog",
  inputSchema: { /* ... */ },
  async execute(input) { /* ... */ }
});
```

### React Hooks Usage Pattern

```jsx
import { useMcpServer } from "mcp-b/react"; // verify package name

function ProductPage() {
  useMcpServer({
    tools: [
      {
        name: "viewProduct",
        description: "View product details",
        inputSchema: { /* ... */ },
        execute: async (input) => { /* ... */ }
      }
    ]
  });

  return <div>Product Page</div>;
}
```

### MCP-B Backend Translation

MCP-B can also translate between client-side WebMCP tools and backend MCP servers:
- Register backend MCP tools as browser-accessible WebMCP tools
- Forward WebMCP tool calls to a backend MCP server
- Handle the protocol translation transparently

### Polyfill vs Native

| Aspect | Native WebMCP | MCP-B Polyfill |
|--------|--------------|----------------|
| **Browser support** | Chrome 146+ Canary (flagged) | Any modern browser |
| **Performance** | Native speed | Slight JS overhead |
| **Permission prompts** | Browser-native UI | Custom/simulated |
| **API surface** | Full spec | May lag behind spec updates |
| **Production readiness** | Not yet (still in preview) | Usable today |

### Progressive Enhancement Strategy

1. Ship the polyfill for broad browser support
2. Detect native WebMCP support at runtime
3. Use native when available, polyfill as fallback
4. Remove polyfill dependency once native support is widespread

### Best Practices

- Always check the MCP-B repo for the latest package names and APIs before installing
- Use feature detection, not browser sniffing, to decide polyfill loading
- Test with both the polyfill and native Chrome to catch behavior differences
- Keep the polyfill updated — APIs may change as the spec evolves
- Consider code-splitting — only load the polyfill for browsers that need it

Fetch the MCP-B README for exact installation commands, import paths, hook names, and API patterns before implementing.

Related Skills

webmcp-user-interaction

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement human-in-the-loop flows with requestUserInteraction() — confirmation dialogs, approval workflows, and user prompts during tool execution. Use when building tools that require user consent before performing actions.

webmcp-tool-schemas

17
from OrcaQubits/agentic-commerce-skills-plugins

Design JSON Schemas for WebMCP tool inputs and outputs — proper types, constraints, nested objects, and agent-friendly documentation. Use when defining or refining tool schemas for agent consumption.

webmcp-tool-annotations

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement WebMCP tool annotations — readOnlyHint, destructiveHint, idempotentHint safety hints that inform browser permission prompts and agent behavior. Use when marking tools with appropriate safety metadata.

webmcp-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test WebMCP tools with AI agents — Chrome DevTools integration, agent testing workflows, tool discovery verification, and end-to-end commerce flow testing. Use when validating that tools work correctly with real AI agents.

webmcp-setup

17
from OrcaQubits/agentic-commerce-skills-plugins

Set up a WebMCP project — enable Chrome flags, install MCP-B polyfill, scaffold tool registration, and configure development environment. Use when starting a new WebMCP-enabled website from scratch.

webmcp-security

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement WebMCP security best practices — permission model, data minimization, honest descriptions, input validation, fingerprinting prevention, and fraud mitigation. Use when auditing or hardening WebMCP tool implementations.

webmcp-register-tool

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement the WebMCP Imperative API — register tools via navigator.modelContext.registerTool() with proper schemas, execute callbacks, and lifecycle management. Use when building dynamic tool registration in JavaScript.

webmcp-mcp-bridge

17
from OrcaQubits/agentic-commerce-skills-plugins

Integrate WebMCP client-side tools with backend MCP servers and UCP endpoints — bridge browser-based agent interactions with server-to-server protocols. Use when connecting front-end WebMCP to existing backend API infrastructure.

webmcp-context-provider

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement the WebMCP provideContext API — bulk tool registration, contextual metadata, page state sharing, and dynamic context updates. Use when providing rich context and multiple tools to agents simultaneously.

webmcp-commerce-tools

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement commerce-specific WebMCP tools — product search, cart management, checkout, returns, subscriptions, and support. Use when building agentic shopping experiences on e-commerce websites.

webmcp-authentication

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement WebMCP authentication patterns — browser session inheritance, cookie-based auth, role-gated tool registration, and conditional tool exposure. Use when managing which tools are available based on user authentication state.

woo-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test WooCommerce extensions — PHPUnit unit/integration tests, WP test suite, WooCommerce test helpers, E2E with Playwright, and WP-CLI test scaffolding. Use when writing tests for WooCommerce plugins or setting up a test environment.