webmcp-gen
browserbase/skills
ターゲットURLと必要なツール機能に基づいて、サイト固有のWebMCP初期化スクリプトを作成、コンパイル、および検証します。
...すべて拡張しますWebMCP Gen
マニフェストを作成し、それを初期化スクリプトにコンパイルし、Chrome がそのツールを登録して起動することを検証することで、Webサイト固有の WebMCP ツールを作成します。
このスキルはネストされたエージェントを呼び出しません。ページの探索、manifest.jsonの作成、および検証結果に基づく反復処理は、ユーザー自身の責任で行ってください。
セットアップの確認
スキルディレクトリから、まだインストールされていない依存関係をインストールします:
cd skills/webmcp-genpnpm install
これにより、ピン留めされた Stagehand パッケージと、生成されたstagehand-example.ts を実行するために使用される TypeScript ツールチェーン(tsx、
typescript、@types/node)がインストールされます。
ワークフロー
- スラッシュが1つだけ含まれるアーティファクト・スラッグを選択してください:
/
例:
example.com/page-context
- アーティファクトのスケルトンを作成します:
node scripts/scaffold.mjs example.com/page-context --url https://example.com
browseCLI を使用してターゲットページを閲覧する:
browse open https://example.com --local
browse snapshot
browse get title
browse get url
browse get text body
browse get html body
視覚的なレイアウトが重要でない限り、スクリーンショットよりも`browse snapshot`、ページテキスト、DOM 検査を優先してください。探索が完了したら`browse stop` を使用してください。
artifacts/を編集します。マニフェストが唯一の信頼できる情報源となります。/ /manifest.json コンパイル:
node scripts/compile.mjs artifacts/example.com/page-context
- 実行可能な Stagehand のサンプル(
stagehand-example.ts)を生成し、tsxを使用して実行します:
node scripts/generate-stagehand-example.mjs artifacts/example.com/page-context
npx tsx artifacts/example.com/page-context/stagehand-example.ts
- 検証:
node scripts/validate.mjs artifacts/example.com/page-context
- 検証に失敗した場合は、
eval.jsonおよびeval-report.mdを確認し、manifest.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": "ページコンテキストを返します。",
"inputSchema": {
"type": "object",
"properties": {},
"required": []
},
"implementation": {
"kind": "dom",
"source": "return { success: true, title: document.title, url: location.href };"
},
"fixtureInput": {}
}
]
}
作成ルール
implementation.source はasync (input) => { ... }; の内部に挿入されます。完全な関数ラッパーではなく、JavaScript のステートメントを記述してください。- JSONシリアライズ可能なオブジェクトを返してください。
- WebMCPのコードはブラウザページ内で実行されます。ブラウザネイティブのAPI(
document、location、navigator、および同一オリジンフェッチ)を使用してください。 implementation.source内では、Playwright、Puppeteer、Stagehand、XPath ヘルパー、およびエージェント/ブラウザコマンドを使用しないでください。document.querySelectorおよびquerySelectorAllには、有効なブラウザ CSS セレクタのみを渡してください。- 表示されているテキストを検索するには、
Array.from(document.querySelectorAll(...)).find((el) => (el.textContent || "").includes("...")). を使用してください。 - API キー、ベアラー トークン、Cookie、localStorage のシークレット、またはユーザーの認証情報を含めないでください。
evalやnew Functionは使用しないでください。- ユーザーから明示的に要求された場合を除き、破壊的な操作は避けてください。
- 実装は防御的なものにしてください。要素の欠落をチェックし、構造化された
{ success: false, error: "..." }レスポンスを返してください。 - 生成された初期化スクリプトは、トップフレームにのみ WebMCP ツールを登録します。
出力レイアウト
artifacts///
manifest.json
webmcp.init.js
stagehand-example.ts
eval.json
eval-report.md
この例をスタンドアロンプロジェクトにするには、
npx create-browser-appを使用して Stagehand アプリを生成し、生成されたwebmcp.init.jsをその中に配置します(
page.addInitScript({ path: "webmcp.init.js" }) で読み込みます)。
---
name: webmcp-gen
description: Create, compile, and validate site-specific WebMCP init scripts from a target URL and desired tool capability.
license: MIT
---
# 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" })`).
すべてのファイル
8件のファイルwebmcp-genをインストール
スキルファイルをダウンロードし、.claude/skills/ ディレクトリに解凍してください。
ZIPをダウンロードリポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。
git clone https://github.com/browserbase/skills/tree/main/skills/webmcp-gen # Copy SKILL.md to your .claude/skills/ directory
コピー





家
