16 chapters · 94 min
Skills
Chapter 16 of 16
Create, compile, and validate site-specific WebMCP init scripts from a target URL and desired tool capability.
1 minute · 285 words · 5 sections
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.
From the skill directory, install dependencies if they are not already installed:
cd skills/webmcp-gen
pnpm installThis installs the pinned Stagehand package plus the TypeScript toolchain (tsx,
typescript, @types/node) used to run the generated stagehand-example.ts.
<domain>/<task>Example:
example.com/page-contextnode scripts/scaffold.mjs example.com/page-context --url https://example.combrowse CLI:browse open https://example.com --local
browse snapshot
browse get title
browse get url
browse get text body
browse get html bodyPrefer browse snapshot, page text, and DOM inspection over screenshots unless visual layout matters. Use browse stop when exploration is complete.
Edit artifacts/<domain>/<task>/manifest.json. The manifest is the source of truth.
Compile:
node scripts/compile.mjs artifacts/example.com/page-contextstagehand-example.ts) and run it with tsx:node scripts/generate-stagehand-example.mjs artifacts/example.com/page-context
npx tsx artifacts/example.com/page-context/stagehand-example.tsnode scripts/validate.mjs artifacts/example.com/page-contexteval.json and eval-report.md, patch manifest.json, then compile and validate again.{
"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"
implementation.source is inserted inside async (input) => { ... }; write JavaScript statements, not a full function wrapper.document, location, navigator, and same-origin fetch.implementation.source.document.querySelector and querySelectorAll must receive valid browser CSS selectors only.Array.from(document.querySelectorAll(...)).find((el) => (el.textContent || "").includes("...")).eval or new Function.{ success: false, error: "..." } responses.artifacts/<domain>/<task>/
manifest.json
webmcp.init.js
stagehand-example.ts
eval.json
eval-report.mdTo 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" })).
Install this repository
npx skills add browserbase/skills/plugin marketplace add browserbase/skillsSkills install per repository, not per chapter — the CLI has no documented per-skill form, so we do not print one.
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.
The verbatim description from this skill’s front matter — the string an agent matches on to decide whether to load it.
BashReadGrepEditWriteskills/webmcp-gen/SKILL.mdmain, last pushed 5 August 2026.SKILL.md, not by matching a directory convention. One layout observed: skills/*/SKILL.md.h1 and no skipped levels:.claude-plugin/marketplace.json by Browserbase, declaring 5 plugins. It is read for editorial metadata only — never as the skill index, which is always the repository tree./browserbase/skills.md.md8 files · 91 KB
Everything this skill ships beside its prose. All of it is set here, as subchapters of chapter 16.
Executable code the skill can run.
Everything else published alongside the skill.