@extension.dev/mcp 3.17.0-canary.1779905934.1151df3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +101 -0
  3. package/bin/extension-mcp.js +3 -0
  4. package/claude/ARCHITECTURE.md +161 -0
  5. package/claude/CLAUDE.md +264 -0
  6. package/claude/README.md +72 -0
  7. package/claude/commands/extension-add.md +63 -0
  8. package/claude/commands/extension-debug.md +43 -0
  9. package/claude/commands/extension-publish.md +62 -0
  10. package/claude/commands/extension.md +76 -0
  11. package/claude/examples/add-sidebar.md +56 -0
  12. package/claude/examples/create-extension.md +49 -0
  13. package/claude/rules/cross-browser.md +84 -0
  14. package/claude/rules/extension-dev.md +83 -0
  15. package/claude/rules/mcp-tools.md +889 -0
  16. package/dist/module.cjs +2979 -0
  17. package/dist/module.d.ts +1 -0
  18. package/dist/rslib.config.d.ts +2 -0
  19. package/dist/src/index.d.ts +1 -0
  20. package/dist/src/lib/act.d.ts +21 -0
  21. package/dist/src/lib/cdp.d.ts +48 -0
  22. package/dist/src/lib/exec.d.ts +13 -0
  23. package/dist/src/lib/process-manager.d.ts +5 -0
  24. package/dist/src/lib/templates-cache.d.ts +11 -0
  25. package/dist/src/lib/types.d.ts +68 -0
  26. package/dist/src/tools/add-feature.d.ts +29 -0
  27. package/dist/src/tools/build.d.ts +36 -0
  28. package/dist/src/tools/create.d.ts +29 -0
  29. package/dist/src/tools/detect-browsers.d.ts +20 -0
  30. package/dist/src/tools/dev.d.ts +34 -0
  31. package/dist/src/tools/dom-inspect.d.ts +56 -0
  32. package/dist/src/tools/eval.d.ts +44 -0
  33. package/dist/src/tools/get-template-source.d.ts +25 -0
  34. package/dist/src/tools/inspect.d.ts +29 -0
  35. package/dist/src/tools/install-browser.d.ts +18 -0
  36. package/dist/src/tools/list-browsers.d.ts +9 -0
  37. package/dist/src/tools/list-templates.d.ts +41 -0
  38. package/dist/src/tools/logs.d.ts +80 -0
  39. package/dist/src/tools/manifest-validate.d.ts +26 -0
  40. package/dist/src/tools/open.d.ts +31 -0
  41. package/dist/src/tools/preview.d.ts +23 -0
  42. package/dist/src/tools/publish.d.ts +32 -0
  43. package/dist/src/tools/reload.d.ts +33 -0
  44. package/dist/src/tools/source-inspect.d.ts +57 -0
  45. package/dist/src/tools/start.d.ts +29 -0
  46. package/dist/src/tools/storage.d.ts +51 -0
  47. package/dist/src/tools/wait.d.ts +29 -0
  48. package/dist/vitest.config.d.ts +3 -0
  49. package/package.json +84 -0
