haive.mcp.downloader.integration¶
Agent integration for MCP Downloader.
This module provides integration between the MCP downloader system and Haive agents, enabling automatic tool, resource, and prompt discovery from downloaded MCP servers.
Examples
Basic integration:
from haive.mcp.downloader import MCPAgentIntegration
from haive import core
integration = MCPAgentIntegration() agent = await integration.create_agent_with_mcp_servers(
engine=engine, server_names=[“filesystem”, “github”]
)
Auto-discovery integration:
agent = await integration.create_agent_with_auto_discovery( engine=engine, limit=10, categories=["official", "core"])
- Classes:
MCPAgentIntegration: Main integration class MCPServerConnection: Connection management for MCP servers MCPCapabilityExtractor: Extract tools, resources, and prompts
Classes¶
Integration between MCP downloader and Haive agents. |
|
Extracts tools, resources, and prompts from MCP servers. |
|
Manages connection to an MCP server. |
Module Contents¶
- class haive.mcp.downloader.integration.MCPAgentIntegration(config_file=None, install_dir=None)¶
Integration between MCP downloader and Haive agents.
This class provides high-level methods to create agents with MCP servers automatically configured and connected.
- downloader¶
General MCP downloader instance
- extractor¶
Capability extractor
- manager¶
MCP manager for agent integration
Examples
Creating integrated agent:
Initialize MCP agent integration.
- Parameters:
- async create_agent_with_auto_discovery(engine, limit=None, categories=None, tags=None, agent_class=MCPAgent, **agent_kwargs)¶
Create an agent with auto-discovered MCP servers.
- Parameters:
- Returns:
Configured agent with discovered servers
- Return type:
haive.mcp.agents.MCPAgent
Examples
Auto-discovery agent:
- async create_agent_with_mcp_servers(engine, server_names, agent_class=MCPAgent, install_if_missing=True, **agent_kwargs)¶
Create an agent with specific MCP servers.
- Parameters:
- Returns:
Configured agent with MCP servers
- Return type:
haive.mcp.agents.MCPAgent
Examples
Creating agent with servers:
- async create_transferable_agent_team(engine, num_agents, server_distribution='shared', **agent_kwargs)¶
Create a team of transferable MCP agents.
- Parameters:
engine (haive.core.engine.aug_llm.AugLLMConfig) – Haive engine configuration
num_agents (int) – Number of agents to create
server_distribution (str) – How to distribute servers - “shared”: All agents share all servers - “split”: Divide servers among agents - “specialized”: Each agent gets specific categories
**agent_kwargs – Additional agent arguments
- Returns:
List of configured transferable agents
- Return type:
list[haive.mcp.agents.TransferableMCPAgent]
Examples
Creating agent team:
- class haive.mcp.downloader.integration.MCPCapabilityExtractor¶
Extracts tools, resources, and prompts from MCP servers.
This class provides methods to extract and organize capabilities from multiple MCP servers for use with agents.
- connections¶
Active server connections
- all_tools¶
Aggregated tools from all servers
- all_resources¶
Aggregated resources
- all_prompts¶
Aggregated prompts
Examples
Extracting capabilities:
Initialize the capability extractor.
- async add_server(name, config, transport='stdio')¶
Add and connect to an MCP server.
- Parameters:
- Returns:
True if server added successfully
- Return type:
Examples
Adding a server:
- async add_servers_from_config(servers, config_dir)¶
Add multiple servers from configuration.
- Parameters:
servers (list[haive.mcp.downloader.config.ServerConfig]) – List of server configurations
config_dir (pathlib.Path) – Directory containing server configs
- Returns:
Dict mapping server names to success status
- Return type:
Examples
Adding from config:
- get_all_prompts()¶
Get all discovered prompts.
- get_all_resources()¶
Get all discovered resources.
- get_all_tools()¶
Get all discovered tools.
Examples
Getting tools:
- get_tools_by_capability(capability)¶
Get tools that have a specific capability.
- class haive.mcp.downloader.integration.MCPServerConnection(/, **data)¶
Bases:
pydantic.BaseModelManages connection to an MCP server.
- Parameters:
data (Any)
- name¶
Server name identifier
- config¶
Server configuration
- transport¶
Transport type (stdio, sse, etc.)
- connection¶
Active connection object
- tools¶
Discovered tools from the server
- resources¶
Available resources
- prompts¶
Available prompts
- connected¶
Connection status
Examples
Creating a connection:
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- async connect()¶
Establish connection to the MCP server.
- Returns:
True if connection successful
- Return type:
Examples
Connecting to server:
- async discover_capabilities()¶
Discover tools, resources, and prompts from the server.
Examples
Discovering capabilities:
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].