DEV Community

Cover image for A WebMCP Tool Is Registered but Failing: Debug the Contract in Chrome

A WebMCP Tool Is Registered but Failing: Debug the Contract in Chrome

Catches subtle schema mismatches early

The agent finds the right tool. Chrome shows a registration. The application still returns INVALID_ARGUMENTS.

That failure is easy to misdiagnose as a model problem. In the companion fixture, it has a simpler cause: the tool advertises an argument called id, while the callback expects eventId. The agent can follow the advertised schema perfectly and still fail.

This article uses that deliberately broken contract to connect Chrome's WebMCP panel, the Chrome DevTools MCP server, and a small TypeScript validation test. The goal is to locate the broken boundary before changing prompts or adding retries.

Build a failure that has one explanation

The fixture contains a single synthetic event and one tool, read_event_summary. Its callback accepts exactly one known event identifier. It rejects extra properties and unknown resources.

The broken and corrected schemas differ in one field:

// Broken advertisement
properties: { id: { type: "string" } }
required: ["id"]

// Correct advertisement
properties: { eventId: { type: "string" } }
required: ["eventId"]
Enter fullscreen mode Exit fullscreen mode

These are excerpts from the two complete schema objects in tool.ts. Open the browser fixture with ?broken to expose the first version. Remove that parameter to expose the corrected version.

Before involving an agent, the companion test calls the callback with each argument shape. The advertised id fails; the corrected eventId reads the intended fixture. A third test rejects an unknown resource and extra arguments. All three tests passed locally.

That establishes the application bug independently of any model's tool selection. It does not establish how a particular agent behaves in Chrome.

Read the browser's evidence in order

Chrome documents a WebMCP panel in DevTools. Use it to answer concrete questions: which tools are registered, what schema does the page expose, and what happened when a call executed?

Start with discovery. If the tool is missing, investigate registration timing, component lifetime, document context, and feature configuration. An execution error is irrelevant until the expected registration exists.

Then compare the actual arguments with the callback's validator. A valid JSON object can still violate the application contract. Finally inspect the result and the user-visible state separately. A successful read callback should return the correct event, while a mutation would need an additional check that the intended state changed.

An invocation count has a limited meaning. Zero invocations tells you that the tool was not called in that observation. It does not prove the model never saw or considered the tool.

Debugging branches from discovery to argument validation, callback results, and application effects.

Configure the agent's debugging connection explicitly

The Chrome DevTools agent guide describes using browser tooling to inspect WebMCP. The companion configuration pins chrome-devtools-mcp rather than relying on an unspecified latest version:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": [
        "-y", "chrome-devtools-mcp@1.13.0",
        "--isolated",
        "--categoryExperimentalWebmcp",
        "--chromeArg=--enable-features=WebMCP",
        "--no-usage-statistics"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

The category and browser feature settings do different jobs. One enables the server's WebMCP tooling; the other enables the browser feature in the launched Chrome instance. A supported Chrome installation is still required.

There is a second distinction in the current server's configuration reference. Tools exposed for developer use with debugging: true belong to the experimental third-party category. The ordinary WebMCP category excludes those debugging tools.

At the November 22, 2026 verification point, chrome-devtools-mcp@1.13.0 remains the current registry version. WebMCP debugging is still experimental, so record the Chrome channel and feature configuration with each run.

The package therefore includes a second configuration that adds --categoryExperimentalThirdParty. The page's ?developer parameter marks the fixture tool for debugging, making this difference reproducible. If a tool is visible in one view and absent from another, inspect those settings before rewriting its registration.

Give the debugging agent a bounded task

A useful instruction is concrete enough to check:

Inspect the registered schema for read_event_summary. Call it using the advertised argument. Compare the result with the callback's expected input and identify the smallest contract correction.

Do not ask the agent to “fix all WebMCP problems” in a profile containing unrelated application tabs. Use the isolated profile and local fixture, then inspect the proposed code change. The example requires no provider key for its application code; the agent client may have its own model configuration.

The expected correction is small: change the advertised field and required list to eventId. The application validator stays in place. Removing validation would hide the mismatch and weaken the contract for every caller.

