haive.mcp.tools.server_selector¶
Intelligent MCP server selection and filtering tools for AI agents.
This module provides sophisticated tools for filtering, selecting, and recommending MCP servers based on various criteria including prefixes, capabilities, task analysis, and performance metrics. Designed to help AI agents make intelligent decisions about which servers to use for specific tasks.
- The server selector provides:
Namespace/prefix-based filtering for organized server groups
Capability-based server recommendations
Task analysis for automatic server selection
Performance-aware server ranking
Interactive selection interfaces
Smart server combinations and workflows
- Classes:
MCPServerSelector: Main class for intelligent server selection ServerFilter: Flexible filtering system for servers TaskAnalyzer: Analyzes tasks to recommend appropriate servers ServerRecommender: Provides smart server recommendations
Example
Basic server selection:
from haive.mcp.tools import MCPServerSelector
from haive.mcp.documentation import MCPDocumentationLoader
# Create selector with all available servers
loader = MCPDocumentationLoader()
all_servers = loader.load_all_mcp_documents()
selector = MCPServerSelector(all_servers)
# Filter by prefix (organization/namespace)
anthropic_servers = selector.filter_by_prefix("anthropic/")
openai_servers = selector.filter_by_prefix("openai/")
# Get recommendations for a task
task = "I need to analyze a GitHub repository for security issues"
recommendations = selector.recommend_for_task(task)
# Interactive selection
chosen_servers = await selector.interactive_select(
"Choose servers for code analysis",
categories=["development", "security"]
)
Note
This system is designed to make server selection intelligent and context-aware, reducing the need for manual server configuration.
Classes¶
Intelligent MCP server selection and recommendation system. |
|
Flexible filtering system for MCP servers. |
|
Score and metadata for a server recommendation. |
|
Analyzes task descriptions to determine server requirements. |
|
Analyzed requirements from a task description. |
Module Contents¶
- class haive.mcp.tools.server_selector.MCPServerSelector(servers=None)[source]¶
Intelligent MCP server selection and recommendation system.
Initialize server selector.
- Parameters:
servers (list[dict[str, Any]] | None) – List of server documentation. If None, loads all available.
- create_config_for_selection(selected_servers, lazy_init=True)[source]¶
Create MCPConfig for selected servers.
- Parameters:
- Returns:
MCPConfig with selected servers
- Return type:
- async interactive_select(prompt='Select MCP servers to use:', categories=None, prefixes=None, max_selections=None)[source]¶
Interactive server selection interface.
- class haive.mcp.tools.server_selector.ServerFilter(servers)[source]¶
Flexible filtering system for MCP servers.
Initialize filter with server list.
- filter_by_capability_keyword(keyword)[source]¶
Filter servers by capability keyword in description.
- class haive.mcp.tools.server_selector.ServerScore[source]¶
Score and metadata for a server recommendation.
- class haive.mcp.tools.server_selector.TaskAnalyzer[source]¶
Analyzes task descriptions to determine server requirements.
Initialize task analyzer.