Skip to main content
The authoritative API definition is the W3C WebMCP specification.

Canonical surface

New code uses document.modelContext.
MemberPurpose
registerTool(tool, { signal })Publish a tool and bind its lifetime to an optional abort signal
getTools()Discover registered tool objects
executeTool(tool, inputJson, options?)Execute a tool object returned by getTools()
toolchangeNotify consumers that available tools changed
const controller = new AbortController();

document.modelContext.registerTool(tool, {
  signal: controller.signal,
});

controller.abort();

Compatibility

  • navigator.modelContext is a deprecated alias for migration.
  • navigator.modelContextTesting is a compatibility surface for testing.
  • listTools(), callTool(), prompts, resources, sampling, elicitation, and transports are MCP-B extensions.
See @mcp-b/webmcp-polyfill for the portable strict runtime.