Authentication & Authorization
Tools run in the user’s browser context with their existing session:Security Principles
WebMCP follows these core security principles:- ✅ Tools inherit user authentication - No separate credential management needed
- ✅ Same-origin policy enforced - Tools can only access their own domain’s resources
- ✅ No credential sharing - API keys and tokens stay within the website context
- ✅ Tools respect existing permissions - Users’ access levels apply to tool actions
- ✅ User visibility - All tool actions happen in the user’s browser where they can see them
Example: Authenticated Tool
Origin Validation
The Tab Transport validates origins to prevent unauthorized access:Origin Validation Rules
Production: Explicit allowlist
Production: Explicit allowlist
Always specify exact origins in production:Never use wildcards in production:
Development: Localhost and wildcards
Development: Localhost and wildcards
For local development, you can use wildcards:
Subdomains: Explicit listing
Subdomains: Explicit listing
List each subdomain explicitly:Note: There’s no wildcard subdomain support (e.g.,
https://*.myapp.com is not supported).Content Security Policy (CSP)
WebMCP respects and works within Content Security Policy restrictions:CSP Considerations
- script-src: WebMCP polyfill needs to execute JavaScript
- connect-src: Tools may need to make API calls
- frame-ancestors: For iframe-based MCP UI integration
- worker-src: If using web workers for tool execution
Tool Security Best Practices
Validate all inputs
Validate all inputs
Always validate and sanitize tool inputs before processing:
Check authorization in handlers
Check authorization in handlers
Use HTTPS in production
Use HTTPS in production
Always serve your website over HTTPS in production:
- Protects tool execution from man-in-the-middle attacks
- Required for many browser APIs (geolocation, camera, etc.)
- Ensures secure cookie transmission
Rate limit tool executions
Rate limit tool executions
Implement rate limiting to prevent abuse:
Use annotations for destructive operations
Use annotations for destructive operations
Mark destructive operations with annotations:
Extension Security
The MCP-B extension follows browser extension security best practices:- Minimal permissions - Only requests necessary browser permissions
- Content script isolation - Content scripts run in isolated contexts
- Message validation - All cross-context messages are validated
- No remote code execution - Extension doesn’t execute arbitrary remote code