@@ -0,0 +1,889 @@
1
+ # extension.dev MCP Tool Specification
2
+
3
+ Design document for `@extension.dev/mcp` — an MCP server that exposes extension.dev capabilities as tools for Claude Code, Claude Desktop, and any MCP-compatible client.
4
+
5
+ ## Why this matters
6
+
7
+ Anthropic has no native browser extension tooling. The extension.dev platform already has clean programmatic APIs (`extensionCreate`, `extensionDev`, `extensionBuild`, `extensionPreview`). Wrapping these as MCP tools makes Claude the first AI that can natively scaffold, develop, build, and test browser extensions.
8
+
9
+ For Claude-heavy extension developers, this means: "Build me a Chrome extension that..." just works.
10
+
11
+ ## The examples repo as the backbone
12
+
13
+ The [examples repo](https://github.com/extension-js/examples) is the template catalog, reference implementation library, and distribution channel for extension.dev. Every MCP tool that creates, recommends, or explains extension patterns should source its knowledge from this repo.
14
+
15
+ **Key resource:** `templates-meta.json` (published as a [nightly release asset](https://github.com/extension-js/examples/releases/tag/nightly))
16
+
17
+ This file contains structured metadata for every template: surfaces, framework, permissions, entry points, files, download URLs, and SHA256 integrity hashes. It is the single source of truth for what templates exist and what they contain.
18
+
19
+ **How `extension create` resolves templates today:**
20
+
21
+ ```
22
+ User: npx extension create my-ext --template=sidebar-claude
23
+
24
+
25
+ programs/create/steps/import-external-template.ts
26
+
27
+ ┌────────────────────────────────┤
28
+ │ Built-in name? │ Full GitHub URL? │ HTTP zip?
29
+ ▼ ▼ ▼
30
+ https://github.com/extension-js/ Direct clone axios + adm-zip
31
+ examples/tree/main/examples/<slug> via go-git-it
32
+
33
+
34
+ go-git-it clones subtree → copies to project path → cleanup temp
35
+ ```
36
+
37
+ No caching — every create call re-fetches from GitHub. The MCP server can improve this.
38
+
39
+ ---
40
+
41
+ ## Tool inventory
42
+
43
+ ### Tier 1 — Core tools (ship first)
44
+
45
+ These map directly to existing programmatic APIs and provide immediate value.
46
+
47
+ #### `extension_create`
48
+
49
+ **Source:** `programs/create/module.ts` → `extensionCreate()`
50
+
51
+ **Purpose:** Scaffold a new browser extension project from a template.
52
+
53
+ ```json
54
+ {
55
+ "name": "extension_create",
56
+ "description": "Create a new browser extension project from a template in the extension.dev template catalog. Use extension_list_templates to see available options.",
57
+ "inputSchema": {
58
+ "type": "object",
59
+ "properties": {
60
+ "projectName": {
61
+ "type": "string",
62
+ "description": "Name of the extension project (used as directory name)"
63
+ },
64
+ "template": {
65
+ "type": "string",
66
+ "default": "typescript",
67
+ "description": "Template slug from the extension.dev template catalog (e.g. 'react', 'sidebar-claude', 'content-vue'). Use extension_list_templates to discover options."
68
+ },
69
+ "install": {
70
+ "type": "boolean",
71
+ "default": true,
72
+ "description": "Install dependencies after creation"
73
+ }
74
+ },
75
+ "required": ["projectName"]
76
+ }
77
+ }
78
+ ```
79
+
80
+ **Returns:** `{ projectPath, projectName, template, depsInstalled }`
81
+
82
+ **Integration with examples repo:** The template slug maps directly to a directory under `examples/` in the repo. The tool resolves `https://github.com/extension-js/examples/tree/main/examples/<template>` via `go-git-it`.
83
+
84
+ ---
85
+
86
+ #### `extension_list_templates`
87
+
88
+ **Source:** New — fetches and queries `templates-meta.json`
89
+
90
+ **Purpose:** Search and filter the template catalog. This is how Claude discovers what starting points exist before calling `extension_create`.
91
+
92
+ ```json
93
+ {
94
+ "name": "extension_list_templates",
95
+ "description": "List available extension templates from the extension.dev template catalog. Filter by surface, framework, or tags. Returns structured metadata from templates-meta.json.",
96
+ "inputSchema": {
97
+ "type": "object",
98
+ "properties": {
99
+ "surface": {
100
+ "type": "string",
101
+ "enum": [
102
+ "content",
103
+ "sidebar",
104
+ "action",
105
+ "newtab",
106
+ "devtools",
107
+ "options",
108
+ "background"
109
+ ],
110
+ "description": "Filter by extension surface type"
111
+ },
112
+ "framework": {
113
+ "type": "string",
114
+ "enum": ["react", "vue", "svelte", "preact", ""],
115
+ "description": "Filter by UI framework (empty string = vanilla JS)"
116
+ },
117
+ "tags": {
118
+ "type": "array",
119
+ "items": { "type": "string" },
120
+ "description": "Filter by tags (e.g. ['ai', 'chat'])"
121
+ },
122
+ "featured": {
123
+ "type": "boolean",
124
+ "description": "Only show featured templates"
125
+ },
126
+ "query": {
127
+ "type": "string",
128
+ "description": "Free-text search across slug, description, tags, and useCases"
129
+ }
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ **Returns:** Array of `{ slug, description, uiFramework, surfaces, tags, difficulty, useCases, repositoryUrl, downloads }` — a filtered view of `templates-meta.json`.
136
+
137
+ **Implementation:**
138
+
139
+ 1. Fetch `templates-meta.json` from `https://github.com/extension-js/examples/releases/download/nightly/templates-meta.json`
140
+ 2. Cache locally (TTL: 1 hour) at `~/.cache/extension-js/templates-meta.json`
141
+ 3. Apply filters against the `templates` array
142
+ 4. Return matching entries with only the fields Claude needs
143
+
144
+ **Why this is Tier 1:** Without this tool, Claude would hard-code template names (which go stale). With it, Claude always knows the current catalog.
145
+
146
+ ---
147
+
148
+ #### `extension_build`
149
+
150
+ **Source:** `programs/develop/module.ts` → `extensionBuild()`
151
+
152
+ **Purpose:** Build extension for production/distribution.
153
+
154
+ ```json
155
+ {
156
+ "name": "extension_build",
157
+ "description": "Build a browser extension for production. Outputs to dist/<browser>/. Optionally creates .zip for store submission.",
158
+ "inputSchema": {
159
+ "type": "object",
160
+ "properties": {
161
+ "projectPath": {
162
+ "type": "string",
163
+ "description": "Path to the extension project root"
164
+ },
165
+ "browser": {
166
+ "type": "string",
167
+ "enum": ["chrome", "edge", "firefox", "chromium-based", "gecko-based"],
168
+ "default": "chrome",
169
+ "description": "Target browser"
170
+ },
171
+ "zip": {
172
+ "type": "boolean",
173
+ "default": false,
174
+ "description": "Create a .zip file for store distribution"
175
+ },
176
+ "zipSource": {
177
+ "type": "boolean",
178
+ "default": false,
179
+ "description": "Include source code zip (required by some stores)"
180
+ }
181
+ },
182
+ "required": ["projectPath"]
183
+ }
184
+ }
185
+ ```
186
+
187
+ **Returns:** `{ outputPath, duration, zipPath?, warnings[] }`
188
+
189
+ ---
190
+
191
+ #### `extension_dev`
192
+
193
+ **Source:** `programs/develop/module.ts` → `extensionDev()`
194
+
195
+ **Purpose:** Start development server with HMR and browser launch.
196
+
197
+ ```json
198
+ {
199
+ "name": "extension_dev",
200
+ "description": "Start the extension development server with hot module replacement. Launches a browser with the extension loaded.",
201
+ "inputSchema": {
202
+ "type": "object",
203
+ "properties": {
204
+ "projectPath": {
205
+ "type": "string",
206
+ "description": "Path to the extension project root"
207
+ },
208
+ "browser": {
209
+ "type": "string",
210
+ "enum": ["chrome", "edge", "firefox", "chromium-based", "gecko-based"],
211
+ "default": "chrome"
212
+ },
213
+ "port": {
214
+ "type": "number",
215
+ "description": "Dev server port (0 for auto-assign)"
216
+ },
217
+ "noBrowser": {
218
+ "type": "boolean",
219
+ "default": false,
220
+ "description": "Start dev server without launching browser"
221
+ }
222
+ },
223
+ "required": ["projectPath"]
224
+ }
225
+ }
226
+ ```
227
+
228
+ **Returns:** `{ port, browser, pid }` — long-running process, returns control info.
229
+
230
+ ---
231
+
232
+ #### `extension_start`
233
+
234
+ **Source:** `programs/extension/commands/start.ts` → `extensionBuild()` + `extensionPreview()`
235
+
236
+ **Purpose:** Build and launch in production mode (no HMR). The "production test" workflow — builds first, then opens the browser with the built output.
237
+
238
+ ```json
239
+ {
240
+ "name": "extension_start",
241
+ "description": "Build the extension for production and immediately preview it in a browser. Combines build + preview in one step. No hot reload.",
242
+ "inputSchema": {
243
+ "type": "object",
244
+ "properties": {
245
+ "projectPath": {
246
+ "type": "string",
247
+ "description": "Path to the extension project root"
248
+ },
249
+ "browser": {
250
+ "type": "string",
251
+ "enum": ["chrome", "edge", "firefox", "chromium-based", "gecko-based"],
252
+ "default": "chrome"
253
+ },
254
+ "polyfill": {
255
+ "type": "boolean",
256
+ "default": true,
257
+ "description": "Apply cross-browser polyfill (default true, unlike dev)"
258
+ },
259
+ "wait": {
260
+ "type": "boolean",
261
+ "default": false,
262
+ "description": "Wait for ready.json contract and return structured status"
263
+ },
264
+ "waitTimeout": {
265
+ "type": "number",
266
+ "default": 60000,
267
+ "description": "Timeout in ms when using wait mode"
268
+ }
269
+ },
270
+ "required": ["projectPath"]
271
+ }
272
+ }
273
+ ```
274
+
275
+ **Returns:** When `wait: true`, returns the `ready.json` contract: `{ status, browser, port, pid, distPath, manifestPath, compiledAt }`. Otherwise returns `{ pid, browser }`.
276
+
277
+ **Why this is distinct from dev:** `dev` uses HMR and watches files. `start` builds once in production mode and launches — what you'd use to verify a production build works before publishing.
278
+
279
+ ---
280
+
281
+ #### `extension_preview`
282
+
283
+ **Source:** `programs/develop/module.ts` → `extensionPreview()`
284
+
285
+ **Purpose:** Preview a built extension without dev server.
286
+
287
+ ```json
288
+ {
289
+ "name": "extension_preview",
290
+ "description": "Preview a production-built extension in a browser. Uses dist/ output directly.",
291
+ "inputSchema": {
292
+ "type": "object",
293
+ "properties": {
294
+ "projectPath": {
295
+ "type": "string",
296
+ "description": "Path to the extension project root"
297
+ },
298
+ "browser": {
299
+ "type": "string",
300
+ "enum": ["chrome", "edge", "firefox", "chromium-based", "gecko-based"],
301
+ "default": "chrome"
302
+ }
303
+ },
304
+ "required": ["projectPath"]
305
+ }
306
+ }
307
+ ```
308
+
309
+ ---
310
+
311
+ ### Tier 2 — Intelligence tools (high DX value)
312
+
313
+ These combine extension.dev knowledge with the examples repo to make Claude _smart_ about extensions, not just a CLI wrapper.
314
+
315
+ #### `extension_get_template_source`
316
+
317
+ **Source:** New — reads files from the examples repo
318
+
319
+ **Purpose:** Read the source code of a template to learn its patterns before building something similar. This is how Claude learns extension patterns by example rather than from documentation.
320
+
321
+ ```json
322
+ {
323
+ "name": "extension_get_template_source",
324
+ "description": "Read source files from a template in the extension.dev template catalog. Use this to learn implementation patterns before building something similar.",
325
+ "inputSchema": {
326
+ "type": "object",
327
+ "properties": {
328
+ "slug": {
329
+ "type": "string",
330
+ "description": "Template slug (e.g. 'sidebar-claude', 'content-react')"
331
+ },
332
+ "files": {
333
+ "type": "array",
334
+ "items": { "type": "string" },
335
+ "description": "Specific files to read (e.g. ['src/manifest.json', 'src/background.ts']). If omitted, returns the file listing from templates-meta.json."
336
+ }
337
+ },
338
+ "required": ["slug"]
339
+ }
340
+ }
341
+ ```
342
+
343
+ **Implementation:**
344
+
345
+ 1. Look up the template in `templates-meta.json` to get its `files` array and `repositoryUrl`
346
+ 2. If `files` param is omitted: return the file listing + metadata (surfaces, framework, permissions)
347
+ 3. If `files` param is provided: fetch each file from `https://raw.githubusercontent.com/extension-js/examples/main/examples/<slug>/<file>`
348
+ 4. Return file contents alongside the template metadata for context
349
+
350
+ **Why this matters:** When a user says "add a sidebar like the shadcn example," Claude can read the actual `sidebar-shadcn` source — its manifest structure, background script pattern, component layout — and replicate it accurately. The examples repo becomes a living pattern library for Claude.
351
+
352
+ **Advanced pattern learning:** Complex content script patterns (multi-level imports, MAIN world) can be learned from `content-multi-one-entry`, `content-multi-three-entries`, and `content-main-world` example sources.
353
+
354
+ ---
355
+
356
+ #### `extension_manifest_validate`
357
+
358
+ **Source:** New tool — wraps manifest parsing logic from `plugin-web-extension`
359
+
360
+ **Purpose:** Validate and explain issues in a manifest.json.
361
+
362
+ ```json
363
+ {
364
+ "name": "extension_manifest_validate",
365
+ "description": "Validate a manifest.json file for correctness across browsers. Reports missing fields, invalid permissions, and cross-browser compatibility issues. Cross-references against known-good manifests in the template catalog.",
366
+ "inputSchema": {
367
+ "type": "object",
368
+ "properties": {
369
+ "manifestPath": {
370
+ "type": "string",
371
+ "description": "Path to manifest.json"
372
+ },
373
+ "browsers": {
374
+ "type": "array",
375
+ "items": { "type": "string" },
376
+ "default": ["chrome", "firefox"],
377
+ "description": "Browsers to validate against"
378
+ }
379
+ },
380
+ "required": ["manifestPath"]
381
+ }
382
+ }
383
+ ```
384
+
385
+ **Returns:** `{ valid, errors[], warnings[], browserSupport: { chrome: {}, firefox: {} }, similarTemplates[] }`
386
+
387
+ The `similarTemplates` field lists templates from the catalog with similar surfaces/permissions — useful for cross-referencing a known-good example.
388
+
389
+ ---
390
+
391
+ #### `extension_inspect`
392
+
393
+ **Source:** New tool — wraps `--source` inspection from `programs/develop`
394
+
395
+ **Purpose:** Analyze a built extension's structure, size, and entry points.
396
+
397
+ ```json
398
+ {
399
+ "name": "extension_inspect",
400
+ "description": "Inspect a built extension: file sizes, entry points, permissions used, and dependency analysis.",
401
+ "inputSchema": {
402
+ "type": "object",
403
+ "properties": {
404
+ "projectPath": {
405
+ "type": "string",
406
+ "description": "Path to the extension project root"
407
+ },
408
+ "browser": {
409
+ "type": "string",
410
+ "default": "chrome"
411
+ },
412
+ "format": {
413
+ "type": "string",
414
+ "enum": ["summary", "tree", "json"],
415
+ "default": "summary"
416
+ }
417
+ },
418
+ "required": ["projectPath"]
419
+ }
420
+ }
421
+ ```
422
+
423
+ **Returns:** File tree with sizes, entry point map, permissions analysis, estimated store review flags.
424
+
425
+ ---
426
+
427
+ #### `extension_add_feature`
428
+
429
+ **Source:** New tool — codegen based on examples repo patterns
430
+
431
+ **Purpose:** Add a feature surface to an existing extension (sidebar, content script, popup, options page, etc.)
432
+
433
+ ```json
434
+ {
435
+ "name": "extension_add_feature",
436
+ "description": "Add a new feature surface to an existing extension. Generates the required files and updates manifest.json. Uses patterns from the extension.dev template catalog.",
437
+ "inputSchema": {
438
+ "type": "object",
439
+ "properties": {
440
+ "projectPath": {
441
+ "type": "string"
442
+ },
443
+ "feature": {
444
+ "type": "string",
445
+ "enum": [
446
+ "sidebar",
447
+ "popup",
448
+ "options",
449
+ "content-script",
450
+ "background",
451
+ "newtab",
452
+ "devtools",
453
+ "history",
454
+ "bookmarks"
455
+ ],
456
+ "description": "Feature surface to add"
457
+ },
458
+ "framework": {
459
+ "type": "string",
460
+ "enum": ["react", "vue", "svelte", "preact", "vanilla"],
461
+ "default": "react"
462
+ }
463
+ },
464
+ "required": ["projectPath", "feature"]
465
+ }
466
+ }
467
+ ```
468
+
469
+ **Implementation:** Internally calls `extension_get_template_source` to fetch the canonical pattern for the requested surface+framework combination, then generates the files and updates manifest.json. The examples repo is the codegen source — not hard-coded templates.
470
+
471
+ ---
472
+
473
+ #### `extension_source_inspect`
474
+
475
+ **Source:** `programs/extension/browsers/` → CDP/RDP source inspection system
476
+
477
+ **Purpose:** Live-inspect a running extension's DOM, console, and content script injection state. This is the `--source` system exposed as an MCP tool — it gives Claude _eyes_ into the running extension.
478
+
479
+ ```json
480
+ {
481
+ "name": "extension_source_inspect",
482
+ "description": "Inspect a running extension's live state: DOM structure, content script injection, console messages, and selector queries. Requires an active dev or start session.",
483
+ "inputSchema": {
484
+ "type": "object",
485
+ "properties": {
486
+ "projectPath": {
487
+ "type": "string",
488
+ "description": "Path to the extension project root (must have an active dev session)"
489
+ },
490
+ "url": {
491
+ "type": "string",
492
+ "description": "URL to inspect (navigates the browser tab). Defaults to the current tab."
493
+ },
494
+ "probe": {
495
+ "type": "array",
496
+ "items": { "type": "string" },
497
+ "description": "CSS selectors to query — returns element counts and samples for each"
498
+ },
499
+ "include": {
500
+ "type": "array",
501
+ "items": {
502
+ "type": "string",
503
+ "enum": ["html", "summary", "meta", "dom_snapshot", "console", "tree"]
504
+ },
505
+ "default": ["summary", "meta", "console"],
506
+ "description": "What data to return"
507
+ },
508
+ "context": {
509
+ "type": "string",
510
+ "enum": [
511
+ "page",
512
+ "options",
513
+ "sidepanel",
514
+ "devtools",
515
+ "newtab",
516
+ "popup",
517
+ "background"
518
+ ],
519
+ "default": "page",
520
+ "description": "Extension context to inspect (page = content script on web page)"
521
+ },
522
+ "shadowDom": {
523
+ "type": "string",
524
+ "enum": ["off", "open-only", "all"],
525
+ "default": "open-only",
526
+ "description": "Shadow DOM traversal strategy"
527
+ },
528
+ "redact": {
529
+ "type": "string",
530
+ "enum": ["off", "safe", "strict"],
531
+ "default": "safe",
532
+ "description": "Redact sensitive content from HTML output"
533
+ }
534
+ },
535
+ "required": ["projectPath"]
536
+ }
537
+ }
538
+ ```
539
+
540
+ **Returns:** Structured NDJSON events based on `include` selection:
541
+
542
+ | Event type | What it contains |
543
+ | --------------------- | ------------------------------------------------------------------------------------------ |
544
+ | `page_html` | Full injected HTML (after content scripts run) |
545
+ | `page_html_summary` | Compact stats: root/script/style/link counts |
546
+ | `page_meta` | readyState, viewport dimensions, frame count |
547
+ | `dom_snapshot` | Structured tree: tag, id, classes, role, text length, child count (max 500 nodes, depth 6) |
548
+ | `console_summary` | error/warn/info/log/debug counts + top 5 unique messages |
549
+ | `extension_root_tree` | Extension root elements with reinject generations |
550
+ | `selector_probe` | Per-selector: count + element samples |
551
+
552
+ **Implementation:**
553
+
554
+ - Chromium: Uses the existing CDP client (`CDPClient.evaluate()`, `CDPClient.getPageHTML()`) via the already-running dev session's remote debugging port
555
+ - Firefox: Uses the existing RDP transport via the already-running dev session
556
+ - The `context` parameter maps to the Phase A expansion in `SESSION-SOURCE-EXTENSION-CONTEXTS.md` — currently only `page` works; extension UI contexts (`options`, `sidepanel`, `popup`, etc.) are planned
557
+
558
+ **Why this is the highest-value Tier 2 tool:** Claude can't fix what it can't see. When a content script doesn't inject, when a selector doesn't match, when the console is full of errors — this tool tells Claude exactly what's happening in the live browser. For complex multi-level content script chains, `probe: ["[data-extension-root]"]` instantly shows whether injection succeeded.
559
+
560
+ ---
561
+
562
+ #### `extension_wait`
563
+
564
+ **Source:** `programs/extension/commands/dev-wait.ts`
565
+
566
+ **Purpose:** Poll for extension readiness after `dev` or `start`. Returns structured status from the `ready.json` contract.
567
+
568
+ ```json
569
+ {
570
+ "name": "extension_wait",
571
+ "description": "Wait for a running dev or start session to be ready. Polls the ready.json contract file and returns structured status.",
572
+ "inputSchema": {
573
+ "type": "object",
574
+ "properties": {
575
+ "projectPath": {
576
+ "type": "string",
577
+ "description": "Path to the extension project root"
578
+ },
579
+ "browser": {
580
+ "type": "string",
581
+ "default": "chrome",
582
+ "description": "Browser to check readiness for"
583
+ },
584
+ "timeout": {
585
+ "type": "number",
586
+ "default": 60000,
587
+ "description": "Timeout in milliseconds"
588
+ }
589
+ },
590
+ "required": ["projectPath"]
591
+ }
592
+ }
593
+ ```
594
+
595
+ **Returns:** The `ready.json` contract:
596
+
597
+ ```json
598
+ {
599
+ "status": "ready",
600
+ "command": "dev",
601
+ "browser": "chrome",
602
+ "port": 8080,
603
+ "pid": 12345,
604
+ "distPath": "/path/to/dist/chrome",
605
+ "manifestPath": "/path/to/dist/chrome/manifest.json",
606
+ "compiledAt": "2026-04-14T10:30:00.000Z",
607
+ "startedAt": "2026-04-14T10:29:55.000Z"
608
+ }
609
+ ```
610
+
611
+ **Why this matters for MCP:** When Claude starts a dev session via `extension_dev`, it needs to know when the extension is actually loaded and ready before calling `extension_source_inspect`. This tool provides that gate.
612
+
613
+ ---
614
+
615
+ ### Tier 3 — Browser management tools
616
+
617
+ #### `extension_install_browser`
618
+
619
+ **Source:** `programs/install/module.ts` → `extensionInstall()`
620
+
621
+ **Purpose:** Install managed browser binaries for testing.
622
+
623
+ ```json
624
+ {
625
+ "name": "extension_install_browser",
626
+ "description": "Install a managed browser binary for extension testing. Useful in CI or fresh environments.",
627
+ "inputSchema": {
628
+ "type": "object",
629
+ "properties": {
630
+ "browser": {
631
+ "type": "string",
632
+ "enum": ["chrome", "chromium", "edge", "firefox"]
633
+ }
634
+ },
635
+ "required": ["browser"]
636
+ }
637
+ }
638
+ ```
639
+
640
+ #### `extension_list_browsers`
641
+
642
+ **Source:** `programs/install/module.ts` → `getManagedBrowsersCacheRoot()`
643
+
644
+ **Purpose:** List installed managed browsers and their paths.
645
+
646
+ ---
647
+
648
+ #### `extension_detect_browsers`
649
+
650
+ **Source:** `programs/extension/browsers/` → binary resolution chain
651
+
652
+ **Purpose:** Detect which browsers are available on the system and their binary paths. Uses the same resolution chain as the CLI: managed cache → WSL → custom binary → npm location packages (`chrome-location2`, `firefox-location2`, `edge-location`).
653
+
654
+ ```json
655
+ {
656
+ "name": "extension_detect_browsers",
657
+ "description": "Detect which browsers are available for extension development. Returns paths and capabilities for each detected browser.",
658
+ "inputSchema": {
659
+ "type": "object",
660
+ "properties": {
661
+ "browsers": {
662
+ "type": "array",
663
+ "items": {
664
+ "type": "string",
665
+ "enum": ["chrome", "chromium", "edge", "firefox"]
666
+ },
667
+ "description": "Browsers to check. If omitted, checks all."
668
+ }
669
+ }
670
+ }
671
+ }
672
+ ```
673
+
674
+ **Returns:**
675
+
676
+ ```json
677
+ {
678
+ "detected": [
679
+ {
680
+ "browser": "chrome",
681
+ "binaryPath": "/usr/bin/google-chrome",
682
+ "source": "system",
683
+ "engine": "chromium",
684
+ "cdpSupport": true
685
+ },
686
+ {
687
+ "browser": "firefox",
688
+ "binaryPath": "/usr/bin/firefox",
689
+ "source": "system",
690
+ "engine": "gecko",
691
+ "cdpSupport": false,
692
+ "rdpSupport": true
693
+ }
694
+ ],
695
+ "managed": {
696
+ "cacheRoot": "/home/user/.cache/extension.js/browsers",
697
+ "installed": ["chromium"]
698
+ }
699
+ }
700
+ ```
701
+
702
+ **Why this matters:** Before Claude runs `extension_dev --browser=firefox`, it should know if Firefox is actually installed. This prevents "browser not found" errors and lets Claude suggest `extension_install_browser` when needed. Especially important for Docker/devcontainer environments.
703
+
704
+ ---
705
+
706
+ ## Where each tool lives in the codebase
707
+
708
+ | MCP Tool | Program | Source API | Data source | Needs new code? |
709
+ | ------------------------------- | -------------------- | ----------------------------------------- | ------------------------------------------- | ------------------------------------------ |
710
+ | **Tier 1 — Core** | | | | |
711
+ | `extension_create` | `programs/create` | `extensionCreate()` | examples repo via go-git-it | Thin wrapper only |
712
+ | `extension_list_templates` | New | — | `templates-meta.json` release asset | Fetch + filter + cache |
713
+ | `extension_build` | `programs/develop` | `extensionBuild()` | — | Thin wrapper only |
714
+ | `extension_dev` | `programs/develop` | `extensionDev()` | — | Thin wrapper + process management |
715
+ | `extension_start` | `programs/extension` | `extensionBuild()` + `extensionPreview()` | — | Thin wrapper (already orchestrated in CLI) |
716
+ | `extension_preview` | `programs/develop` | `extensionPreview()` | — | Thin wrapper only |
717
+ | **Tier 2 — Intelligence** | | | | |
718
+ | `extension_get_template_source` | New | — | `templates-meta.json` + raw GitHub | Fetch + read files |
719
+ | `extension_manifest_validate` | `programs/develop` | `plugin-web-extension` | `templates-meta.json` for similar templates | Extract validation logic |
720
+ | `extension_inspect` | `programs/develop` | `--source` flag logic | — | Extract into callable API |
721
+ | `extension_source_inspect` | `programs/extension` | CDP client / RDP transport | Live browser via debugging protocol | Wire to running session |
722
+ | `extension_wait` | `programs/extension` | `dev-wait.ts` | `ready.json` contract file | Thin wrapper (exists in CLI) |
723
+ | `extension_add_feature` | New | `extension_get_template_source` | examples repo patterns | Codegen from examples |
724
+ | **Tier 3 — Browser management** | | | | |
725
+ | `extension_install_browser` | `programs/install` | `extensionInstall()` | — | Thin wrapper only |
726
+ | `extension_list_browsers` | `programs/install` | `getManagedBrowsersCacheRoot()` | — | Thin wrapper only |
727
+ | `extension_detect_browsers` | `programs/extension` | Binary resolution chain | System PATH + managed cache | Extract from launch logic |
728
+
729
+ ## Changes needed in existing programs
730
+
731
+ ### `programs/develop/`
732
+
733
+ - **Extract manifest validation** from `plugin-web-extension` into a standalone callable function. Currently validation is embedded in the Rspack plugin lifecycle.
734
+ - **Extract source inspection** from `--source` flag handling into `extensionInspect(projectPath, options)` API.
735
+ - **Add `--json` output mode** to `extensionBuild()` return value. Currently returns `BuildSummary` but it could be richer with file-level details.
736
+ - **Structured error types.** Current errors are human-readable strings. MCP tools need error codes + structured details for Claude to act on.
737
+
738
+ ### `programs/create/`
739
+
740
+ - **Template listing API.** Add `extensionListTemplates(filters?)` that fetches+caches `templates-meta.json` and returns filtered results. This serves both the MCP `extension_list_templates` tool and any future CLI `extension list` command.
741
+ - **Dry-run mode.** Add `dryRun` option to `extensionCreate()` that returns the file list without writing. Useful for Claude to explain what will be created before doing it.
742
+ - **Template caching.** The current no-cache approach (re-download from GitHub every time) works but is slow. An MCP server that handles many create calls should cache the examples repo or individual template tarballs with a TTL.
743
+
744
+ ### `programs/install/`
745
+
746
+ - **Already clean.** `extensionInstall()` and `extensionUninstall()` are ready for wrapping.
747
+
748
+ ### `programs/extension/` (CLI + browsers)
749
+
750
+ - **`--json` flag for all commands.** Machine-readable output for every command. This benefits not just MCP but any programmatic consumer. The `--ai-help` / `--format json` flags already exist — extend this pattern to command output.
751
+ - **Exit codes.** Ensure distinct exit codes for different failure modes (missing manifest, build error, browser not found, etc.)
752
+ - **`extension list` command.** Expose `extensionListTemplates()` as a CLI command. Shows the catalog in terminal or JSON.
753
+ - **Extract binary detection into callable API.** The browser resolution chain (managed cache → WSL → custom binary → npm location packages) is embedded in `chromium-launch/index.ts` and `firefox-launch/index.ts`. Extract into `extensionDetectBrowsers()` for the `extension_detect_browsers` MCP tool.
754
+ - **Extract source inspection into MCP-callable API.** The `--source` system is deeply integrated into the browser launch lifecycle. For MCP, we need a way to call it against an _already-running_ dev session. The ready.json contract already gives us port/pid — the MCP server can connect to the CDP/RDP port directly.
755
+ - **Extract wait mode into callable API.** The `dev-wait.ts` logic is CLI-only. Expose `extensionWait(projectPath, browser, timeout)` as a programmatic function.
756
+ - **Expose the `start` command programmatically.** Currently `start` is CLI-only orchestration (build then preview). Add `extensionStart()` that chains `extensionBuild()` + `extensionPreview()` with the ready.json contract.
757
+
758
+ ### Examples repo
759
+
760
+ - **AI metadata in `template.meta.json`.** See "AI-relevant metadata fields" section below.
761
+ - **Ensure `templates-meta.json` is always published** as a release asset and committed to the repo, so both the MCP server and Claude Code rules can consume it.
762
+
763
+ ---
764
+
765
+ ## AI-relevant metadata fields
766
+
767
+ Proposed additions to the `template.meta.json` curated schema (via `CURATED_ALLOWED_KEYS` in `generate-templates-meta.mjs`):
768
+
769
+ ```javascript
770
+ const CURATED_ALLOWED_KEYS = [
771
+ // Existing
772
+ "title",
773
+ "featured",
774
+ "tags",
775
+ "difficulty",
776
+ "timeToFirstSuccessMinutes",
777
+ "firstSteps",
778
+ "useCases",
779
+ "docsUrl",
780
+ // Proposed additions
781
+ "aiPromptExamples", // Example user prompts this template is good for
782
+ "aiRecommendFor", // Keywords/intents that should recommend this template
783
+ "patternExplanation", // Brief explanation of the architectural pattern
784
+ "keyFiles", // Most important files to read to understand the pattern
785
+ ];
786
+ ```
787
+
788
+ **Example for `sidebar-claude/template.meta.json`:**
789
+
790
+ ```json
791
+ {
792
+ "title": "Claude AI Sidebar",
793
+ "featured": true,
794
+ "tags": ["ai", "claude", "anthropic", "chat", "sidebar", "react", "shadcn"],
795
+ "difficulty": "beginner",
796
+ "timeToFirstSuccessMinutes": 3,
797
+ "useCases": [
798
+ "AI assistant sidebar for any webpage",
799
+ "Claude-powered research companion"
800
+ ],
801
+ "aiPromptExamples": [
802
+ "Build a Chrome extension with a Claude chatbot sidebar",
803
+ "Create a browser extension that lets me talk to AI on any page",
804
+ "Make an extension with an Anthropic-powered assistant panel"
805
+ ],
806
+ "aiRecommendFor": [
807
+ "claude",
808
+ "anthropic",
809
+ "ai chat",
810
+ "llm sidebar",
811
+ "ai assistant"
812
+ ],
813
+ "patternExplanation": "Sidebar panel with React chat UI calling Anthropic SDK. API key stored in chrome.storage.local. Cross-browser via chromium:side_panel + firefox:sidebar_action.",
814
+ "keyFiles": [
815
+ "src/manifest.json",
816
+ "src/lib/claude.ts",
817
+ "src/sidebar/SidebarApp.tsx",
818
+ "src/background.ts"
819
+ ]
820
+ }
821
+ ```
822
+
823
+ These fields enable `extension_list_templates` to match user intent ("I want to build an AI sidebar") to the right template, and `extension_get_template_source` to read only the key files rather than everything.
824
+
825
+ ---
826
+
827
+ ## Implementation plan
828
+
829
+ ### Phase 1: Foundation (changes to existing programs)
830
+
831
+ 1. Add `--json` output flag to build/dev/start/preview/create commands in `programs/extension`
832
+ 2. Extract manifest validation into `extensionValidateManifest()` in `programs/develop`
833
+ 3. Add `extensionListTemplates(filters?)` to `programs/create` — fetches and caches `templates-meta.json`
834
+ 4. Add `extension list` CLI command wrapping the above
835
+ 5. Extract browser detection into `extensionDetectBrowsers()` in `programs/extension`
836
+ 6. Extract wait mode into `extensionWait()` in `programs/extension`
837
+ 7. Add AI metadata fields to `CURATED_ALLOWED_KEYS` in `generate-templates-meta.mjs`
838
+ 8. Populate `template.meta.json` with AI fields for key templates (sidebar-claude, action-chatgpt, sidebar-transformers-js)
839
+
840
+ ### Phase 2: MCP Server package
841
+
842
+ 1. New package: `programs/mcp` or standalone `@extension.dev/mcp`
843
+ 2. Implement Tier 1 tools: `extension_create`, `extension_list_templates`, `extension_build`, `extension_dev`, `extension_start`, `extension_preview`
844
+ 3. `extension_list_templates` caches `templates-meta.json` with 1-hour TTL
845
+ 4. Register on MCP directory (npmjs.com + modelcontextprotocol.io)
846
+
847
+ ### Phase 3: Live inspection tools
848
+
849
+ 1. `extension_wait` — poll ready.json contract (gate for inspection tools)
850
+ 2. `extension_source_inspect` — connect to running session's CDP/RDP port for live DOM inspection
851
+ 3. `extension_detect_browsers` — system browser detection
852
+ 4. `extension_get_template_source` — reads from examples repo via raw.githubusercontent.com
853
+ 5. `extension_manifest_validate` — cross-browser validation + similar template suggestions
854
+
855
+ ### Phase 4: Codegen + advanced tools
856
+
857
+ 1. `extension_inspect` — static build analysis from `--source` extraction
858
+ 2. `extension_add_feature` — codegen sourced from examples repo patterns
859
+
860
+ ### Phase 5: Feedback loop
861
+
862
+ 1. MCP server reports which templates Claude recommends most → feed into `featured` rankings
863
+ 2. Track which `aiPromptExamples` lead to successful creates → improve matching
864
+ 3. New templates added to examples repo are immediately available via `extension_list_templates` (no MCP server update needed — it reads `templates-meta.json` at runtime)
865
+
866
+ ---
867
+
868
+ ## DX priorities for power users
869
+
870
+ Typical power-user workflows that drive tool prioritization:
871
+
872
+ - Multi-browser extensions (Chrome + Firefox)
873
+ - Complex content script import trees (multi-level chains across manifest entries)
874
+ - Docker/devcontainer development
875
+ - Heavy Claude Code usage for rapid iteration
876
+
877
+ **Highest-value tools by workflow:**
878
+
879
+ | Workflow | Tool | Why |
880
+ | ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
881
+ | Debugging injection failures | `extension_source_inspect` | `probe: ["[data-extension-root]"]` shows injection state, reinject generation, console errors — no manual DevTools needed |
882
+ | Docker/devcontainer | `extension_detect_browsers` + `extension_wait` | Check browser availability, gate on dev server readiness |
883
+ | Multi-browser | `extension_manifest_validate` + `extension_build` | Catch manifest divergence early, build for `chrome,firefox` |
884
+ | Learning patterns | `extension_list_templates` + `extension_get_template_source` | Read `content-multi-one-entry`, `content-multi-three-entries` for multi-level import patterns |
885
+ | Rapid prototyping | `extension_add_feature` | "Add a sidebar" generates correct manifest + files + background handler |
886
+
887
+ **Why the examples repo is central:** Complex patterns (multi-level content script imports, MAIN world isolation, cross-browser sidebars) are documented as working examples. `extension_get_template_source` gives Claude the canonical implementation to reference when building or debugging these patterns.
888
+
889
+ **Why source inspection is the highest-value tool:** The most time-consuming extension debugging failure is "it didn't load." `extension_source_inspect` with `probe` and `console_summary` turns manual Chrome DevTools investigation into a one-call Claude diagnosis.