一个用于检查、测试和监控通过 navigator.modelContext 注册的 WebMCP 工具的 Chrome 扩展。
English | 中文
Web Model Context Protocol (WebMCP) 是一个浏览器原生 API,允许网页通过 navigator.modelContext 为 AI 模型注册工具。WebMCP DevTools 提供强大的侧面板,让你实时查看和操作这些工具。
| 功能 | 说明 |
|---|---|
| 工具检测 | 自动检测当前页面注册的所有 WebMCP 工具 |
| Schema 可视化 | 以可折叠树形结构查看输入 Schema |
| 表单生成 | 根据 JSON Schema 自动生成交互式表单 |
| 工具执行 | 直接从侧面板执行工具并即时查看结果 |
| 事件时间线 | 实时追踪工具注册、注销和变更事件 |
| 执行历史 | 查看最近 20 次执行的输入/输出详情 |
| 快照 & 对比 | 保存工具定义快照并对比变化 |
| 导出 | 支持 JSON、Markdown、Postman Collection、JavaScript 代码导出 |
| 国际化 | 中英文双语支持,一键切换 |
| 主题 | 支持跟随系统、明亮、暗色三种主题 |
即将上架 — 扩展目前正在审核中。
前置要求: Node.js 18+、pnpm
# 克隆仓库
git clone https://github.com/2019-02-18/WebMCP-DevTools.git
cd WebMCP-DevTools
# 安装依赖
pnpm install
# 构建生产版本
pnpm build在 Chrome 中加载扩展:
- 打开
chrome://extensions/ - 开启右上角的 开发者模式
- 点击 加载已解压的扩展程序
- 选择
.output/chrome-mv3文件夹
使用扩展前,需要先在 Chrome 中启用 WebMCP 标志:
- 打开
chrome://flags/#enable-webmcp-testing - 将该标志设为 Enabled
- 重启 Chrome
- 点击 Chrome 工具栏中的 WebMCP DevTools 图标打开侧面板
- 导航到任何注册了 WebMCP 工具的页面
- Tools 标签页列出所有检测到的工具及其 Schema
- 点击工具卡片切换到 Execute 标签页
- 填写参数(表单模式或原始 JSON)并点击 Execute
- 在 Timeline 标签页查看实时注册事件
- 使用 Snapshots 保存和对比工具定义
项目包含一个测试页面 test/demo.html,内含多个模拟工具。使用本地服务器(如 VS Code Live Server)打开即可测试,无需真实的 WebMCP 页面。
├── entrypoints/
│ ├── background.ts # Service Worker — 标签页管理、消息路由
│ ├── content.ts # Content Script (ISOLATED) — 与侧面板桥接
│ ├── injected.content.ts # Content Script (MAIN) — 拦截 modelContext
│ └── sidepanel/
│ ├── index.html # 侧面板 HTML 外壳
│ ├── main.ts # 侧面板逻辑 — 渲染、交互
│ └── styles.css # 所有样式、主题、组件
├── lib/
│ ├── types.ts # 共享 TypeScript 接口
│ ├── i18n.ts # 国际化(中文 / 英文)
│ ├── icons.ts # Lucide 风格 SVG 图标定义
│ ├── theme.ts # 主题切换辅助函数
│ ├── storage.ts # chrome.storage.local 工具函数
│ ├── export.ts # 导出:JSON、Markdown、Postman、Script
│ ├── diff.ts # 快照对比引擎
│ ├── schema-renderer.ts # JSON Schema → 可折叠树形视图
│ ├── schema-form.ts # JSON Schema → 交互式表单
│ └── json-highlight.ts # JSON 语法高亮
├── test/
│ └── demo.html # 本地测试页面(含模拟 WebMCP 工具)
├── scripts/
│ └── generate-icons.mjs # 扩展图标生成脚本
├── public/
│ └── icons/ # 生成的扩展图标(16–128px)
├── wxt.config.ts # WXT 框架配置
├── package.json
├── tsconfig.json
├── PRIVACY.md # 隐私政策
└── LICENSE # MIT 许可证
- WXT — 新一代浏览器扩展框架
- TypeScript — 类型安全开发
- Chrome Manifest V3 — Service Worker、Side Panel API
- Vanilla DOM — 无 UI 框架依赖,极小打包体积(~90 KB)
# 启动开发模式(热重载)
pnpm dev
# 构建生产版本
pnpm build
# 打包为 Chrome Web Store 上传用的 zip
pnpm zip┌──────────────┐ postMessage ┌──────────────┐ chrome.runtime ┌──────────────┐
│ 网页 │ ←───────────────→ │ Content │ ←──────────────────→ │ Background │
│ (MAIN) │ │ Scripts │ .sendMessage │ (Service │
│ │ │ (ISOLATED) │ │ Worker) │
│ modelContext │ │ │ │ │
│ .registerTool│ │ │ chrome.runtime │ │
│ │ │ │ ←──────────────────→ │ │
└──────────────┘ └──────────────┘ .sendMessage └──────┬───────┘
│
┌──────────────┐ │
│ 侧面板 │ ←────────────────────────────────────────────────────────┘
│ (UI) │ chrome.runtime.sendMessage
│ │
│ 工具列表 │
│ 执行面板 │
│ 事件时间线 │
│ 快照管理 │
└──────────────┘
- injected.content.ts 运行在页面的 MAIN 世界,通过 monkey-patch
navigator.modelContext.registerTool()拦截工具注册 - content.ts 运行在 ISOLATED 世界,桥接
window.postMessage↔chrome.runtime.sendMessage - background.ts(Service Worker)在 content script 和侧面板之间路由消息,管理标签页追踪
- sidepanel/main.ts 渲染 UI 并协调所有用户交互
欢迎贡献!请提交 Issue 或 Pull Request。
- Fork 本仓库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交更改(
git commit -m 'Add amazing feature') - 推送分支(
git push origin feature/amazing-feature) - 发起 Pull Request
本项目基于 MIT 许可证 开源。
A Chrome extension for inspecting, testing, and monitoring WebMCP tools registered via navigator.modelContext.
中文 | English
Web Model Context Protocol (WebMCP) is a browser-native API that allows web pages to register tools for AI models through navigator.modelContext. WebMCP DevTools gives you a powerful side panel to inspect and interact with these tools in real-time.
| Feature | Description |
|---|---|
| Tool Detection | Automatically detects all WebMCP tools registered on the current page |
| Schema Visualization | View input schemas as collapsible tree structures |
| Form Generation | Auto-generates interactive forms from JSON Schema |
| Tool Execution | Execute tools directly from the side panel with instant results |
| Event Timeline | Track tool register / unregister / change events in real-time |
| Execution History | Review the last 20 executions with full input & output details |
| Snapshots & Diff | Save tool definition snapshots and compare changes over time |
| Export | Export as JSON, Markdown, Postman Collection, or JavaScript code |
| i18n | English and Chinese (中文) with one-click toggle |
| Themes | System-aware dark / light theme with manual override |
Coming soon — the extension is currently under review.
Prerequisites: Node.js 18+, pnpm
# Clone the repository
git clone https://github.com/2019-02-18/WebMCP-DevTools.git
cd WebMCP-DevTools
# Install dependencies
pnpm install
# Build for production
pnpm buildThen load the extension in Chrome:
- Open
chrome://extensions/ - Enable Developer mode (top-right toggle)
- Click Load unpacked
- Select the
.output/chrome-mv3folder
Before using the extension, enable the WebMCP flag in Chrome:
- Open
chrome://flags/#enable-webmcp-testing - Set the flag to Enabled
- Restart Chrome
- Click the WebMCP DevTools icon in the Chrome toolbar to open the side panel
- Navigate to any page that registers WebMCP tools
- The Tools tab lists all detected tools with their schemas
- Click a tool card to switch to the Execute tab
- Fill in parameters (form mode or raw JSON) and click Execute
- Check the Timeline tab for real-time registration events
- Use Snapshots to save and diff tool definitions over time
A test page is included at test/demo.html with several mock tools. Open it with a local server (e.g. VS Code Live Server) to try the extension without needing a real WebMCP-enabled site.
├── entrypoints/
│ ├── background.ts # Service Worker — tab tracking, message routing
│ ├── content.ts # Content Script (ISOLATED) — bridge to side panel
│ ├── injected.content.ts # Content Script (MAIN) — intercepts modelContext
│ └── sidepanel/
│ ├── index.html # Side Panel HTML shell
│ ├── main.ts # Side Panel logic — rendering, interactions
│ └── styles.css # All styles, themes, components
├── lib/
│ ├── types.ts # Shared TypeScript interfaces
│ ├── i18n.ts # Internationalization (en / zh)
│ ├── icons.ts # Lucide-style SVG icon definitions
│ ├── theme.ts # Theme application helpers
│ ├── storage.ts # chrome.storage.local utilities
│ ├── export.ts # Export: JSON, Markdown, Postman, Script
│ ├── diff.ts # Snapshot diff engine
│ ├── schema-renderer.ts # JSON Schema → collapsible tree view
│ ├── schema-form.ts # JSON Schema → interactive form
│ └── json-highlight.ts # JSON syntax highlighter
├── test/
│ └── demo.html # Local test page with mock WebMCP tools
├── scripts/
│ └── generate-icons.mjs # Extension icon generator
├── public/
│ └── icons/ # Generated extension icons (16–128px)
├── wxt.config.ts # WXT framework configuration
├── package.json
├── tsconfig.json
├── PRIVACY.md # Privacy policy
└── LICENSE # MIT License
- WXT — Next-gen Web Extension Framework
- TypeScript — Type-safe development
- Chrome Manifest V3 — Service Worker, Side Panel API
- Vanilla DOM — No UI framework dependency, minimal bundle size (~90 KB)
# Start dev mode with hot reload
pnpm dev
# Build for production
pnpm build
# Package as zip for Chrome Web Store
pnpm zip┌──────────────┐ postMessage ┌──────────────┐ chrome.runtime ┌──────────────┐
│ Web Page │ ←───────────────→ │ Content │ ←──────────────────→ │ Background │
│ (MAIN) │ │ Scripts │ .sendMessage │ (Service │
│ │ │ (ISOLATED) │ │ Worker) │
│ modelContext │ │ │ │ │
│ .registerTool│ │ │ chrome.runtime │ │
│ │ │ │ ←──────────────────→ │ │
└──────────────┘ └──────────────┘ .sendMessage └──────┬───────┘
│
┌──────────────┐ │
│ Side Panel │ ←────────────────────────────────────────────────────────┘
│ (UI) │ chrome.runtime.sendMessage
│ │
│ Tools list │
│ Execute │
│ Timeline │
│ Snapshots │
└──────────────┘
- injected.content.ts runs in the page's MAIN world, monkey-patches
navigator.modelContext.registerTool()to intercept tool registrations - content.ts runs in ISOLATED world, bridges
window.postMessage↔chrome.runtime.sendMessage - background.ts (Service Worker) routes messages between content scripts and the side panel, manages tab tracking
- sidepanel/main.ts renders the UI and orchestrates all user interactions
Contributions are welcome! Please open an issue or submit a pull request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.