<wmcp-form>

Wrap a <form> to expose it as one WebMCP tool. Its inputSchema has one property per control name, synthesized the way Chrome's declarative form API does it; calling the tool fills every control through the same validate-and-announce path a direct call would, then focuses the submit button for the person to review and submit.

<wmcp-form name="booking" label="Book a table" expose>
  <form>
    <wmcp-input name="email" label="Email" type="email" required></wmcp-input>
    <wmcp-select name="party" label="Party size">
      <option value="2">2 guests</option>
      <option value="4">4 guests</option>
    </wmcp-select>
    <wmcp-checkbox name="window" label="Window seat"></wmcp-checkbox>
    <wmcp-button type="submit">Book</wmcp-button>
  </form>
</wmcp-form>
<!-- registers one "fill-booking" tool with email, party and window as properties -->

This is the form-level counterpart to per-control expose. A twelve-field checkout becomes one tool call instead of twelve, which is how Chrome's WebMCP guidance says to budget an agent's context, and it is the shape agents are being taught to drive forms with. Controls inside may still carry their own expose when a single field needs to be adjustable on its own.

Element attributes

AttributeTypeDefaultDescription
namestring—Identifier used for the default tool name: fill-<name>, or submit-<name> with auto-submit. Falls back to the form's name or id.
labelstring—Human-readable name of the form; the tool's title and the noun in its description.
auto-submitbooleanfalseSubmit after filling. Off by default: the agent fills, the submit button receives focus, and the person submits. Marks the tool consequentialHint: true.
consequentialbooleanfalseMark the tool consequentialHint: true even without auto-submit.
exposebooleanfalseRegister the WebMCP tool.
tool-namestring—Override the generated tool name.
tool-descriptionstring—Override the generated description.
agent-activeboolean—Reflected (read-only) while an agent call is filling or submitting the form.

The inner <form> may instead carry Chrome's own attributes — toolname, tooldescription, toolautosubmit — and <wmcp-form> reads them. On a browser that implements the declarative API natively, a form annotated that way is left to the browser.

The generated schema

ControlProperty schema
<wmcp-input>, <wmcp-textarea>{ type: 'string' } (number for type="number"), description from label
<wmcp-select>, <wmcp-radio-group>{ type: 'string', enum: [...] } of the live options
<wmcp-checkbox>, <wmcp-switch>{ type: 'boolean' }
native <input>, <select>, <textarea>Chrome's mapping: number/range → number with minimum/maximum, checkbox → boolean, radio group → enum + anyOf { const, title }, <select> → enum + anyOf titled by option text, email/url/date → string with format; description from toolparamdescription, then the <label>, then aria-description

required on a control puts its name in required[]. Hidden, password, file and disabled controls, and buttons, are left out. <wmcp-*> controls contribute their schema through a small public protocol (toolParameterSchema(), applyToolParameter(value), validationMessage), which any custom element can implement to take part.

Tool results

{
  "ok": true,
  "message": "Filled 3 fields. The form is ready for the user to review and submit; it was not submitted.",
  "filled": { "email": "[email protected]", "party": "4", "window": true },
  "ignored": [],
  "invalid": [],
  "submitted": false,
  "autoSubmit": false
}

A control that fails validation after filling (its required, native constraints, or a Standard Schema on a <wmcp-*> control) comes back in invalid with its message and ok: false, and an auto-submit form is not submitted. Properties that match no control are listed in ignored. With auto-submit, submitted reports whether the form's submit event really fired, the same truthful contract as <wmcp-button type="submit">.

Agent activity

While an agent call runs, the element reflects agent-active, and the inner form carries tool-form-active (its submit button tool-submit-active) until the form submits or resets. These attributes stand in for Chrome's :tool-form-active and :tool-submit-active pseudo-classes, which cannot be polyfilled; the default style draws a dashed ring around the form:

:root {
  --form-agent-ring: var(--brand);
  --form-agent-ring-width: 2px;
  --form-agent-ring-offset: 4px;
}

The form also dispatches wmcp-tool-call (before filling, detail: { name, input }) and wmcp-tool-result (after, detail: { name, result }), so a page can log, animate, or react to agent-driven changes.

Without the element: exposeForm()

The same behaviour is available for any <form> on any page, with no components, from @webmcpui/webmcp/forms:

import { exposeForm, observeDeclarativeForms } from '@webmcpui/webmcp/forms';

// One form, reading its toolname / tooldescription / toolautosubmit attributes:
const dispose = exposeForm(document.querySelector('form#support')!);

// Or polyfill the declarative API for the whole document:
const stop = observeDeclarativeForms();

This is a polyfill for Chrome's declarative API on top of the imperative one, filling the gap the W3C polyfill leaves open. What stays native-only: SubmitEvent.agentInvoked, SubmitEvent.respondWith(), and the :tool-form-active / :tool-submit-active pseudo-classes. The declarative vocabulary left the WebMCP spec in October 2026 and is maintained as an explainer, so this entry point is kept separate from the core exposure layer.

Accessibility

The element renders a single <slot> and adds no ARIA of its own; the form and its controls keep their native semantics. Focusing the submit button after an agent fills the form tells screen-reader users where the agent left off.