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 demo, I tell the agent I need to review the DevDesk changelog ASAP. The agent can turn that request into a task title, a project, and a priority. You get to check those fields, edit anything that looks wrong, and decide whether to submit.
We'll use Chrome's experimental declarative WebMCP API. It adds annotations to HTML forms so a supporting browser can expose them as tools. This form API is being explored separately from the WebMCP Community Group's imperative API draft; details and browser support can change. See Chrome's declarative API guide for the current behavior.
Run this chapter
The Part 02 demo branch contains the complete example. With Node.js 26 or later installed, check out that branch and start DevDesk.
git clone https://github.com/Puppo/webmcp-in-practice.git
cd webmcp-in-practice
git checkout part-02-declarative-form
npm ci
npm run dev
Open the URL printed by Vite. The form works by hand in an ordinary browser: enter a title and project, select a priority, and click Add task. To try the agent flow, use a browser and agent setup that supports the experimental declarative API; check Chrome's current documentation for its availability and setup. Inspect the tools actually available to the agent and look for create_task. The presence of a model context API alone doesn't prove this form was registered or that declarative forms are supported.
Describe the form as a tool
Here's the form from the demo:
<form
id="task-form"
toolname="create_task"
tooldescription="Prepare a task for review and creation. Use when the user wants to add a task."
>
<label for="task-title">Title
<input
id="task-title"
name="title"
placeholder="e.g. Review the changelog"
required
/>
</label>
<label for="task-project">Project
<input id="task-project" name="project" placeholder="e.g. DevDesk" required />
</label>
<label for="task-priority">Priority
<select id="task-priority" name="priority">
<option value="low">Low</option>
<option value="medium" selected>Medium</option>
<option value="high">High</option>
</select>
</label>
<button class="primary-button" type="submit">
<span aria-hidden="true">+</span> Add task
</button>
</form>
toolname gives the action a stable name, and tooldescription explains when to use it. The controls' name attributes identify the inputs: title, project, and priority. Their labels describe the fields, required marks title and project as required, and the select provides the allowed priority choices, with medium selected initially. Chrome also supports toolparamdescription when a field needs a more explicit description; this demo uses its labels.
Notice what's missing: toolautosubmit. In the documented flow, the browser can fill and focus the form, but the person must submit it. Review the values, change them if needed, and choose Add task when ready. You can also cancel the agent operation instead of submitting. Until submission, the form is a proposal, not a new task.
The form itself declares create_task. We don't also register an imperative tool with the same name: one action has one entry point here. The existing submit handler still owns the application behavior.
The form with example values before submission. These values were entered manually to illustrate what you would review.
Keep the existing submit path
The handler reads the form and passes its values to the same createTask operation used by the app. This is the actual submit handler:
form.addEventListener('submit', event => {
event.preventDefault()
const fields = new FormData(form)
const result = createTask(
tasks,
{
title: fields.get('title'),
project: fields.get('project'),
priority: fields.get('priority'),
},
`DD-${crypto.randomUUID()}`,
)
if (!result.ok) {
if (event.agentInvoked) event.respondWith(Promise.resolve(result.message))
formError.textContent = result.message
formError.hidden = false
return
}
clearFormError()
form.reset()
updateBoard(result.tasks, `Added ${result.task.title} to To do.`)
titleInput.focus()
if (event.agentInvoked) {
event.respondWith(
Promise.resolve(`Created ${result.task.id}: ${result.task.title}.`),
)
}
})
preventDefault() stops the normal navigation. The task operation validates the values and returns either an error or the updated task list. On success, the page resets the form and updates the board. On failure, it displays the validation message.
For a submission reported as agent-invoked, the handler also calls respondWith() with a promise containing a message for the agent. Both success and validation failure are plain strings in this example; the error isn't a structured error response. Also, the success message says the task was created, not that it was durably saved. If browser storage fails, DevDesk keeps the change in memory and shows a warning, but the task may disappear on reload. We'll give agent outcomes more structure in a later chapter.
Try the review step
Try it with Chrome’s WebMCP extension
You can use the example WebMCP extension from GoogleChromeLabs as your agent. The extension requires Node.js 22.18 or later and Chrome 155 or later with chrome://flags/#enable-webmcp-testing enabled. In the extension checkout, copy .env.example to .env, choose a MODEL and set its provider key. Run npm install and npm run server, then run npm run build in another terminal. Open chrome://extensions, enable Developer mode , and use Load unpacked to select the extension’s dist/ directory. Extension setup
Open the extension’s side panel on the running DevDesk tab and look for create_task in the tools list. Then try the prompt from the video:
I have to review the changelog of the DevDesk project ASAP.
If the extension asks for permission, allow the tool call. That lets the agent fill the form. You still decide whether to submit it on the page. Check the proposed title and confirm that the project is DevDesk and the priority is high. Edit a value before submitting, then confirm the task that appears on the board reflects your final choice. Try another request and cancel it: no new task should be created from that cancelled operation.
You can still test creation and validation manually when the experimental tool isn't available. The demo’s automated tests cover the application code. Use the side-panel exercise to check tool discovery and the review step in your browser.
Next, we'll use imperative tools to list tasks and change a task's status by ID. For now, one ordinary form gives us a useful boundary: the agent prepares the details, and you decide when to create the task.

Top comments (4)
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.
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:
Definitely something worth testing as the declarative spec evolves!
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.
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.