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¶
How the install command was determined. |
|
Plan for installing an MCP server. |
|
Result of an installation attempt. |
|
Service for searching, configuring, and installing MCP servers. |
Module Contents¶
- class haive.mcp.installer_service.InstallMethod[source]¶
-
How the install command was determined.
Initialize self. See help(type(self)) for accurate signature.
- 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 customapproval_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
InstallPlanand returnsTrueto approve. IfNone, 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. IfNone, 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_callbackif set, otherwise prompts on stdin.- Parameters:
plan (InstallPlan) – The install plan to approve.
- Returns:
Trueif approved.- Return type:
- generate_claude_desktop_config(server_name)[source]¶
Generate a Claude Desktop
mcp.jsonconfig entry.
- generate_langchain_config(server_name)[source]¶
Generate a
langchain-mcp-adapterscompatible config.
- generate_mcp_server_config(server_name)[source]¶
Generate an
MCPServerConfigfor a server.- Parameters:
server_name (str) – Server name.
- Returns:
MCPServerConfigready to use withMCPManager.- Return type:
- async install(plan)[source]¶
Execute an install plan.
Verifies the command is available, then attempts installation.
- Parameters:
plan (InstallPlan) – Approved install plan.
- Returns:
InstallResultwith success status.- Return type:
- 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:
InstallPlanorNoneif server not found.- Return type:
InstallPlan | None
- async search_and_install(query)[source]¶
Full pipeline: search → plan → approve → install.
- Parameters:
query (str) – Search query (e.g.,
"postgres","filesystem").- Returns:
InstallResultorNoneif 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