Keep hints separate from enforcement

The fixture marks the tool as read-only. That is useful metadata for clients, but the callback's behavior is what makes the operation read-only. A hint does not authorize a caller, validate arguments, or constrain arbitrary implementation code.

This matters more when moving the pattern into Trip Workbench. An event identifier should be checked against the current application context and server authorization. A debugging tool that happens to receive a valid identifier should not acquire broader access merely because the schema accepts a string.

Keep the example intentionally small: one fixture, one input shape, one result. Once that contract is correct, add resource authorization and state-effect checks at the appropriate application boundaries.

Capture a useful debugging record

The package includes browser steps and a result template for registration, submitted arguments, callback output, and the observed correction. Native DevTools execution has not yet been run for this companion, so no screenshot or transcript is presented as a successful browser session.

When you run it, capture the failing and corrected schemas from the same Chrome version. Include the command-line configuration and whether the tool had debugging: true. That evidence lets another developer distinguish a schema bug from a discovery-category problem.

The larger lesson is practical: make the advertised contract, runtime validator, and observed effect agree before tuning the agent. DevTools becomes much more useful when every inspection step answers one specific question.

Top comments (8)

Collapse
 
dosaygo profile image
dosaygo •

INVALID_ARGUMENTS is the second bug in that fixture. An agent in production has no DevTools panel, only the string your callback hands back. Have the validator say unknown property "id", expected "eventId" and the agent fixes its own call on the next turn.

Collapse
 
x1y1co profile image
X1Y1 •

id vs eventId is nasty because the schema and the callback each look right on their own. Generating the callback's parameter type from the advertised schema, instead of writing both by hand, would make this a compile error.

Collapse
 
raju_dandigam profile image
Raju Dandigam Google Developer Experts •

@x1y1co Yes—deriving the callback type from the advertised schema would catch this mismatch during development. I would still keep runtime validation, since browser callers and older registrations do not inherit TypeScript’s checks. A small contract test that exercises the published schema against the callback would cover both boundaries.

Collapse
 
yogin_parmar profile image
Yogin Parmar •

Checking the result and the visible state separately caught us tonight, in a much dumber way. Our run script posted a reply, then searched the page for its own text to confirm it, and found nothing. The reply was there; the site had turned the straight apostrophes into curly ones, so the string match failed. The state check was right to exist, and it was checking the wrong thing.

For mutation tools, do you put the "did the state change" check in the callback's return value, or in a separate read tool the agent calls afterwards?

Collapse
 
raju_dandigam profile image
Raju Dandigam Google Developer Experts •

@yogin_parmar I would return a receipt from the mutation callback—resource ID, accepted version, and any pending status—then verify the effect with a separate read of the authoritative state. The callback can say it accepted a write while a later validation or asynchronous step still fails. For your reply check, a comment ID or parent-child relationship is a stronger signal than exact rendered text, since typography can change after submission.

Collapse
 
yogin_parmar profile image
Yogin Parmar •

That's close to what we moved to tonight. Our reply check now looks for the new comment's ID on the page instead of matching the text. A receipt plus a separate read of the real state is a cleaner way to put it.

Collapse
 
paullovelace profile image
Paul Lovelace •

The receipt idea is the bit that clicked for me — a callback saying "accepted" while a later validation fails is exactly the shape that burns you in production, because the agent walks away happy. I keep thinking about the flip side though: if the validator's error said "unknown property id, expected eventId" instead of just INVALID_ARGUMENTS, the agent fixes its own call next turn without any of this debugging. Is that a deliberate choice in the fixture, to keep the error dumb, or is that how the real validator actually talks?

Collapse
 
andrii_0308f2a18c503d78ec profile image
Andrii •

Thanks for sharing this! One additional improvement would be to add an end-to-end test that invokes the registered tool through Chrome DevTools, rather than testing only the callback directly. This would verify that the exposed JSON Schema, argument serialization, and runtime validation actually work together. Have you considered generating the TypeScript types and runtime validator from a single schema definition to prevent these contract mismatches at compile time?