---
description: "Returns a string of what WebMCP sees of a tool."
---

# `webToolSignature`

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`](/docs/reference/core/register-web-tool).

## Import

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

## Example

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

```ts title="signature.ts"
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`](/docs/reference/core/define-web-tool). |

## 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`](/docs/reference/core/create-tool-registry) uses it in `update(catalog)`, and [`useWebTool`](/docs/reference/react/use-web-tool) uses it to decide when to re-register.

## See also

- [Define a tool](/docs/build/define-a-tool), what a definition holds
- [`createToolRegistry`](/docs/reference/core/create-tool-registry), which compares signatures
- [`defineWebTool`](/docs/reference/core/define-web-tool), the definition it reads
- [Tool lifecycle](/docs/concepts/tool-lifecycle), why a changed tool cancels calls
