Skip to content
WebMCP Agents
Esc
↑↓navigate↵open⌘Jpreview
On this page

webToolSignature

Returns a string of what WebMCP sees of a tool.

Returns a string of what WebMCP sees of a tool. When it changes, the tool must re-register; when it does not, it must not, because Chrome cancels the calls of a tool whose definition changes. Reach for it when you build your own registration on top of registerWebTool.

Import

import { webToolSignature } from "@webmcp-agents/core";

Example

Re-register a tool only when the definition the agent sees changed.

import { type WebTool, webToolSignature } from "@webmcp-agents/core";

let registered: string | undefined;

/** Re-register only when what the agent sees changed. */
export function needsReregistration(next: WebTool): boolean {
  const signature = webToolSignature(next);
  const changed = signature !== registered;
  registered = signature;
  return changed;
}

Options

webToolSignature(tool).

Name Type Default Description
tool WebTool required The tool to describe, made with defineWebTool.

Returns

A string: JSON.stringify of [id, title, description, jsonSchema, annotations ?? null, !!requireConfirmation, target ?? null], where annotations are the merged hints (the tool’s annotations with its flags written over them), so changing a flag changes the signature.

Notes

  • execute is not part of the signature: a new execute alone needs no re-registration. Neither are match, fill or fields: a registered tool reads them from its latest definition on every call.
  • A locator or selector target is part of the signature. A function target stringifies to null, so swapping one function target for another does not change the signature (the new one is read on the next call).
  • createToolRegistry uses it in update(catalog), and useWebTool uses it to decide when to re-register.

See also

Was this page helpful?