Skip to content

Add webmcp gen skill#133

Merged
shrey150 merged 9 commits into
mainfrom
add-webmcp-gen-skill
Jun 18, 2026
Merged

Add webmcp gen skill#133
shrey150 merged 9 commits into
mainfrom
add-webmcp-gen-skill

Conversation

@shrey150

@shrey150 shrey150 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a webmcp-gen skill that authors site-specific WebMCP tools: write a manifest.json for a target URL, compile it to a webmcp.init.js init script, and validate that Chrome actually registers and invokes the tools.
  • Workflow is four small Node scripts: scaffold.mjs (creates the artifact dir + starter manifest), compile.mjs (manifest → init script), generate-stagehand-example.mjs (runnable example), and validate.mjs (drives Chrome with --enable-features=WebMCPTesting,DevToolsWebMCPSupport via local Stagehand and checks registration + invocation against fixture input).
  • Page exploration uses the browse CLI (browse open --local, browse snapshot, browse get ...); the manifest is the source of truth and the agent iterates on it from eval.json / eval-report.md output.
  • The skill calls no nested agent and ships authoring rules for safe in-page tool implementations (browser-native APIs only, JSON-serializable returns, defensive { success: false, error } handling, no secrets/eval).

E2E Test Matrix

Command / flow Observed output Confidence / sufficiency
cd <skill dir> && pnpm install Packages: +234 ... + @browserbasehq/stagehand 3.6.0-alpha-fd42e65... / Done in 1.7s using pnpm v10.21.0 Proves the lockfile resolves and the pinned Stagehand dep installs cleanly from scratch in the skill dir. Doesn't prove behavior on other Node/pnpm versions.
node scripts/scaffold.mjs example.com/page-context --url https://example.com Created WebMCP artifact at <artifact dir>; starter manifest.json (914 B) with an example_com_page_context tool, inputSchema, implementation.source, and fixtureInput matching the SKILL.md manifest contract Proves the documented scaffold command and slug format work and emit a contract-conformant starter manifest. Single-tool happy path only; slug-validation edge cases not exercised.
browse open https://example.com --localbrowse snapshot / browse get title / browse get url / browse get text bodybrowse stop {"mode": "managed-local", ..., "title": "Example Domain"}; snapshot a11y tree showed heading: Example Domain, intro paragraph, link: Learn morehttps://iana.org/domains/example; {"stopped": true} Proves the exploration steps in SKILL.md run as written with a globally installed browse and yield enough structure to author the manifest. Only the documented read-only commands were used.
Edit manifest.json (authored from exploration), then node scripts/compile.mjs <artifact dir> Compiled WebMCP artifact at <artifact dir>; webmcp.init.js produced (2628 B) Proves compile accepts a hand-authored manifest (multi-statement source with defensive missing-element handling) and emits the init script. Manifest-schema rejection paths not exercised.
node scripts/generate-stagehand-example.mjs <artifact dir> Generated Stagehand example at <artifact dir>/stagehand-example.ts, wired to env: "LOCAL" with the WebMCP Chrome flags and the manifest's expected tools/fixtures Proves generation emits a TypeScript example (matching create-browser-app / browserbase/templates). Runnability proven separately in the last row.
node scripts/validate.mjs <artifact dir> Validation passed: <artifact dir> / - example_com_page_context: found=true invoked=true status=Completed; eval.json status: "passed" with real invocation output: {"title": "Example Domain", "url": "https://example.com/", "heading": "Example Domain", "intro": "This domain is for use in documentation...", "link": {"text": "Learn more", "href": "https://iana.org/domains/example"}} and the fixture echo round-tripped; eval-report.md written The core proof: a real local Chrome launched with WebMCP flags registered the compiled tool and invoked it with fixture input, returning live page data (including fields only present in the hand-authored manifest, not the scaffold default). Passed first try, no env vars needed. Failure/iteration loop (step 8) not exercised since nothing failed.
npx tsx <artifact dir>/stagehand-example.ts Found 1 WebMCP tools: ... Invocation result for example_com_page_context: "status": "Completed", "success": true with live page payload (title: "Example Domain", url, …) Proves the generated .ts example runs standalone via tsx (the create-browser-app/templates runner), reusing the skill's installed Stagehand. Re-verified after the .mjs.ts switch.

🤖 Generated with Claude Code


Note

Low Risk
Additive skill and docs with local-only browser validation; no changes to existing runtime paths. Main caveat is reliance on a pinned Stagehand alpha and WebMCP Chrome flags.

Overview
Adds a new webmcp-gen skill and registers it in the Claude plugin marketplace and README. Agents can scaffold per-site artifacts (<domain>/<task>), author a manifest.json, compile webmcp.init.js, and validate registration/invocation in local Chrome via Stagehand with WebMCP testing flags.

The pipeline is four Node scripts: scaffold.mjs (starter manifest + slug validation), compile.mjs (manifest → init script with timeouts, top-frame-only registration, and static checks for eval/Playwright-style code), generate-stagehand-example.mjs (runnable demo), and validate.mjs (lists/invokes tools against fixture input and writes eval.json / eval-report.md). SKILL.md documents the workflow, manifest contract, and in-page authoring rules (browser APIs only, no secrets). The skill pins @browserbasehq/stagehand via package.json and pnpm-lock.yaml.

