mcp.tools.ai_assistantΒΆ
AI-friendly MCP server selection and configuration assistant.
This module provides tools specifically designed for AI agents to automatically select, configure, and use MCP servers based on task analysis and intelligent recommendations. It minimizes the need for manual configuration while maximizing the effectiveness of server selection.
- The assistant provides:
Automatic server selection based on task analysis
Smart configuration generation with minimal setup
Performance-aware server combinations
Fallback strategies for failed servers
Context-aware capability matching
- Classes:
MCPAssistant: Main AI-friendly server selection assistant SmartConfig: Intelligent configuration generator TaskMatcher: Advanced task-to-server matching system
Example
AI agent usage:
from haive.mcp.tools import MCPAssistant
# Create assistant
assistant = MCPAssistant()
# Automatically select servers for a task
task = "I need to analyze Python code in a GitHub repo for security issues"
config = await assistant.auto_configure_for_task(task)
# Create agent with optimal configuration
agent = MCPAgent(
engine=engine,
mcp_config=config,
name="security_analysis_agent"
)
# Assistant provides reasoning
reasoning = assistant.get_selection_reasoning()
print(f"Selected servers because: {reasoning}")
Note
Designed to work seamlessly with AI agents that need to dynamically adapt their capabilities based on task requirements.
AttributesΒΆ
ClassesΒΆ
AI-friendly MCP server selection and configuration assistant. |
|
A server recommendation with detailed reasoning. |
|
A complete MCP configuration with metadata. |
|
Advanced task-to-server matching with learning capabilities. |
Module ContentsΒΆ
- class mcp.tools.ai_assistant.MCPAssistant(cache_enabled: bool = True)ΒΆ
AI-friendly MCP server selection and configuration assistant.
- async auto_configure_for_task(task_description: str, prefer_simple_setup: bool = True, max_servers: int = 3, include_fallbacks: bool = True) SmartConfiguration ΒΆ
Automatically configure MCP servers for a task.
- Parameters:
task_description β Natural language description of the task
prefer_simple_setup β Prefer servers with easier setup
max_servers β Maximum number of servers to include
include_fallbacks β Whether to include fallback servers
- Returns:
SmartConfiguration with optimized setup
- explain_recommendation(server_name: str) dict[str, Any] ΒΆ
Get detailed explanation for a server recommendation.
- Parameters:
server_name β Name of the server to explain
- Returns:
Dictionary with detailed explanation
- async validate_configuration(config: haive.mcp.config.MCPConfig) dict[str, Any] ΒΆ
Validate a configuration and provide feedback.
- Parameters:
config β MCP configuration to validate
- Returns:
Validation results with issues and suggestions
- analyzerΒΆ
- cache_enabled = TrueΒΆ
- cached_configsΒΆ
- last_reasoning = ''ΒΆ
- matcherΒΆ
- selectorΒΆ
- class mcp.tools.ai_assistant.ServerRecommendationΒΆ
A server recommendation with detailed reasoning.
- class mcp.tools.ai_assistant.SmartConfigurationΒΆ
A complete MCP configuration with metadata.
- config: haive.mcp.config.MCPConfigΒΆ
- class mcp.tools.ai_assistant.TaskMatcherΒΆ
Advanced task-to-server matching with learning capabilities.
- get_server_recommendation_score(server_name: str, task_pattern: str | None, task_description: str) float ΒΆ
Calculate recommendation score for a server.
- Parameters:
server_name β Name of the server
task_pattern β Matched task pattern
task_description β Original task description
- Returns:
Score from 0.0 to 1.0
- match_task_to_pattern(task_description: str) str | None ΒΆ
Match a task description to a known pattern.
- Parameters:
task_description β Natural language task description
- Returns:
Pattern name if matched, None otherwise
- server_profilesΒΆ
- success_historyΒΆ
- task_patternsΒΆ
- mcp.tools.ai_assistant.loggerΒΆ