haive.mcp.installer_service

MCP Server Installer Service with LLM fallback and HITL approval.

Provides a complete install pipeline: 1. Search the 1,960 server database for matching servers 2. Extract install command from README (primary) 3. Fall back to LLM to derive install command if extraction fails 4. HITL approval before installation (configurable) 5. Install via npx/uvx/pip and verify connectivity

The service is usable standalone or integrated into IntelligentMCPAgent.

Example

from haive.mcp.installer_service import MCPInstallerService

service = MCPInstallerService(require_approval=True)
result = await service.search_and_install("postgres")
# Searches DB → finds server → derives install → asks approval → installs

Classes

InstallMethod

How the install command was determined.

InstallPlan

Plan for installing an MCP server.

InstallResult

Result of an installation attempt.

MCPInstallerService

Service for searching, configuring, and installing MCP servers.

Module Contents

class haive.mcp.installer_service.InstallMethod[source]

Bases: str, enum.Enum

How the install command was determined.

Initialize self. See help(type(self)) for accurate signature.

class haive.mcp.installer_service.InstallPlan[source]

Plan for installing an MCP server.

class haive.mcp.installer_service.InstallResult[source]

Result of an installation attempt.

class haive.mcp.installer_service.MCPInstallerService(require_approval=True, approval_callback=None, llm_callback=None, auto_verify=True)[source]

Service for searching, configuring, and installing MCP servers.

Supports three modes for deriving install commands: 1. README extraction – parses install commands from server READMEs 2. LLM fallback – uses an LLM to analyze the repo and suggest install 3. Pattern fallback – derives from repo name conventions

HITL approval can be enabled via require_approval=True. The default approval handler prints to stdout and waits for input. Override with a custom approval_callback.

Initialize the installer service.

Parameters:
  • require_approval (bool) – Require human approval before install.

  • approval_callback (Callable[[InstallPlan], bool] | None) – Custom approval function. Receives an InstallPlan and returns True to approve. If None, uses interactive stdin prompt.

  • llm_callback (Callable[[str, str], str] | None) – Custom LLM function for install command derivation. Receives (server_name, readme_content) and returns an install command string. If None, uses a built-in prompt with langchain (if available).

  • auto_verify (bool) – Verify the command exists before installing.

async approve(plan)[source]

Request approval for an install plan.

Uses approval_callback if set, otherwise prompts on stdin.

Parameters:

plan (InstallPlan) – The install plan to approve.

Returns:

True if approved.

Return type:

bool

generate_claude_desktop_config(server_name)[source]

Generate a Claude Desktop mcp.json config entry.

Parameters:

server_name (str) – Server name.

Returns:

Dict in Claude Desktop format.

Return type:

dict[str, Any] | None

generate_langchain_config(server_name)[source]

Generate a langchain-mcp-adapters compatible config.

Parameters:

server_name (str) – Server name.

Returns:

Dict suitable for MultiServerMCPClient.

Return type:

dict[str, Any] | None

generate_mcp_server_config(server_name)[source]

Generate an MCPServerConfig for a server.

Parameters:

server_name (str) – Server name.

Returns:

MCPServerConfig ready to use with MCPManager.

Return type:

haive.mcp.config.MCPServerConfig | None

get_detail(name)[source]

Get enriched detail for a server.

Parameters:

name (str)

Return type:

dict[str, Any] | None

async install(plan)[source]

Execute an install plan.

Verifies the command is available, then attempts installation.

Parameters:

plan (InstallPlan) – Approved install plan.

Returns:

InstallResult with success status.

Return type:

InstallResult

async plan_install(server_name)[source]

Create an install plan for a server.

Tries README extraction first, then LLM fallback.

Parameters:

server_name (str) – Server name (exact or partial match).

Returns:

InstallPlan or None if server not found.

Return type:

InstallPlan | None

search(query, limit=10)[source]

Search the server database.

Parameters:
Return type:

list[dict[str, Any]]

async search_and_install(query)[source]

Full pipeline: search → plan → approve → install.

Parameters:

query (str) – Search query (e.g., "postgres", "filesystem").

Returns:

InstallResult or None if no server found / rejected.

Return type:

InstallResult | None

search_and_install_sync(query)[source]

Synchronous wrapper for search_and_install.

Parameters:

query (str)

Return type:

InstallResult | None