webmcp-tool

Open source

The one kind of traffic your site cannot see

A browser tool invocation does not automatically create a server log entry. Its handler may make requests, but those requests alone do not necessarily identify the originating tool call. Instrument registration, execution and failures explicitly to observe that behavior.

The open-source webmcp-analytics library offers browser instrumentation. Verify its compatibility with your current API and check that the wrapper preserves the tool's result and errors.

See it runningSource on GitHub

One line, including for tools you did not write

The original library example wraps the model-context API instead of asking each tool to report itself. Instrumentation that depends on every tool author remembering a line goes missing exactly where it matters most: the tool added in a hurry, the tool a third-party widget registered, the tool that throws.

Review API compatibility

The current draft exposes document.modelContext; older examples use navigator.modelContext. Inspect the installed library before applying this example. Follow the API migration guide, then test registration and a tool call in the browser. This page does not certify every library version.

npm install github:shufflethis/webmcp-analytics
import { instrumentModelContext } from "webmcp-analytics";

instrumentModelContext({ endpoint: "/api/webmcp-events" });

The wrapper is transparent: return values pass through untouched, and a tool that throws still throws, after the failure is recorded. Analytics that change what the agent receives are a bug in the thing they measure.

What it records, and what it refuses to

RecordedNever recorded
Which tool, how long it took, whether it failedArgument values
Argument shapes — query:string:17Cookies, storage, IP addresses
The shape of the execute contextAny durable identifier
Which registered tools were never calledAnything sent to a third party

A tool argument is whatever a stranger typed at an agent. query:string:17 says a seventeen character query was supplied — which answers what you are asking — while leaving nothing to leak, nothing to anonymise, and nothing that turns the log into personal data. Records go to your own endpoint and stay on your own disk.

The number you cannot get any other way

A tool nobody calls leaves no record to count, so registered, never called cannot be derived from a call log at all — it needs the list of what you registered. It is usually the line worth acting on: a tool an agent never reaches for is either described badly or not worth having.

The open question

Nobody yet knows whether a WebMCP call can be attributed to the agent behind it. The proposal specifies { signal } for the execute context and says nothing about provenance. So no field is guessed at: the shape of that object is recorded, and every key that ever appears is listed. The day a client starts identifying itself, it shows up on the first call rather than after somebody thinks to look for it.

Why we published it

We measure whether sites are ready for agents. Measuring whether the tools they ship are then used is the same question one step later, and nobody could answer it — so keeping the answer private would have been a strange way to argue that the web should be measurable. It is MIT licensed. Fork it, read it, send a patch, or take the idea and build something better.

RepositoryLive demoDashboard