Skip to content
Skills Library
AI & agents · Building & coding

webmcp-declarative-forms

/webmcp-declarative-forms

Implement the WebMCP Declarative API — annotate HTML forms with toolname and tooldescription attributes for automatic tool extraction. Use when making existing forms agent-ready with minimal code changes.

Licence
MIT
Last repository change
14.09.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 14.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Implement the WebMCP Declarative API — annotate HTML forms with toolname and tooldescription attributes for automatic tool extraction. Use when making existing forms agent-ready with minimal code changes.

Original author description

Implement the WebMCP Declarative API — annotate HTML forms with toolname and tooldescription attributes for automatic tool extraction. Use when making existing forms agent-ready with minimal code changes.

How it works

  1. Before writing code
  2. Conceptual Architecture
Original SKILL.md headings · 110 lines, 572 words
SKILL.md preview
---
name: webmcp-declarative-forms
description: Implement the WebMCP Declarative API — annotate HTML forms with toolname and tooldescription attributes for automatic tool extraction. Use when making existing forms agent-ready with minimal code changes.
allowed-tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch
---

# WebMCP Declarative Forms

## Before writing code

**Fetch live docs**:
1. Fetch `https://webmachinelearning.github.io/webmcp/` for the declarative form attribute specification
2. Web-search `webmcp declarative form toolname tooldescription HTML attributes` for attribute syntax and behavior
3. Web-search `site:developer.chrome.com webmcp declarative forms` for Chrome implementation details
4. Web-search `webmcp SubmitEvent agentInvoked` for the agent submission event API

## Conceptual Architecture

### What Declarative Forms Are

The Declarative API lets developers make existing HTML forms agent-ready by adding attributes — no JavaScript required for basic cases. Chrome auto-extracts form tools and exposes them to agents.

### HTML Attributes

| Attribute | Applied To | Purpose |
|-----------|-----------|---------|
| `toolname` | `<form>` | Unique tool name (becomes the tool's `name`) |
| `tooldescription` | `<form>` | Natural-language description for the agent |
| Standard `name`, `type` | `<input>`, `<select>`, `<textarea>` | Mapped to JSON Schema properties automatically |

### How It Works

1. Developer adds `toolname` and `tooldescription` to a `<form>` element
2. Browser auto-extracts form fields into a JSON Schema (input names become properties, types are inferred)
3. The form becomes a registered tool visible to agents
4. When an agent invokes the tool, the browser fills the form fields and submits
5. A `SubmitEvent` fires with `agentInvoked` property set to `true`
6. The site can detect agent submissions and handle them accordingly

### Basic Example

```html
<form toolname="searchProducts" tooldescription="Search the product catalog by keyword and price range">
  <label>
    Search: <input name="query" type="text" required />
  </label>
  <label>
    Max Price: <input name="maxPrice" type="number" min="0" />
  </label>
  <label>
    Category:
    <select name="category">
      <option value="all">All</option>
      <option value="electronics">Electronics</option>
      <option value="clothing">Clothing</option>
    </select>
  </label>
  <button type="submit">Search</button>
</form>
```

### Detecting Agent Submissions

```js
form.addEventListener("submit", (event) => {
  if (event.agentInvoked) {
    // Agent submitted this form — handle programmatically
    event.preventDefault();
    const data = new FormData(form);
    handleAgentSearch(Object.fromEntries(data));
  }
  // Otherwise, normal user submission
});
```

### Schema Inference

The browser infers JSON Schema from form fields:
- `<input type="text">` → `{ type: "string" }`
- `<input type="number">` → `{ type: "number" }`
- `<input type="email">` → `{ type: "string", format: "email" }`
- `<input required>` → Added to `required` array
- `<select>` → `{ type: "string", enum: [...options] }`
- `<input type="checkbox">` → `{ type: "boolean" }`

### When to Use Declarative vs Imperative

| Scenario | Recommended |
|----------|-------------|
| Simple search or filter forms | Declarative |
| Legacy server-rendered pages | Declarative |
| Complex multi-step interactions | Imperative |
| Dynamic SPA with state management | Imperative |
| Quick agent enablement of existing forms | Declarative |
| Tools that need user confirmation dialogs | Imperative |
| Both simple and complex on one page | Both |

### Combining Both APIs

A page can use both declarative forms and imperative tools simultaneously:
- Simple forms get `toolname`/`tooldescription` attributes
- Complex interactions use `navigator.modelContext.registerTool()`
- Both appear in the agent's tool list together

### Best Practices

- Use descriptive `toolname` values that clearly identify the action
- Write `tooldescription` for the agent, not the user — explain what the form does and what it returns
- Ensure form field `name` attributes are semantic (`query` not `q`, `maxPrice` not `mp`)
- Handle `agentInvoked` submissions gracefully — return structured data, not HTML redirects
- Test with agents to verify the auto-inferred schema matches expectations
- Add `required` attributes to mandatory fields so the schema reflects them

Fetch the specification for exact attribute names, SubmitEvent properties, and schema inference rules before implementing.

Versions

The database has no other skills named webmcp-declarative-forms.

Database snapshot: 13.11.2026 · package version bcbcbeb91823 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100webmcp
    This skill should be used when the user asks to make a website or web app "WebMCP-compatible", "agent-ready", or usable by in-browser AI agents, or mentions WebMCP, document.modelContext, navigator.modelContext, registerTool, declarative form tools (toolname/tooldescription), or…
  • 100webmcp-context-provider
    Implement the WebMCP provideContext API — bulk tool registration, contextual metadata, page state sharing, and dynamic context updates. Use when providing rich context and multiple tools to agents simultaneously.
  • 100webmcpx
    Add WebMCP tools to a website and check them. Use when a user wants AI agents to use their site, asks about WebMCP, navigator.modelContext or document.modelContext, registerTool, or wants to lint/validate WebMCP tool definitions.
  • 100webmcp-gen
    Build and validate experimental WebMCP tools for an existing web page. Use when an agent needs to expose a site's real workflows as page tools, create webmcp.init.js, define deterministic checks, or compare WebMCP with accessibility-tree automation.
  • 85webmcp
    In-page WebMCP tools (JavaScript functions or HTML tools) for front-ends. Use for Literate AI workflow tasks that expose MCP in the browser page. Inherits the MCP parent; not a second protocol.
  • 100webmcp-setup
    Set up a WebMCP project — enable Chrome flags, install MCP-B polyfill, scaffold tool registration, and configure development environment. Use when starting a new WebMCP-enabled website from scratch.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.