Decision flowchart
Ask these questions in order:-
Does the target browser ship
navigator.modelContextnatively? If yes, and that covers your use case, you may not need any package at all. -
Do you need compile-time types without any runtime? Install
@mcp-b/webmcp-typesas a dev dependency. -
Do you need the WebMCP standard in browsers that lack native support, and nothing else? Install
@mcp-b/webmcp-polyfill. -
Do you need MCP bridge transport,
callTool,listTools, prompts, resources, elicitation, or sampling? Install@mcp-b/global. -
Do you need React hooks? Choose
usewebmcpfor strict core, or@mcp-b/react-webmcpfor the full MCP-B surface.
Package comparison
| Package | Runtime | Core API | MCP extensions | Transport | React |
|---|---|---|---|---|---|
@mcp-b/webmcp-types | No | Types only | Types only | No | No |
@mcp-b/webmcp-polyfill | Yes | registerTool, unregisterTool | No | No | No |
@mcp-b/global | Yes | All core methods | callTool, listTools, prompts, resources, elicitation, sampling | Tab + iframe | No |
usewebmcp | Yes | Via hook | No | No | Yes |
@mcp-b/react-webmcp | Yes | Via hook | Full MCP-B surface | Via @mcp-b/global | Yes |
If you want the WebMCP standard only
Install the polyfill. It addsnavigator.modelContext and stays on the strict WebMCP path. It does not add MCP-B extension methods.
main.ts
navigator.modelContext already exists natively, initialization is a no-op.
For type inference on tool arguments, pair the polyfill with @mcp-b/webmcp-types:
If you want the full MCP-B runtime
Install@mcp-b/global. It layers the MCP-B runtime on top of the WebMCP surface.
main.ts
@mcp-b/global auto-initializes on import. It installs the polyfill first, then replaces navigator.modelContext with a BrowserMcpServer that keeps the core behavior and adds MCP-B-only methods such as callTool, listTools, prompts, resources, and transport support.
If you need to customize before initialization (for example, to restrict allowed origins), set options on window.__webModelContextOptions before loading the script:
If you want React hooks
- Strict core (usewebmcp)
- Full MCP-B (@mcp-b/react-webmcp)
CounterTool.tsx
usewebmcp expects navigator.modelContext to exist. Provide it with @mcp-b/webmcp-polyfill or @mcp-b/global.If you only need types
Install@mcp-b/webmcp-types as a dev dependency. It has no runtime code and no side effects.
tsconfig.json to get navigator.modelContext typing:
tsconfig.json
