Skip to main content
skill CX Codex

webmcp-gen — Claude Code skill: WebMCP tools for a site

Writes a WebMCP tool manifest for a specific site, compiles it into an init script, and checks that Chrome registers and invokes the tools.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add browserbase/skills --skill webmcp-gen -a claude-code
Open on GitHub

What webmcp-gen does

The skill walks you through the loop: pick a slug shaped like <domain>/<task>, scaffold the artifact, explore the page with the browse CLI, describe tools in manifest.json, compile to webmcp.init.js, then validate. There is no nested agent here — you explore the page and edit the manifest yourself, the skill supplies the scripts and the rules.

Under the hood sit scripts/scaffold.mjs, scripts/compile.mjs, scripts/generate-stagehand-example.mjs and scripts/validate.mjs. The generated stagehand-example.ts runs through tsx. Tool code executes inside the page, so implementation.source gets browser APIs only: document, location, navigator and same-origin fetch. Playwright, Puppeteer and Stagehand do not work there — worth checking before you compile.

You need Node 18+, Chrome or Chromium with WebMCP testing flags, and the browse CLI (npm install -g browse). Dependencies install with pnpm install in the skill directory. Keep API keys, tokens, cookies and credentials out of the manifest; eval and new Function are off limits. When validation fails, read eval.json and eval-report.md, patch the manifest, compile and validate again.

What it helps with

  • describe WebMCP tools for one site in a manifest
  • compile a manifest into webmcp.init.js
  • confirm Chrome registers the tools and invokes them
  • get a runnable Stagehand example to launch with tsx
  • trace a failed validation through eval-report.md

Example prompts for the agent

  • generate a WebMCP tool for example.com that returns the page title and URL
  • scaffold the example.com/page-context artifact and compile it to webmcp.init.js
  • run validation on the artifact and show me what failed in eval-report.md

How to install webmcp-gen

1Skills CLI (Vercel)

npx skills add browserbase/skills --skill webmcp-gen -a claude-code

2Manually: put the files in place

~/.claude/skills/webmcp-gen/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/webmcp-gen/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about webmcp-gen

How do I install webmcp-gen in Claude?

Run npx skills add browserbase/skills --skill webmcp-gen -a claude-code. The skill then lives at ~/.claude/skills/webmcp-gen/SKILL.md.

What does webmcp-gen do?

It helps you describe WebMCP tools for a site in manifest.json, compile them into webmcp.init.js, and verify that Chrome registers and invokes the tools.

What does webmcp-gen need to run?

Node 18+, Chrome or Chromium with WebMCP testing flags, and the browse CLI installed via npm install -g browse. Skill dependencies come from pnpm install in its directory.

Source text

SKILL.md · MIT
---
name: webmcp-gen
description: Create, compile, and validate site-specific WebMCP init scripts from a target URL and desired tool capability. Use when the user wants to author WebMCP tools for a website, produce a webmcp.init.js artifact, or test WebMCP registration and invocation through Stagehand.
compatibility: "Requires Node 18+ and Chrome/Chromium with WebMCP testing flags. Run `pnpm install` in the skill directory to install the Stagehand dependency. Page exploration uses the browse CLI (`npm install -g browse`)."
license: MIT
allowed-tools: Bash Read Grep Edit Write
---

# WebMCP Gen

Author website-specific WebMCP tools by writing a manifest, compiling it to an init script, and validating that Chrome registers and invokes the tools.

This skill does not call a nested agent. You are responsible for exploring the page, writing `manifest.json`, and iterating based on validation output.

## Setup check

From the skill directory, install dependencies if they are not already installed:

```bash
cd skills/webmcp-gen
pnpm install
```

This installs the pinned Stagehand package plus the TypeScript toolchain (`tsx`,
`typescript`, `@types/node`) used to run the generated `stagehand-example.ts`.

## Workflow

1. Pick an artifact slug with exactly one slash:

```text
<domain>/<task>
```

Example:

```text
example.com/page-context
```

2. Scaffold the artifact:

```bash
node scripts/scaffold.mjs example.com/page-context --url https://example.com
```

3. Explore the target page with the `browse` CLI:

