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ΒΆ

MCPAssistant

AI-friendly MCP server selection and configuration assistant.

ServerRecommendation

A server recommendation with detailed reasoning.

SmartConfiguration

A complete MCP configuration with metadata.

TaskMatcher

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

get_selection_reasoning() strΒΆ

Get the reasoning for the last selection.

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.

capabilities: list[str]ΒΆ
confidence: floatΒΆ
estimated_setup_time: intΒΆ
fallback_servers: list[str]ΒΆ
reasoning: strΒΆ
required_env_vars: list[str]ΒΆ
server_name: strΒΆ
class mcp.tools.ai_assistant.SmartConfigurationΒΆ

A complete MCP configuration with metadata.

config: haive.mcp.config.MCPConfigΒΆ
estimated_capabilities: list[str]ΒΆ
fallback_servers: list[str]ΒΆ
primary_servers: list[str]ΒΆ
reasoning: strΒΆ
setup_complexity: strΒΆ
warnings: list[str]ΒΆ
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ΒΆ