Reviewed by Cursor Bugbot for commit 031ecb9. Bugbot is set up for automated code reviews on this repo. Configure here.

seanmcguire12 and others added 3 commits June 10, 2026 14:35
- allowed-tools: space-separated list (matches ui-test style)
- compatibility: include install commands (pnpm install, npm install -g browse)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@shrey150

Copy link
Copy Markdown
Contributor Author

Standards-conformance pass on skills/webmcp-gen (pattern-matched against skills/browser and skills/ui-test).

Pushed 22f06a3:

  • allowed-tools → space-separated (Bash Read Grep Edit Write), matching ui-test style
  • compatibility → now includes the install commands the workflow actually needs (pnpm install in the skill dir; browse CLI via npm install -g browse)

Audited, no changes needed:

  • LICENSE.txt byte-identical to skills/browser/LICENSE.txt (MIT, Copyright (c) 2026 Browserbase, Inc.)
  • README table row present, wording consistent with other rows
  • .claude-plugin/marketplace.json valid JSON; entry shape matches existing entries
  • No setup.json; package.json + pnpm-lock.yaml follow the autobrowse/cookie-sync precedent
  • No redundant "When to Use" body section
  • Scripts: no secrets or personal paths; documented commands match actual script names/flags (scaffold.mjs also supports an undocumented --out flag)

Left for the author:

  • PR body is empty — needs a description and a real E2E Test Matrix (actual scaffold → compile → validate run output) per house rules; not fabricating one here
  • The PR also removes the autobrowse codegen subsystem (~1.4k deleted lines) — the body should explain that or it should be split out
  • Both pre-existing commits are titled wip
  • package.json pins a Stagehand alpha (3.6.0-alpha-fd42e65…) — confirm that's intended for a public skill before merge

@shrey150 shrey150 marked this pull request as ready for review June 18, 2026 16:59
Comment thread skills/webmcp-gen/scripts/validate.mjs
Comment thread skills/webmcp-gen/scripts/validate.mjs
Comment thread skills/webmcp-gen/scripts/scaffold.mjs
warnings.push(`Tool "${tool.name}" may contain Playwright-style code; WebMCP implementations run in the page.`);
}
if (implementationSource.includes("eval(") || implementationSource.includes("new Function")) {
errors.push(`Tool "${tool.name}" uses eval/new Function.`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substring blocks valid source

Low Severity

Static checks reject implementation.source when it merely contains the substrings eval( or new Function, including inside string literals or comments. Legitimate defensive error text can fail compile even though SKILL.md only forbids actually calling those APIs.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1cdef7c. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged — leaving as-is for now (recommend won't-fix, your call @shrey150). This is a deliberately conservative safety guard: implementation.source is injected into the page and run, so over-blocking anything that looks like eval(/new Function is safer than risking a false negative that lets a real call through. Distinguishing a real call from the same text inside a string/comment would require full JS parsing (AST), which is disproportionate for a Low-severity heuristic. The false-positive is rare (you'd have to literally put eval( or new Function in your in-page source text) and easy to reword. Happy to switch to a word-boundary regex or AST check if you'd prefer.

shrey150 and others added 2 commits June 18, 2026 10:04
…rText

Address Cursor Bugbot review on validate.mjs:
- Empty manifest tools array no longer reports "passed" (vacuous every()
  + 0===0 length check); now pushes an explicit error and requires >0 tools.
- A tool returning { success: false } with an empty errorText is now stored
  as an error and fails validation (|| fallback instead of ?? on "").

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address Cursor Bugbot: parseSlug accepted a ".." segment (e.g. "../task"),
and artifactDirFor resolves with path.resolve, so scaffold could write
outside the artifacts/ tree. Now each slug segment must match
^[A-Za-z0-9][A-Za-z0-9._-]*$, rejecting ".." and leading-dot segments.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread skills/webmcp-gen/scripts/validate.mjs
Address Cursor Bugbot: a manifest with missing/null `tools` made
`manifest.tools.length` throw after the try/finally, crashing before
eval.json/eval-report.md were written. Now validate early-returns a
written "failed" report when `tools` is not an array.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

There are 4 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c4b9560. Configure here.

Comment thread skills/webmcp-gen/scripts/compile.mjs
Comment thread skills/webmcp-gen/scripts/scaffold.mjs
Comment thread skills/webmcp-gen/scripts/validate.mjs Outdated
… tool-list timeout

Address Cursor Bugbot:
- scaffold.mjs toolNameFor now slices to compile.mjs's 1-80 char limit so a
  long slug can't scaffold a manifest that then fails compile.
- validate.mjs listWebMCPTools timeout 1000ms -> 5000ms so slow page loads
  don't false-report tools as unregistered (example uses the default wait).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread skills/webmcp-gen/scripts/generate-stagehand-example.mjs
Match the create-browser-app / browserbase/templates convention (TS examples
run with tsx). The generator now writes stagehand-example.ts (no shebang);
package.json adds tsx/typescript/@types/node devDeps; SKILL.md documents
`npx tsx stagehand-example.ts` and points to `npx create-browser-app` for
turning the demo into a standalone project.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shrey150 shrey150 merged commit 8d4c4cb into main Jun 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants