DEV Community

Cover image for WebMCP in Practice - Turn an HTML Form into an Agent Tool

WebMCP in Practice - Turn an HTML Form into an Agent Tool

Luca Del Puppo on November 16, 2026

In Part 01, we built DevDesk, a small task board. Today, let's give an agent a way to prepare a task using the form already on the page. In the de...
Collapse
 
gautamtalksdev profile image
Gautam K •

Letting the agent fill the form while the person keeps the submit button is the right default. The edge case I'd test: hidden or off screen fields. If the form has a hidden input, say an assignee or a webhook URL, can the agent set it through the tool without it ever showing up in the fields the person reviews? Highlighting every field the agent changed before submit, including hidden ones, would close that.

Collapse
 
puppo profile image
Luca Del Puppo Playful Programming •

Great catch! You're pointing at a very real human-in-the-loop edge case.
In Chrome's current experimental implementation of declarative WebMCP, standard elements are excluded from the generated tool schema (since they are meant for app-managed state like CSRF tokens or IDs rather than user input), so the agent can't set them directly.
However, your concern is spot-on for CSS-hidden, off-screen, or collapsed fields (like inputs inside closed accordions or tabs): because those are standard form controls in the DOM, the browser exposes them as parameters, meaning an agent could populate them out of the user's sight.
Two practical ways to close that gap right now:

  • Keep sensitive or non-reviewable values out of the form inputs and attach them inside the submit handler instead.
  • Surface agent changes explicitly before submission—for instance, using the toolactivated event (or tracking dirty fields) to highlight modified inputs or show a quick summary of what the agent populated before the user hits submit.

Definitely something worth testing as the declarative spec evolves!

Collapse
 
gautamtalksdev profile image
Gautam K •

Thanks for the detail on how hidden inputs are excluded from the schema. The CSS hidden and collapsed field case is the one I'd test first, since the user never sees what was filled.

Collapse
 
aheadkit profile image
AheadKit •

One detail worth underlining for anyone copying this pattern: the form's markup IS the tool schema, so the schema can only be as strict as the HTML. Your priority field works because it is a select with fixed options. Your project field is a free-text input, which means the agent has to guess a valid project name — and if createTask rejects unknown projects, that rejection arrives as a plain string through respondWith() after the human has already reviewed and submitted. The failure lands after the review step, not before it.

The fix costs nothing: wherever the server has an enum, put it in the markup — a select, or a datalist on the text input so the agent sees the allowed values while the user keeps free typing. That one habit is what keeps a declarative tool honest: everything the agent needs to succeed has to be visible in the form itself, because there is no second channel to ask.

Collapse
 
puppo profile image
Luca Del Puppo Playful Programming •

Yes, that's true :) But spoiler: we will have a dedicated article for the error state :)

Collapse
 
aheadkit profile image
AheadKit •

Ha, good — that's the bit I was most curious about, since the rejection only shows up after the human already reviewed it. Will it cover the timing of it, or mostly the error shape itself?

Thread Thread
 
puppo profile image
Luca Del Puppo Playful Programming •

How to handle errors. And some best practices

Collapse
 
paullovelace profile image
Paul Lovelace •

What I liked most is that the agent flow reuses the exact same submit path and createTask operation — the form isn't a second implementation of task creation, it's just another way in. And respondWith() returning plain strings for both success and validation failure feels like the right level of honesty to the agent. No separate happy-path story, no separate error story.

Collapse
 
puppo profile image
Luca Del Puppo Playful Programming •

Yes, that's what I like as well 😃

Collapse
 
mp3sss31 profile image
mp3sss •

Reusing the existing form as the tool schema is a neat shortcut: the field labels, required flags, and validation rules already encode what the agent is allowed to set, so you avoid maintaining a parallel tool definition that drifts out of sync. In a desktop app the same idea fits a settings or submission view - expose it to a helper agent, but keep the human confirm step before the state-changing submit fires. Since this declarative API is still experimental, it's worth guarding the tool surface behind a feature flag so a browser spec change doesn't silently strip the annotations.

Collapse
 
mudassirworks profile image
Mudassir Khan •

leaving out toolautosubmit is the part that makes this usable. the form stays a proposal and the human review step is just the existing UI, so there is no extra approval layer to build.

the respondWith note caught my eye too. a plain string saying the task was created, when it may only live in memory after a storage failure, is exactly how agents end up reporting success on writes that never landed. we moved to returning a structured status with a persisted flag so the agent can tell accepted from saved.

will the structured outcomes in the later chapter carry a persisted flag, or just success and failure?