Overview
Smart Routing is MCPHub’s intelligent tool discovery system that uses vector semantic search to automatically find the most relevant tools for any given task. Instead of manually specifying which tools to use, AI clients can describe what they want to accomplish, and Smart Routing will identify and provide access to the most appropriate tools.How Smart Routing Works
1. Tool Indexing
When servers start up, Smart Routing automatically:- Discovers all available tools from MCP servers
- Extracts tool metadata (names, descriptions, parameters)
- Converts tool information to vector embeddings
- Stores embeddings in PostgreSQL with pgvector
2. Semantic Search
When a query is made:- User queries are converted to vector embeddings
- Similarity search finds matching tools using cosine similarity
- Dynamic thresholds filter out irrelevant results
- Results are ranked by relevance score
3. Intelligent Filtering
Smart Routing applies several filters:- Relevance Threshold: Only returns tools above similarity threshold
- Context Awareness: Considers conversation context
- Tool Availability: Ensures tools are currently accessible
- Permission Filtering: Respects user access permissions
4. Tool Execution
Found tools can be directly executed:- Parameter validation ensures correct tool usage
- Error handling provides helpful feedback
- Response formatting maintains consistency
- Logging tracks tool usage for analytics
Prerequisites
Smart Routing requires additional setup compared to basic MCPHub usage:Required Components
- PostgreSQL with pgvector: Vector database for embeddings storage
- Embedding Service: OpenAI API or compatible service
- Environment Configuration: Proper configuration variables
Using Smart Routing
Smart Routing Endpoint
Access Smart Routing through the special$smart endpoint:
- HTTP MCP
- SSE (Legacy)
Group-Scoped Smart Routing
Smart Routing now supports group-scoped searches, allowing you to limit tool discovery to servers within a specific group:Using Group-Scoped Smart Routing
Using Group-Scoped Smart Routing
Connect your AI client to a group-specific Smart Routing endpoint:This endpoint will only search for tools within servers that belong to the “production” group.Benefits:
- Focused Results: Only tools from relevant servers are returned
- Better Performance: Reduced search space for faster queries
- Environment Isolation: Keep development, staging, and production tools separate
- Access Control: Limit tool discovery based on user permissions
Example: Environment-Based Groups
Example: Environment-Based Groups
Create groups for different environments:Each endpoint will only return tools from servers in that specific environment group.
Example: Team-Based Groups
Example: Team-Based Groups
Organize tools by team or department:This enables teams to have focused access to their relevant toolsets.
How It Works
How It Works
When using
$smart/{group}:- The system identifies the specified group
- Retrieves all servers belonging to that group
- Filters the tool search to only those servers
- Returns results scoped to the group’s servers
Progressive Disclosure Mode
Progressive Disclosure is an optimization feature that reduces token usage when working with Smart Routing. When enabled, the tool discovery workflow changes from a 2-step to a 3-step process.What is Progressive Disclosure?
What is Progressive Disclosure?
By default, Smart Routing returns full tool information including complete parameter schemas in
search_tools results. This can consume significant tokens when dealing with tools that have complex input schemas.Progressive Disclosure changes this behavior:search_toolsreturns only tool names and descriptions (minimal info)- A new
describe_toolendpoint provides full parameter schema on demand call_toolexecutes the tool as before
- Working with many tools with complex schemas
- Token usage optimization is important
- AI clients need to browse many tools before selecting one
Enabling Progressive Disclosure
Enabling Progressive Disclosure
Enable Progressive Disclosure through the Settings page or environment variable:Via Settings UI:
- Navigate to Settings → Smart Routing
- Enable the “Progressive Disclosure” toggle
- The change takes effect immediately
Standard Mode (Default)
Standard Mode (Default)
When Progressive Disclosure is disabled (default), Smart Routing provides two tools:Workflow:
This mode is simpler but uses more tokens due to full schemas in search results.
search_tools → call_tool| Tool | Purpose |
|---|---|
search_tools | Find tools by query, returns full tool info including inputSchema |
call_tool | Execute a tool with the provided arguments |
Progressive Disclosure Mode
Progressive Disclosure Mode
When Progressive Disclosure is enabled, Smart Routing provides three tools:Workflow:
Example workflow:
search_tools → describe_tool → call_tool| Tool | Purpose |
|---|---|
search_tools | Find tools by query, returns only name and description |
describe_tool | Get full schema for a specific tool (new) |
call_tool | Execute a tool with the provided arguments |
- AI calls
search_toolswith query “file operations” - Results show tool names and descriptions (minimal tokens)
- AI calls
describe_toolfor a specific tool to get fullinputSchema - AI calls
call_toolwith the correct arguments
Response Format Comparison
Response Format Comparison
Standard Mode search_tools response:Progressive Disclosure Mode search_tools response:describe_tool response:
Troubleshooting
Database Connection Issues
Database Connection Issues
Symptoms:
- Smart Routing not available
- Database connection errors
- Embedding storage failures
- Verify PostgreSQL is running
- Check DB_URL format
- Ensure pgvector extension is installed
- Test connection manually:
Embedding Service Problems
Embedding Service Problems
Symptoms:
- Tool indexing failures
- Query processing errors
- API rate limit errors
- Verify API key validity
- Check network connectivity
- Monitor rate limits
- Test embedding service:
Poor Search Results
Poor Search Results
Symptoms:
- Irrelevant tools returned
- Low relevance scores
- Missing expected tools
- Adjust similarity threshold
- Re-index tools with better descriptions
- Use more specific queries
- Check tool metadata quality
Performance Issues
Performance Issues
Symptoms:
- Slow query responses
- High database load
- Memory usage spikes
- Optimize database configuration
- Increase cache sizes
- Reduce batch sizes
- Monitor system resources
Best Practices
Query Writing
Tool Descriptions
System Maintenance
Regular Re-indexing: Periodically re-index tools to ensure embedding quality.
Monitor Performance: Track query patterns and optimize based on usage.
Update Models: Consider updating to newer embedding models as they become available.