haive.mcp

Haive MCP - Dynamic Model Context Protocol Integration.

This package provides dynamic MCP (Model Context Protocol) integration for Haive agents, enabling them to discover and use external tools and resources at runtime.

Key Components

  • MCPManager: Central manager for MCP server lifecycle and tool management

  • MCPAgent: Production-ready agent with static MCP configuration

  • IntelligentMCPAgent: AI-powered agent with automatic server discovery

  • TransferableMCPAgent: Agent that can share tools with other agents

Quick Start

Basic MCP Agent Usage

from haive.mcp import MCPAgent, MCPConfig
from haive.core.engine import AugLLMConfig

# Create agent with MCP capabilities
agent = MCPAgent(
    engine=AugLLMConfig(),
    mcp_config=MCPConfig(
        enabled=True,
        servers={
            "filesystem": {
                "transport": "stdio",
                "command": "npx",
                "args": ["-y", "@modelcontextprotocol/server-filesystem"]
            }
        }
    )
)

# Initialize and use
await agent.setup()
result = await agent.arun({"messages": [...]})

Dynamic Discovery with IntelligentMCPAgent

from haive.mcp import IntelligentMCPAgent

# Create agent with auto-discovery
agent = IntelligentMCPAgent(
    engine=AugLLMConfig(),
    auto_discover=True,
    require_approval=True
)

# Agent will automatically find and install needed MCP servers
result = await agent.arun({
    "messages": [{"role": "user", "content": "Search web and save to database"}]
})

Available Classes

Configuration

  • MCPConfig - Main configuration for MCP integration

  • MCPServerConfig - Individual server configuration

  • MCPTransport - Transport protocol enumeration

Agents

  • MCPAgent - Basic MCP-enabled agent

  • IntelligentMCPAgent - Agent with automatic discovery

  • TransferableMCPAgent - Agent with tool sharing capabilities

Management

  • MCPManager - Server lifecycle management

  • MCPHealthStatus - Health monitoring

  • MCPRegistrationResult - Registration status

Utilities

  • MCPMixin - Add MCP capabilities to existing agents

  • MCPServerDiscovery - Discover available servers

  • MCPDocumentationLoader - Load server documentation

Submodules