```bash
browse open https://example.com --local
browse snapshot
browse get title
browse get url
browse get text body
browse get html body
```

Prefer `browse snapshot`, page text, and DOM inspection over screenshots unless visual layout matters. Use `browse stop` when exploration is complete.

4. Edit `artifacts/<domain>/<task>/manifest.json`. The manifest is the source of truth.

5. Compile:

```bash
node scripts/compile.mjs artifacts/example.com/page-context
```

6. Generate a runnable Stagehand example (`stagehand-example.ts`) and run it with `tsx`:

```bash
node scripts/generate-stagehand-example.mjs artifacts/example.com/page-context
npx tsx artifacts/example.com/page-context/stagehand-example.ts
```

7. Validate:

```bash
node scripts/validate.mjs artifacts/example.com/page-context
```

8. If validation fails, inspect `eval.json` and `eval-report.md`, patch `manifest.json`, then compile and validate again.

## Manifest contract

```json
{
  "domain": "example.com",
  "task": "page-context",
  "url": "https://example.com",
  "generatedAt": "2026-06-04T00:00:00.000Z",
  "tools": [
    {
      "name": "example_com_page_context",
      "description": "Returns page context.",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "required": []
      },
      "implementation": {
        "kind": "dom",
        "source": "return { success: true, title: document.title, url: location.href };"
      },
      "fixtureInput": {}
    }
  ]
}
```

## Authoring rules

- `implementation.source` is inserted inside `async (input) => { ... }`; write JavaScript statements, not a full function wrapper.
- Return a JSON-serializable object.
- WebMCP code runs inside the browser page. Use browser-native APIs: `document`, `location`, `navigator`, and same-origin `fetch`.
- Do not use Playwright, Puppeteer, Stagehand, XPath helpers, or agent/browser commands inside `implementation.source`.
- `document.querySelector` and `querySelectorAll` must receive valid browser CSS selectors only.
- To find visible text, use `Array.from(document.querySelectorAll(...)).find((el) => (el.textContent || "").includes("..."))`.
- Do not include API keys, bearer tokens, cookies, localStorage secrets, or user credentials.
- Do not use `eval` or `new Function`.
- Avoid destructive actions unless the user explicitly asked for them.
- Make implementations defensive: check for missing elements and return structured `{ success: false, error: "..." }` responses.
- Generated init scripts register WebMCP tools only in the top frame.

## Output layout

```text
artifacts/<domain>/<task>/
  manifest.json
  webmcp.init.js
  stagehand-example.ts
  eval.json
  eval-report.md
```

To turn the example into a standalone project, scaffold a Stagehand app with
`npx create-browser-app` and drop the generated `webmcp.init.js` into it (load it
with `page.addInitScript({ path: "webmcp.init.js" })`).

© browserbase · MIT · browserbase/skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set16

cookie-sync Syncs cookies from local Chrome into a Browserbase persistent context. This lets the browse CLI run cloud sessions on authenticated websites. CX Codex +1 2,600installs company-research Discovers target B2B companies via Browserbase Search API, evaluates their ICP fit, and outputs a scored research report and CSV. CX Codex +1 2,300installs event-prospecting Takes a conference speakers page URL, extracts people, filters companies by ICP, and outputs an HTML report with person cards explaining why the AE should reach out. CX Codex +1 2,100installs browser-to-api Reads a browser-trace capture and turns it into an OpenAPI 3.1 spec, a fetch client and a coverage report. Useful when the site you are integrating with has no published API docs. CX Codex +1 1,900installs safe-browser The skill builds a local browser agent whose only tool is safe_browser. Requests to hosts outside the allowlist fail at the CDP layer. CX Codex +1 1,700installs agent-experience Tests how AI agents onboard with a product, SDK, documentation site, or SKILL.md using short prompts and real tools. Use it to expose onboarding friction. CX Codex +1 862installs competitor-analysis Research competitors, discover additional candidates, and produce an HTML report with feature and pricing comparisons. Use it when you need public competitive evidence. CX Codex +1 659installs browser-use-to-stagehand Converts browser-use (Python) browser-automation scripts into Stagehand v3 (TypeScript) on Browserbase. Useful when an opaque agent loop should become inspectable code. CX Codex +1 488installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor