Basic Usage
Create a router and define your tools:prefix="math", your tools become math_add and math_subtract.
Router Options
TheMCPRouter constructor accepts optional metadata:
Defining Resources
Use@router.resource() to define resources:
Defining Prompts
Use@router.prompt() to define prompts:
Multiple Routers
Organize different domains into separate routers:- Tools:
math_add,math_multiply,weather_get_weather - Resources:
weather_weather://forecast
Nested Routers
Routers can include other routers:math_arithmetic_add, math_factorial
Without Prefix
You can include routers without a prefix:Enabling/Disabling Routers
Use theenabled flag to conditionally include routers:
- Feature flags
- Environment-specific routes (dev vs production)
- Temporarily disabling functionality