Dynamic Tool Registration
Conditional Tools Based on User State
Register tools based on authentication, permissions, or user roles:Page-Specific Tools
Register tools based on the current route - tools appear and disappear as users navigate:Context Engineering
For comprehensive context engineering patterns including URL-based scoping, progressive disclosure, role-based tools, component lifecycle scoping, and feature flags, see the dedicated Context Engineering guide.
enabled prop on useWebMCP to conditionally register tools.
State Synchronization
React State Integration
Tools can access and update React state:Context API Integration
Share tools across the component tree using React Context:Advanced Validation
Complex Input Validation
Zod supports sophisticated validation patterns:Custom Validation Logic
Add business logic validation in your handler:Error Handling
Handle errors gracefully and provide clear feedback:Performance Optimization
Use debouncing, throttling, and caching for expensive operations:Multi-Tab Tool Collection
The MCP-B Extension collects and maintains tools from all open tabs simultaneously, making them available to agents regardless of which tab is currently active.Key behavior: Unlike traditional tab-scoped approaches, the extension aggregates tools from every open tab, giving agents access to your entire browsing context at once.
How Tool Collection Works
When you have multiple tabs open with WebMCP servers:Tool Routing
When an agent calls a tool:1
Agent requests tool
Agent calls a tool (e.g.,
github_com_create_issue)2
Extension identifies source
Extension determines which tab owns that tool
3
Extension routes call
If the tab is open, the tool is executed immediately. If the tab was closed, the extension may need to reopen it.
4
Results returned
Tool execution results are returned to the agent
Design Implications
Since all tools from all tabs are visible to the agent:Tool Naming Matters
Tool Naming Matters
Use descriptive, namespaced tool names to avoid confusion:
Context in Descriptions
Context in Descriptions
Since agents see all tools at once, make descriptions specific:
Tool Availability
Tool Availability
Tools appear and disappear as you open/close tabs:
Cross-Tab Workflows
Cross-Tab Workflows
Agents can naturally compose tools from different tabs:
Managing Tool Overload
When many tabs are open, agents see many tools. Use context engineering patterns to help:Multi-Step Workflows
Stateful Multi-Step Operations
Cross-Site Tool Composition
One of the most powerful features of the MCP-B Extension is the ability to compose tools from different websites. Tools from one site can use data from another site, enabling complex multi-site workflows.Key advantage: Each site exposes its existing functionality as MCP tools, and the extension handles routing calls between them. The user maintains separate authentication contexts for each site.
How Cross-Site Calls Work
Example: Cross-Site Tool Composition
Site A exposes cart data:Example: Content Aggregation
Agents can fetch content from one site and post to another:Best Practices for Cross-Site Tools
Use descriptive tool names
Use descriptive tool names
Include the site domain or purpose in tool names to avoid collisions:
Return structured data
Return structured data
Make it easy for tools on other sites to consume your data:
Keep tools focused
Keep tools focused
Each tool should do one thing well, making them easier to compose:
Document data formats
Document data formats
Use clear descriptions and schemas so other sites know what to expect:
Security Considerations
Read-Only Context Tools
Exposing Application State
Security Best Practices
Always sanitize inputs, implement rate limiting, and validate permissions. See the Security Guide for comprehensive patterns including:- Input sanitization with DOMPurify
- Rate limiting implementations
- Permission checks and auth validation
- Handling sensitive data securely
Next Steps
Package Documentation
Deep dive into package APIs
Examples
See complete working examples
Troubleshooting
Common issues and solutions
Discord Community
Get help from the community
