webmcp-gen

作者: browserbase

根據目標網址和所需工具能力,建立、編譯並驗證特定網站的 WebMCP 初始化腳本。當使用者想要編寫 WebMCP 工具時使用…

npx skills add https://github.com/browserbase/skills --skill webmcp-gen

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:

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:
<domain>/<task>

Example:

example.com/page-context
  1. Scaffold the artifact:
node scripts/scaffold.mjs example.com/page-context --url https://example.com
  1. Explore the target page with the browse CLI:
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.

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

  2. Compile:

node scripts/compile.mjs artifacts/example.com/page-context
  1. Generate a runnable Stagehand example (stagehand-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.ts
  1. Validate:
node scripts/validate.mjs artifacts/example.com/page-context
  1. If validation fails, inspect eval.json and eval-report.md, patch manifest.json, then compile and validate again.

Manifest contract

{
  "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

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 的更多技能

browse
browserbase
Use the browse CLI for Browserbase browser automation, Browserbase cloud APIs, Browserbase Functions, templates, web fetch/search, diagnostics, and Browse.sh…
official
browser-automation
browserbase
Automate web browser interactions using MCP tools. Use when the user asks to browse websites, navigate web pages, extract data from websites, take screenshots,…
official
functions
browserbase
使用官方 Browserbase Functions CLI 引導無伺服器瀏覽器自動化的部署。當使用者想要部署自動化以在…上執行時使用。
official
agent-experience
browserbase
審核產品、SDK、文檔網站或 SKILL.md 的開發者體驗,方法是投放多個 Claude 子代理,僅附上極簡任務提示和真實…
official
autobrowse
browserbase
透過自動研究循環實現自我改進的瀏覽器自動化。反覆執行瀏覽任務、讀取追蹤記錄,並持續提升導航技能…
official
browse
browserbase
使用 browse CLI 建立和部署瀏覽器自動化功能的完整指南
official
browser
browserbase
使用本地Chrome或遠端Browserbase進行瀏覽器自動化,適用於受保護網站、機器人偵測及CAPTCHA驗證。兩種模式:本地Chrome(預設,無需設定)或遠端Browserbase(反機器人隱蔽、自動CAPTCHA解鎖、住宅代理、會話持久化)。核心指令涵蓋導航、頁面檢查、互動(點擊、輸入、填寫、選擇、拖曳)及透過CLI進行會話管理。使用瀏覽快照讀取無障礙樹並取得元素參考以實現可靠互動;保留...
official
Browser Automation
browserbase
透過CLI指令使用自然語言自動化網頁瀏覽器操作。當使用者要求瀏覽網站、導覽網頁、從中提取資料時使用…
official