Skip to main content

ModelContextProvider

WebMCP's tool-registration entry point, the value of document.modelContext (Chrome origin trial, see https://webmachinelearning.github.io/webmcp/).

This is an interface exported by @mapcairn/react, checked against version 0.2.0.

Signature​

import type { ModelContextProvider } from "@mapcairn/react";

interface ModelContextProvider

Properties​

registerTool​

registerTool: (tool: {
name: string;
description: string;
inputSchema: Record<string, unknown>;
execute: (input: unknown) => Promise<ModelContextToolResult>;
}, options?: {
signal?: AbortSignal;
}) => Promise<void>;

Registers a tool with the browser. It rejects, or throws, when the page's Permissions-Policy denies tools or the schema is invalid. options.signal removes the tool again when aborted.

Remarks​

The SDK does not add modelContext to the global Document type, because a global augmentation does not survive the built declarations. Type a stub or a read with this interface instead.

See also​

Source: packages/react/src/hooks/useModelContextTool.ts:46