document.modelContext. Keep business rules, authorization, and UI updates in the existing
application path.
Install the runtime
For the complete MCP-B runtime, install and import@mcp-b/global before registering tools:
Install the runtime
main.ts
Wrap an existing function
Call the same function used by your interface from the tool handler. Use anAbortSignal to remove
the tool when the capability is no longer available.
cart-tool.ts
removeCartTool() when that state becomes invalid. A later registration can reuse the same tool
name after the previous signal is aborted.
For React components, use the lifecycle-aware hooks in Integrate with your
framework.
Verify the registration
Check the page registry after your registration promise resolves:Browser console
Finish the integration
- Add MCP-B input adapters or structured output in Use input schemas and structured output.
- Follow Chrome’s WebMCP best practices for tool boundaries, names, descriptions, and agent-facing errors.
- Follow Chrome’s secure tools guidance before exposing destructive or externally visible actions.
- If discovery fails, use Debug and troubleshoot to trace the MCP-B runtime and transport.
