Skip to content
WebMCP Kit
Esc
↑↓navigate↵open⌘Jpreview
On this page

Verify a WebMCP tool

Run a small board app. Check the tool result, visible change, invalid input, and cleanup.

Run the same board app with @nekuda/webmcp-sdk 0.7.1 or directly with native WebMCP. Change its title with the form, then with a WebMCP tool.

This is a hand-written example. Verification does not depend on how the tools were added or which SDK they use.

Tool plan

This is the approved scope for this example:

Item Scope
Tool rename_board
Input title: a nonblank string, up to 80 characters
Action Call the same renameBoard function as the form
Result Return the saved title and update the heading
Availability This page, while the demo session is on
Cleanup End the demo session to unregister the tool
Data In this tab only. Reload to reset.

The demo session is a local flag. It is not real sign-in or proof of access control. In an app, the server must check access for every protected action.

Run it

Use Node.js 20 or later, npm, and Python 3. Download the example and extract it, or run:

curl -fLO https://docs.nekuda.ai/verification-example.tar.gz
tar -xzf verification-example.tar.gz
cd verification
npm ci
npm test
npm start

Open http://127.0.0.1:4174. Select Start demo session. Save a title with the form.

To try native WebMCP, open http://127.0.0.1:4174/?native. This version does not load the SDK. After extracting the download, you can run it without Node.js or npm ci:

cd verification
python3 -m http.server 4174 --bind 127.0.0.1

Both versions use the same form and action. The form works in browsers without WebMCP; the page reports that no WebMCP surface is available. Neither version adds a polyfill. SDK telemetry is off for this example.

Before and after

The existing form calls one action:

const { title } = board.renameBoard({ title: input.value });

The tool calls that same action. It adds no second write path:

const renameTool = {
  name: "rename_board",
  description: "Set the title of this demo board. Return the saved title.",
  inputSchema: {
    type: "object",
    properties: { title: { type: "string", minLength: 1, maxLength: 80 } },
    required: ["title"],
    additionalProperties: false,
  },
  annotations: { readOnlyHint: false },
  execute: renameBoard,
};

The shared action checks input before it changes the title. It rejects blank titles, extra fields, and calls after the demo session ends. The title is rendered as text.

With the SDK, register this definition when the demo session starts:

registration = registerTools([
  defineTool({ stableKey: "board.rename", ...renameTool }),
], { telemetry: false });
await registration.ready;
// When the demo session ends:
registration.unregister();

The native version registers the same definition directly. It uses the browser’s AbortSignal cleanup:

const controller = new AbortController();
await document.modelContext.registerTool({
  ...renameTool,
  async execute(input) {
    return JSON.stringify(await renameTool.execute(input));
  },
}, { signal: controller.signal });
// When the demo session ends:
controller.abort();

The full source also checks whether document.modelContext exists. The native version requires that browser API; it does not fall back to the older navigator.modelContext surface.

The example download includes the full source and its local check.

Check it in a browser

Use a browser with WebMCP enabled. With WebMCP Kit installed, ask your coding agent:

/webmcp-kit:verify http://127.0.0.1:4174

This is a local demo. You may change its board title and start or end
its demo session. Test the steps below. Report observed results.

The verify skill uses the kit’s test browser. See Browser setup.

Repeat the same checks for the native version:

/webmcp-kit:verify http://127.0.0.1:4174/?native
Step Expected result
Load the page. List tools. rename_board is absent.
Start the demo session. List tools. rename_board appears once.
Call it with {"title":"From the agent"}. The result contains From the agent. The heading shows From the agent.
Call it with {"title":" "}. The call fails. The heading stays From the agent.
End the demo session. List tools again. rename_board is absent.
Start the demo session again. List tools. rename_board appears once.

Record the browser version, date, returned result, and visible heading. Save a screenshot after the valid call. Report each step as passed, failed, or not run.

Recorded result

Both versions passed on 12 October 2026 on macOS, using WebMCP Kit 0.9.0’s browser driver (chrome-devtools-mcp 1.10.1) with Chrome 154.0.8037.99:

Check SDK 0.7.1 Native WebMCP
Before the demo session No tools No tools
Start the demo session One rename_board tool One rename_board tool
Call with {"title":"From the agent"} Returned the saved title; heading showed From the agent Returned the saved title; heading showed From the agent
Call with a whitespace-only title Error; heading unchanged Error; heading unchanged
End the demo session Tool removed Tool removed
Restart the demo session One rename_board tool One rename_board tool

The native page loaded no SDK files. Its valid call returned {"title":"From the agent"}; the SDK returned the same JSON inside a text content result. Invalid input produced the expected validation error in both versions.

What the local check proves

npm test checks both registration paths with a stub of the browser API. The SDK path uses the published package. Both paths check the shared action, registration, invalid input, cleanup, calls after the demo session ends, and the unsupported-browser fallback.

It does not launch a browser or prove native tool discovery. The browser steps above are a separate check. Do not report them as passed from npm test alone.

Was this page helpful?