agent-tracking

Guides

How do I track MCP and WebMCP tool calls on my site?

The snippet observes supported browser WebMCP registrations and calls while active, and declarative form submit attempts. It stores tool name, duration, technical outcome and safe error class. Remote MCP calls need their own server adapter.

By · Updated 2026-09-08

Diesen Guide auf Deutsch lesen

Nothing to change in your code

The snippet wraps registerTool and provideContext before your code runs. Register tools as the specification says and they appear in the Tools view. Declarative tools, forms carrying a toolname attribute, are caught on submit.

await navigator.modelContext.registerTool({
  name: "add_to_cart",
  description: "Add a product to the cart by SKU.",
  inputSchema: { type: "object", properties: { sku: { type: "string" }, qty: { type: "integer" } }, required: ["sku"] },
  execute: async ({ sku, qty }) => { /* your code */ },
});

What the Tools view answers

Per tool: calls, success rate, average duration, the top three error messages, whether it is declarative, when it was last seen, and whether it has ever been called. The last one matters most: a tool nobody calls has a description agents do not understand or a schema they cannot fill.

Argument privacy

Tool argument values and arbitrary key names are not stored in the event schema. Inspect schema versions and sanitized error classes for debugging instead.

The manifest

If you publish /.well-known/webmcp, the snippet hashes it once per visit. The dashboard shows when it last changed; on Pro and Agency plans an email goes out when it does, which catches a deploy that silently dropped a tool.

In short

Does it see MCP servers that agents call outside the browser?

The snippet does not. A separate, authenticated server telemetry adapter can report those calls; browser and server observations can overlap.

Can I test it without an agent?

Yes. The demo page has two tools and a simulate button; simulated calls are marked and never counted as agents.