Skip to main content
The authoritative API definition is the WebMCP Community Group draft. Chrome’s current implementation notes live in the Chrome WebMCP imperative API docs.

Canonical surface

New code uses document.modelContext.
Register a tool with abort cleanup
registerTool() returns Promise<void>, and tool cleanup is tied to the optional AbortSignal passed at registration time. Invalid descriptors and duplicate names reject the returned promise, so await registration or handle its rejection. ModelContextTool has the following fields: Registration options are signal, which unregisters the tool when aborted, and exposedTo, an array of origins in the current document tree to which the tool may be exposed. getTools() accepts fromOrigins to include tools from specified origins; without it, discovery is same-origin. getTools() returns RegisteredTool values. They contain name, optional title, description, serialized inputSchema, window, origin, and optional annotations. They do not expose the original execute callback. The API is available only in secure contexts. The tools Permissions Policy defaults to self; cross-origin discovery still requires explicit exposure and policy delegation.

Chrome execution extension

Chrome’s current preview adds executeTool(tool, inputJson, options?). It is not part of the strict WebMCP Community Group draft, so feature-detect it:
Execute a discovered tool in Chrome
The extension accepts a descriptor returned by getTools(), a JSON object or array string, and optional abort options. It resolves to a JSON string or null.

Compatibility

  • navigator.modelContext is a deprecated compatibility alias. Current Chrome exposes document.modelContext only.
  • navigator.modelContextTesting is a removed Chromium preview API retained only by older runtimes and MCP-B/polyfill compatibility shims.
  • listTools(), prompt and resource registration, mcpServer, and transports belong to MCP-B runtimes. Sampling and elicitation remain protocol-specific APIs on the composed official MCP server, not document.modelContext methods.
  • outputSchema is not part of the current W3C/Chrome WebMCP tool dictionary. MCP-B packages expose it as helper metadata for type inference, structured MCP responses, and polyfill/runtime adapters.
See @mcp-b/webmcp-polyfill for the portable strict runtime.