haive.mcp.integration.aug_llm_mcp_extension

Extension module to add MCP support to AugLLMConfig.

This module provides utilities and mixins to enhance AugLLMConfig with MCP integration capabilities, allowing seamless use of MCP tools, resources, and prompts within the Haive agent framework.

Classes

MCPAugLLMConfig

Extended AugLLMConfig with MCP integration support.

MCPPromptTemplate

Model representing an MCP prompt template.

MCPResource

Model representing an MCP resource.

MCPToolWrapper

Wrapper to convert MCP tools to Haive-compatible tools.

Functions

create_mcp_enabled_aug_config(name[, model, mcp_servers])

Factory function to create an MCP-enabled AugLLMConfig.

extend_aug_llm_config_for_mcp(base_config, mcp_config)

Utility function to extend an existing AugLLMConfig with MCP support.

Module Contents

class haive.mcp.integration.aug_llm_mcp_extension.MCPAugLLMConfig

Bases: haive.core.engine.aug_llm.AugLLMConfig

Extended AugLLMConfig with MCP integration support.

This class extends the base AugLLMConfig to add MCP-specific fields and functionality, enabling agents to use MCP servers for tools, resources, and prompts.

enhance_system_prompt_with_mcp()

Enhance the system prompt with MCP information.

Returns:

Enhanced system prompt including MCP resources and capabilities

Return type:

str

async get_mcp_resource_content(uri)

Fetch content for an MCP resource.

Parameters:

uri (str) – Resource URI

Returns:

Resource content

Return type:

Any

async setup_mcp()

Initialize MCP integration.

Sets up the MCP manager, discovers tools, loads resources, and configures prompts based on the MCP configuration.

Return type:

None

class haive.mcp.integration.aug_llm_mcp_extension.MCPPromptTemplate(/, **data)

Bases: pydantic.BaseModel

Model representing an MCP prompt template.

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.

Parameters:

data (Any)

class haive.mcp.integration.aug_llm_mcp_extension.MCPResource(/, **data)

Bases: pydantic.BaseModel

Model representing an MCP resource.

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.

Parameters:

data (Any)

class haive.mcp.integration.aug_llm_mcp_extension.MCPToolWrapper(**kwargs)

Bases: langchain_core.tools.BaseTool

Wrapper to convert MCP tools to Haive-compatible tools.

This wrapper allows MCP tools to be used seamlessly within the Haive framework by adapting their interface to match BaseTool expectations.

Initialize the tool.

Raises:

TypeError – If args_schema is not a subclass of pydantic BaseModel or dict.

Parameters:

kwargs (Any)

description: str

Used to tell the model how/when/why to use the tool.

You can provide few-shot examples as a part of the description.

name: str

The unique name of the tool that clearly communicates its purpose.

async haive.mcp.integration.aug_llm_mcp_extension.create_mcp_enabled_aug_config(name, model='gpt-4o-mini', mcp_servers=None, **kwargs)

Factory function to create an MCP-enabled AugLLMConfig.

Parameters:
  • name (str) – Configuration name

  • model (str) – LLM model to use

  • mcp_servers (dict[str, haive.mcp.config.MCPServerConfig] | None) – Dictionary of MCP server configurations

  • **kwargs – Additional AugLLMConfig parameters

Returns:

Initialized MCPAugLLMConfig with MCP integration

Return type:

MCPAugLLMConfig

haive.mcp.integration.aug_llm_mcp_extension.extend_aug_llm_config_for_mcp(base_config, mcp_config)

Utility function to extend an existing AugLLMConfig with MCP support.

Parameters:
  • base_config (haive.core.engine.aug_llm.AugLLMConfig) – Existing AugLLMConfig instance

  • mcp_config (haive.mcp.config.MCPConfig) – MCP configuration to add

Returns:

MCPAugLLMConfig with MCP support added

Return type:

MCPAugLLMConfig