add-webmcp-tools

Add, edit, debug, and test WebMCP tools built with webmcp-kit. Use when users ask to create or modify defineTool-based tools, fix missing tools, resolve schema/execution errors, or validate tools in dev panel/native mode.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "add-webmcp-tools" with this command: npx skills add victorhuangwq/webmcp-kit/victorhuangwq-webmcp-kit-add-webmcp-tools

Add WebMCP Tools with webmcp-kit

When to Use This Skill

Use this skill when the request is about WebMCP tools in a website codebase:

  • Add a new tool using defineTool(...)
  • Edit existing tool behavior, schema, or annotations
  • Debug tools that do not appear or fail at runtime
  • Test tools with webmcp-kit dev panel or direct execution

Do not use this skill for unrelated frontend/backend feature work that does not involve WebMCP tool definitions.

Preflight

Run these checks before changing code:

  1. Confirm dependencies and framework
  • Check package.json for webmcp-kit and zod
  • If missing, install with npm install webmcp-kit zod
  1. Find likely tool files
  • Search for existing tools and registration:
    • rg -n "defineTool\(|\.register\(" src
    • rg -n "enableDevMode\(" src
  • Prioritize common locations:
    • src/mcp-tools.ts
    • src/lib/mcp-tools.ts
    • src/mcp/*.ts
  1. Locate app entrypoint
  • Identify where browser app bootstraps and where tool .register() calls belong
  • Ensure enableDevMode() is enabled for local debugging when requested

Playbooks

1) Add New Tool

Entry condition: No existing tool satisfies the requested capability.

Steps:

  1. Create or update the tool module.
  2. Define tool with specific camelCase name and clear description.
  3. Add strict inputSchema with .describe() for every field and .default() for optional defaults.
  4. Implement execute and return either string or response helper (textContent, jsonContent, errorContent).
  5. Register the tool in the app flow with .register().
  6. Verify with dev panel and direct execution.

Reference template:

import { defineTool, jsonContent } from 'webmcp-kit';
import { z } from 'zod';

export const searchProducts = defineTool({
  name: 'searchProducts',
  description: 'Search products by query',
  inputSchema: z.object({
    query: z.string().describe('Search text entered by user'),
    limit: z.number().min(1).max(50).default(10).describe('Maximum results'),
  }),
  execute: async ({ query, limit }) => {
    const results = await db.products.search(query, limit);
    return jsonContent(results);
  },
});

searchProducts.register();

Completion checks:

  • Tool appears in dev panel list
  • Valid inputs execute successfully
  • Invalid inputs return schema validation errors

2) Edit Existing Tool

Entry condition: Tool exists and user requests schema/behavior changes.

Steps:

  1. Update only the target tool definition (description, inputSchema, execute, annotations).
  2. Keep input changes backward-compatible unless user explicitly requests breaking changes.
  3. Re-run dev panel execution with old and new input shapes when relevant.
  4. Confirm .register() path still executes at app startup.

Common edits:

  • Schema constraints (.min(), .max(), .regex(), z.enum(...))
  • Output formatting (jsonContent vs string)
  • Optional params (.optional() / .default())
  • Confirmation hints for sensitive actions

Completion checks:

  • Existing intended flow still works
  • Updated behavior matches user request

3) Debug Missing or Broken Tool

Entry condition: Tool does not show up or throws errors.

Steps:

  1. If tool is missing in panel:
  • Verify .register() executes
  • Verify enableDevMode() runs in browser entry
  • Check browser console for [webmcp-kit] diagnostics
  1. If validation fails:
  • Match failing field to inputSchema
  • Add/adjust bounds, optionals, defaults, descriptions
  1. If execution fails:
  • Isolate failing logic in execute
  • Add guarded error handling and clearer error messages
  1. Confirm environment mode:
  • Native mode: real navigator.modelContext available
  • Mock mode: fallback message is expected and dev panel still works

Expected fallback log (normal in unsupported browsers):

[webmcp-kit] Using mock modelContext for tool "toolName". Native WebMCP not available.

Completion checks:

  • Root cause identified and fixed
  • Tool now appears/executes in expected mode

4) Test Tool (Dev Panel + Direct Execution)

Entry condition: New or changed tool needs verification.

Steps:

  1. Dev panel test:
  • Enable enableDevMode()
  • Open panel, select tool, run with valid and invalid payloads
  1. Direct execution test:
const result = await searchProducts.execute({ query: 'pizza', limit: 5 });
  1. Schema inspection when needed:
console.log(searchProducts.inputSchema); // JSON Schema
console.log(searchProducts.schema);      // original Zod schema

Completion checks:

  • Dev panel path works
  • Direct invocation works
  • Validation errors are understandable

Destructive or Sensitive Actions

For delete/checkout/payment/account changes:

  1. Add annotations: { destructiveHint: true } (or confirmationHint: true)
  2. Request user confirmation in execute before mutation
  3. Return cancellation result when confirmation is denied

Pattern:

const deleteItem = defineTool({
  // ...
  annotations: { destructiveHint: true },
  execute: async (input, agent) => {
    const { confirmed } = await agent.requestUserInteraction({
      prompt: 'Are you sure?',
      type: 'confirmation',
    });
    if (!confirmed) return 'Cancelled';
    // perform mutation
  },
});

Validation Checklist

  • Tool name is specific, camelCase, and action-oriented
  • description explains when an agent should call the tool
  • Every schema field has .describe(...)
  • Optional inputs use .optional() or .default(...)
  • Tool is registered with .register() in startup path
  • enableDevMode() is enabled when local testing is requested
  • Native vs mock behavior is explicitly validated
  • Sensitive actions require confirmation flow

Expected Output

When using this skill, report results in this structure:

  1. Summary
  • What was added/edited/debugged
  1. Files changed
  • Exact paths touched
  • What changed in each file
  1. Verification
  • Commands/tests/manual checks run
  • Native or mock mode used
  1. Remaining risks
  • Open issues, follow-up tests, or assumptions

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Web3

precog

Trade on prediction markets. Create a local wallet, list markets, check prices, buy and sell outcome shares. Coming soon: create and fund markets directly from this skill.

Archived SourceRecently Updated
Web3

china-sportswear-outdoor-sourcing

Comprehensive sportswear and outdoor equipment sourcing guide for international buyers – provides detailed information about China's athletic apparel, footwear, outdoor gear, and accessories manufacturing clusters, supply chain structure, regional specializations, and industry trends (2026 updated).

Archived SourceRecently Updated
Web3

china-lighting-sourcing

Comprehensive lighting industry sourcing guide for international buyers – provides detailed information about China's LED, smart, outdoor, automotive, and specialty lighting manufacturing clusters, supply chain structure, regional specializations, and industry trends (2026 updated).

Archived SourceRecently Updated
Web3

china-furniture-sourcing

Comprehensive furniture industry sourcing guide for international buyers – provides detailed information about China's residential, office, hotel, outdoor, and custom furniture manufacturing clusters, supply chain structure, regional specializations, and industry trends (2026 updated).

Archived SourceRecently Updated