This directory contains documentation and examples for developing WebMCP userscripts that inject MCP-B servers into websites. As an AI assistant, use the following guides based on your task:
Purpose: Comprehensive development guide for creating, testing, and debugging userscripts When to use:
- When asked to create a new userscript for any website
- When debugging existing userscripts
- When you need detailed workflow phases and best practices
- For understanding the complete WebMCP ecosystem
Contents:
- Complete development workflow (6 phases)
- Tool discovery and usage patterns
- Selector strategies and React compatibility
- Testing and debugging patterns
- Common issues and solutions
- Code examples and templates
Purpose: Concise, action-oriented prompt template for rapid userscript development When to use:
- When you need to quickly create a userscript without detailed explanations
- For autonomous development without user interaction
- As a copy-paste template for immediate action
Contents:
- Step-by-step autonomous workflow
- Time-boxed development phases
- Success criteria checklist
- Minimal explanations, maximum action
Purpose: Actual implementation example showing the complete workflow for ChatGPT When to use:
- As a reference when creating similar React-based userscripts
- To understand common pitfalls and solutions
- For seeing the complete test sequence
Contents:
- Real reconnaissance results
- Actual code that works
- Issues encountered and solutions
- Complete test sequence with real tab IDs
| User Request | Primary Guide | Secondary Reference |
|---|---|---|
| "Create a userscript for [website]" | AI_AUTOMATION_PROMPT.md | WEBMCP_USERSCRIPT_GUIDE.md |
| "Debug why tools aren't appearing" | WEBMCP_USERSCRIPT_GUIDE.md | |
| "Find selectors for [website]" | WEBMCP_USERSCRIPT_GUIDE.md (Phase 1) | - |
| "Make it work with React" | WEBMCP_USERSCRIPT_GUIDE.md (React section) | |
| "Just inject and test quickly" | AI_AUTOMATION_PROMPT.md | - |
# Navigate to userscripts directory
cd /path/to/WebMCP/webmcp-userscripts
# Create new script directory
mkdir -p scripts/[sitename]/src
cd scripts/[sitename]
# Build a script
pnpm install
pnpm run build
# Output location (for injection)
# dist/[sitename].user.js-
Reconnaissance (Playwright MCP):
mcp_playwright_browser_navigatemcp_playwright_browser_snapshotmcp_playwright_browser_evaluate
-
Development (File tools):
- Create files in
scripts/[sitename]/src/ - Use templates from documentation
- Create files in
-
Testing (WebMCP Extension):
mcp_mcp-b_call_extension_tool(toolName: "extension_tool_list_active_tabs")mcp_mcp-b_extension_tool_execute_user_scriptmcp_mcp-b_list_website_toolsmcp_mcp-b_call_website_tool
webmcp-userscripts/
βββ README.md # This file - AI usage guide
βββ WEBMCP_USERSCRIPT_GUIDE.md # Comprehensive development guide
βββ AI_AUTOMATION_PROMPT.md # Quick autonomous template
βββ # Real-world example
βββ scripts/ # Individual userscripts
β βββ gmail/ # Gmail MCP-B script
β βββ google/ # Google search script
β βββ chatgpt/ # ChatGPT script (see example)
βββ packages/ # Shared code
βββ templates/ # File templates
βββ tests/ # Test suites
START
β
ββ User wants new userscript?
β ββ Yes β Use AI_AUTOMATION_PROMPT.md
β ββ No β
β
ββ User having problems?
β ββ Yes β Use WEBMCP_USERSCRIPT_GUIDE.md (debugging section)
β ββ No β
β
ββ User wants to understand?
β ββ Yes β Use WEBMCP_USERSCRIPT_GUIDE.md (complete guide)
β ββ No β
β
ββ Need example?
ββ Yes β Use
-
Always use absolute paths when injecting scripts:
/path/to/WebMCP/webmcp-userscripts/scripts/[site]/dist/[site].user.js -
Tab IDs change frequently - always re-fetch before use
-
React sites need special handling - use the React helpers from the guides
-
Build before inject - always run
pnpm run buildafter changes -
Tools may not appear immediately - reload tab and wait 1-2 seconds if needed
- Playwright MCP - Browser automation and selector discovery
- WebMCP Extension Tools - Tab management and script injection
- Website Tools - Appear after userscript injection (site-specific)
Tool name: mcp_mcp-b_extension_tool_execute_user_script
Parameters:
filePath: Absolute path to built .user.js filetabId: Target browser tab ID
| Issue | Solution | Reference |
|---|---|---|
| Tools not appearing | Reload tab, wait 2s, list again | WEBMCP_USERSCRIPT_GUIDE.md |
| React text not working | Use native value setter | |
| Can't find selectors | Use multiple strategies | WEBMCP_USERSCRIPT_GUIDE.md Phase 1 |
| Script won't inject | Check absolute path, rebuild | AI_AUTOMATION_PROMPT.md |
WebMCP Userscripts is a TypeScript monorepo for building Tampermonkey userscripts that inject MCP-B (Model Context Protocol - Browser) servers into websites. This enables AI assistants to interact with web applications through structured tools rather than brittle DOM manipulation.
- π§ TypeScript-first development with modern tooling
- π¦ Vite + vite-plugin-monkey for optimized userscript bundling
- π§ͺ Automated testing with Puppeteer
- ποΈ pnpm workspace monorepo structure
- π― Pre-built MCP-B integration patterns
- β‘ Hot reload development workflow
See the comprehensive guide in WEBMCP_USERSCRIPT_GUIDE.md for:
- Setting up development environment
- Creating new userscripts
- Testing and debugging
- NEW: Production deployment and script registration
- Contributing to the project
After testing your userscript, register it for automatic execution:
mcp_mcp-b_extension_tool_userscripts_register({
filePath: "/absolute/path/to/dist/script.user.js",
id: "sitename-mcp-server",
matches: ["https://domain/*"],
runAt: "document_start",
world: "MAIN"
})Benefits: Auto-activation, no manual injection, persistent across sessions.
MIT License - see LICENSE file for details.