--- name: build-webmcp-tools description: >- Designs, evaluates, audits, and implements WebMCP tools: client-side tools a web page exposes to in-browser AI agents on document.modelContext, via registerTool, declarative form attributes (toolname, tooldescription), React useWebMCP, or Angular provideExperimentalWebMcpTools. Use when a developer wants to make a website or web app agent-ready, analyze a site or URL for WebMCP user journeys, add or review tools for in-browser agents, write tool schemas, descriptions, annotations, or evals.json, audit existing WebMCP tools, or fix Lighthouse "Agentic browsing" and DevTools WebMCP findings. Not for backend MCP servers over stdio or SSE, or for standalone scraping scripts. --- # WebMCP Tool Development Workflow (`build-webmcp-tools`) WebMCP lets a web page expose client-side capabilities as structured tools to in-browser AI agents on `document.modelContext`, instead of agents scraping or clicking the DOM. This skill routes a developer to the right stage of the tool lifecycle and points to the reference file that holds the detailed rules and code for that stage. **Key tenet**: WebMCP runs **client-side in the browser tab on `document.modelContext`**, inside the user's authenticated session. It supports **Tools only** (no Resources or Prompts). It is **not** a backend MCP server over `stdio`/SSE, and tools execute application logic (state stores, APIs, client routers) directly rather than simulating typing or clicks. ## How to Use This Skill 1. Match the developer's request to a row in the **Router** and go to that stage. 2. **Read the files in the "Read first" column before responding.** Paths are relative to this skill's directory. This file only summarizes them; the detailed rules, examples, and code patterns live in the references, so do not answer from this summary alone. 3. If the request refers to an artifact you were not given (transcripts, `schema.json`, source files), read it if it is available in the workspace; otherwise ask for it, and outline how you will apply the stage's key rules from its reference file (for audits, include the verification steps). Never invent the missing artifact. 4. Apply the **Non-Negotiables** to everything you produce. 5. Before finishing an audit, `schema.json`, or implementation, check your output against [`references/audit-checklist.md`](./references/audit-checklist.md). --- ## Non-Negotiables - **Budgets**: tool and parameter names ≤ 30 chars; tool descriptions ≤ 500 chars; parameter descriptions ≤ 150 chars; output ≤ 1,500 chars (~400 tokens), paginated. → [tool-design.md](./references/tool-design.md) - **Descriptions**: "What + When" (what the tool does, when to choose it); never repeat `inputSchema` parameters; no implementation jargon (Redux, Pinia, Express, REST, GraphQL, gRPC). → [tool-design.md](./references/tool-design.md) - **Naming & shape**: action verbs; `initiate_*` for tools that open a form or wizard vs. `book_*`/`create_*` for immediate execution; never make the model compute values (relative dates, conversions): accept the user's phrasing and resolve it in the app, though unambiguous lookups to standard codes are fine; prefer names over opaque IDs; recommended: consolidate entities that share a lifecycle and annotations into polymorphic, batched tools, keeping trusted and user-authored content in separate tools. → [tool-design.md](./references/tool-design.md) - **Annotations**: all hints default to false and are strictly opt-in (specify only when true; never declare : false); `readOnlyHint: true` only on pure queries; `consequentialHint: true` only on significant, irreversible real-world actions (payments, bookings, deletions); view navigation, tab switching, and `initiate_*` hand-offs must not declare `readOnlyHint: true` (omit it) and do not need `consequentialHint`, protecting unsaved work inside the tool; routine mutating tools omit annotations; `untrustedContentHint: true` on any output containing user- or third-party-authored text, even from your own database. → [annotations.md](./references/annotations.md) - **Errors reach the agent**: React `useWebMCP` throws `Error` (→ `isError: true`); native `registerTool` **resolves** `{ error, code, retryable }` because rejections become a generic `DOMException: UnknownError`; declarative forms resolve structured field errors via `event.respondWith`. → [error-handling.md](./references/error-handling.md) - **UI sync**: await state and DOM updates before a tool returns. - **Cross-origin**: tools are same-origin by default (Permissions Policy `tools`, default `self`); delegate only with `