In the demo, I ask the agent to move “Write release notes.” There are two cards called Write release notes on the DevDesk board. The one we want is DD-104. The other is DD-101 and belongs to DevDesk. If we offer an action that takes a title and picks the first match, we’ve already made the wrong choice before the agent gets a say.
In Part 02, we gave the agent a way to prepare a task in the existing HTML form. This time, we’ll register two JavaScript tools. One reads the board and returns matching tasks. The other updates a task whose ID the caller already knows. Part 02 — Turn an HTML Form into an Agent Tool
Run DevDesk
Use Node.js 26 or later and check out the branch for this chapter. If you already cloned the repository, fetch the branch and switch to it. Part 03 demo
git clone https://github.com/Puppo/webmcp-in-practice.git
cd webmcp-in-practice
git checkout part-03-imperative-tools
npm ci
npm run dev
Open the URL printed by Vite. The board’s manual controls work in a modern browser. For native tool discovery and invocation, follow Chrome’s current setup instructions and check that your browser or inspector can see both imperative tools. Confirm Reset example board if you’ve used another chapter on the same local origin and want to restore the fixtures. Chrome’s imperative WebMCP guide
Find first, then change
list_tasks accepts three optional filters. project matches the whole project name ignoring case, query matches part of the title ignoring case, and status matches a board status. With no filters it returns the current board. Matching tasks include their IDs alongside the project and title. Tool definitions
Start with this input to list_tasks:
{ "query": "Write release notes" }
On a reset board you’ll get both release-notes tasks. If that’s all the user told you, ask which project they mean. If they said Design System, include that project in the query or use it to select the matching result. Once you have the ID, pass it to set_task_status:
{ "taskId": "DD-104", "status": "done" }
Keeping lookup separate gives an agent a way to inspect the board before committing to an update. It also lets someone ask what’s still in progress without touching any tasks. The ID makes the update precise once the target is known. The user’s words and the lookup results still determine which target to choose.
Register the update
The tool definition describes its inputs and implements what happens when it’s called. Here’s the set_task_status entry from the demo’s tool array. Source
{
name: 'set_task_status',
description:
'Update a known task by its ID. Find the task first if its identity is unclear.',
inputSchema: {
type: 'object',
properties: {
taskId: {
type: 'string',
description: 'The unique task ID.',
},
status: {
type: 'string',
enum: statuses,
},
},
required: ['taskId', 'status'],
additionalProperties: false,
},
annotations: {
untrustedContentHint: true,
},
async execute(input) {
if (typeof input.taskId !== 'string') {
return output({ error: 'Provide a task ID.' })
}
const result = setTaskStatus(
board.getTasks(),
input.taskId,
input.status,
)
if (!result.ok) {
return output({ error: result.message })
}
board.update(result.tasks, `Updated ${result.task.title}.`)
return output(result.task)
},
},
The schema exposes the required arguments and supported status values. The callback checks the ID type at runtime, and setTaskStatus checks the status and whether the ID exists. output wraps the result as a text content item containing JSON. At this checkpoint, a successful response returns the updated task. The page can warn when storage fails, but the tool response gives the caller no storage status yet.
The page passes document.modelContext to the registration function. When the interface is present, the demo registers each tool with an abort signal, logs a registration rejection unless cleanup is underway, and aborts the signal when Vite disposes the module during a development update. A page that re-registers tools as its views change can use the same signal pattern to retire old definitions. Page setup · WebMCP draft
Use the same board from both entry points
The callback calls board.getTasks() at invocation time. If you change a card by hand after the tools register, the next tool call sees the current tasks. Both the dropdown and the tool call setTaskStatus. A successful update goes through the same page function, which updates the in-memory board, attempts to save it, and redraws the cards. Board state · Page setup
The video starts with a request that leaves the project and destination open:
Move the Write release notes
The agent finds two cards with that title, one in DevDesk and one in Design System , and asks which one I want to move. I reply with the project and destination:
The design one to the Done column
Here, “the design one” refers to the Design System card. The follow-up gives the agent enough information to move that card to Done.
To check the underlying tool behavior yourself, try the two calls above and list the release-notes tasks again. On a fresh board, DD-104 should be in Done and DD-101 should still be in To do. Change DD-104 by hand and list again to check that the tool reads the updated board. The automated tests exercise these handlers with a mocked model context. The video shows one run of the clarification flow. Tool tests
The expected board after updating DD-104. The screenshot uses the demo’s tool handler with mocked registration.
Next, we’ll see what happens when a valid ID goes stale between the two calls.

Top comments (2)
Separating
list_tasksfromset_task_statusmakes the DD-104/DD-101 ambiguity visible before a write, and routing both UI and tool throughsetTaskStatusavoids two business rules. For the stale-ID chapter, I would test a revision precondition as well as the ID: a task can still exist after its status changed. I would also distinguish “board updated in memory” from “saved to storage,” since this response currently returns the task even if persistence fails. Are those the two failure cases you plan to exercise?Two cards with the same name is the perfect demo, because that's exactly where an agent picks the wrong one. Asking which one when there's a duplicate, instead of guessing, is the behaviour I'd want from WebMCP tools.