MAIDR JavaScript API
    Preparing search index...

    Module service/webMcp

    Experimental WebMCP tools: typed functions an in-browser AI agent can call on a page that shows MAIDR charts.

    Tracks the W3C Web Machine Learning Community Group draft at https://webmachinelearning.github.io/webmcp/, which is still moving: the entry point went from navigator.modelContext to document.modelContext, and unregistration from unregisterTool(name) to an AbortSignal. Both variants are detected here, and only here.

    On by default, and a strict no-op wherever the browser has no WebMCP. The reader turns it off with the general.agentTools setting, and a page author with <meta name="maidr-webmcp" content="off">, which wins over the setting. Nothing runs at import. Five tools are exposed: two silent reads of the charts, a cursor move that travels the same path as window.maidrLive.navigateTo but is marked as the agent's, and a silent list of the reader's command-palette commands with a tool that runs one of them through the reader's own command executor. Commands that open a dialog or text field stay the reader's, and nothing writes chart data or settings beyond what a command's own key changes. Keyboard focus moves for an agent in one way only: into the chart, for a move or command whose focus input says the reader asked to be taken there -- never out of a dialog, at most once every 10 seconds on the page, and with nothing made or announced while the page does not have the browser's focus. Otherwise a reader outside the chart meets the move or command when they next enter it.

    Everything a tool returns is rebuilt from plain JSON types and capped, and every string that came from the chart producer sits under content, since a chart's title and labels are text an agent must not take as instructions.

    The feature is contained in this file, its call site, command channel, the agent's mark on a kept target and the focus move in useMaidrController (with LiveDataManager.runCommand, inspectCommands, dropAgentRequests and the byAgent and focus options, which carry them), the settings listener and the command methods in Controller, the setting in GeneralSettings and its row in the settings dialog; deleting those removes it.

    Variables

    TOOL_NAMES
    AGENT_COMMANDS

    Functions

    clip
    sanitizeForAgent
    buildWebMcpTools
    isWebMcpSupported
    acquireWebMcpTools
    setWebMcpEnabled
    resetWebMcpForTests