This page is a quick lookup. For the authoritative API shape, read the W3C WebMCP spec and the WebMCP proposal.
navigator.modelContext
The strict imperative WebMCP surface. Owned by the WebMCP specification, not by @mcp-b/* packages.
Methods
The formal spec centers on
registerTool() and unregisterTool(). See the W3C spec for the full ToolDescriptor shape, ContentBlock types, InputSchema constraints, and execution semantics.
Example
From the@mcp-b/webmcp-polyfill README, using only the strict core API:
navigator.modelContextTesting
The testing and inspection companion to navigator.modelContext. Chromium exposes it in the native preview. The MCP-B polyfill can install a compatible shim.
Methods
Key behaviors:
listTools()returns metadata only, not execute functions.inputSchemaon returned tool info is a serialized JSON string, not a parsed object.executeTool()takes a JSON string for ordinary (non-streamed) calls.
Example
Native preview vs polyfill shim
For shim configuration, see @mcp-b/webmcp-polyfill. For end-to-end testing patterns, see Test native and polyfill.
Feature detection
Check for both APIs before use:Where MCP-B begins
The browser standard owns the surface above. MCP-B adds a separate layer on top.
For why the core surface is kept separate from MCP-B additions, see Strict core vs MCP-B extensions.
