mcp.downloader.installers ========================= .. py:module:: mcp.downloader.installers .. autoapi-nested-parse:: Installer plugins for different MCP server types. This module provides installer implementations for various installation methods including NPM, pip, Git, Docker, binary downloads, and more. .. rubric:: Examples Using installers directly: .. code-block:: python installer = NPMInstaller() if await installer.can_handle(server_config, template): result = await installer.install(server_config, template, install_dir) Classes: MCPInstaller: Abstract base class for installers NPMInstaller: Handles NPM package installations PipInstaller: Handles Python pip installations GitInstaller: Handles Git repository cloning DockerInstaller: Handles Docker image pulling BinaryInstaller: Handles binary executable downloads CurlInstaller: Handles direct HTTP downloads Version: 1.0.0 Author: Haive MCP Team Attributes ---------- .. autoapisummary:: mcp.downloader.installers.logger Classes ------- .. autoapisummary:: mcp.downloader.installers.BinaryInstaller mcp.downloader.installers.CurlInstaller mcp.downloader.installers.DockerInstaller mcp.downloader.installers.GitInstaller mcp.downloader.installers.MCPInstaller mcp.downloader.installers.NPMInstaller mcp.downloader.installers.PipInstaller Module Contents --------------- .. py:class:: BinaryInstaller Bases: :py:obj:`MCPInstaller` Installer for binary executable MCP servers. Downloads and installs pre-compiled binary executables. .. rubric:: Examples Binary installation: .. code-block:: python installer = BinaryInstaller() result = await installer.install( server_config, template, install_dir ) .. py:method:: can_handle(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate) -> bool :async: Check if this is a binary installation. .. py:method:: install(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> dict[str, Any] :async: Download and install binary executable. :param server_config: Server configuration :param template: Server template :param install_dir: Installation directory :returns: Installation result dictionary .. py:method:: verify(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> bool :async: Verify binary installation. Checks if the binary exists and is executable. :returns: True if binary exists and is executable .. py:class:: CurlInstaller Bases: :py:obj:`MCPInstaller` Installer for direct HTTP downloads. Downloads files directly via HTTP/HTTPS without package managers. .. rubric:: Examples Curl installation: .. code-block:: python installer = CurlInstaller() result = await installer.install( server_config, template, install_dir ) .. py:method:: can_handle(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate) -> bool :async: Check if this is a curl/HTTP download. .. py:method:: install(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> dict[str, Any] :async: Download files via HTTP. :param server_config: Server configuration :param template: Server template :param install_dir: Installation directory :returns: Installation result dictionary .. py:method:: verify(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> bool :async: Verify curl installation. Checks if the expected files exist. :returns: True if installation directory exists with files .. py:class:: DockerInstaller Bases: :py:obj:`MCPInstaller` Installer for Docker-based MCP servers. Handles pulling Docker images for containerized MCP servers. .. rubric:: Examples Docker installation: .. code-block:: python installer = DockerInstaller() result = await installer.install( server_config, template, install_dir ) .. py:method:: can_handle(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate) -> bool :async: Check if this is a Docker installation. .. py:method:: install(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> dict[str, Any] :async: Pull Docker image. :param server_config: Server configuration :param template: Server template :param install_dir: Installation directory :returns: Installation result dictionary .. py:method:: verify(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> bool :async: Verify Docker installation. Checks if the Docker image exists locally. :returns: True if image is available .. py:class:: GitInstaller Bases: :py:obj:`MCPInstaller` Installer for Git repository-based MCP servers. Handles cloning Git repositories and running post-install commands. .. rubric:: Examples Git installation: .. code-block:: python installer = GitInstaller() result = await installer.install( server_config, template, install_dir ) .. py:method:: can_handle(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate) -> bool :async: Check if this is a Git installation. .. py:method:: install(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> dict[str, Any] :async: Clone Git repository and run post-install commands. :param server_config: Server configuration :param template: Server template :param install_dir: Installation directory :returns: Installation result dictionary .. py:method:: verify(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> bool :async: Verify Git installation. Checks if the repository was cloned successfully. :returns: True if repository exists with .git directory .. py:class:: MCPInstaller Bases: :py:obj:`abc.ABC` Abstract base class for MCP installers. All installer implementations must inherit from this class and implement the required methods. .. rubric:: Examples Creating a custom installer: .. code-block:: python class MyInstaller(MCPInstaller): async def can_handle(self, server_config, template): return template.installation_method == "custom" async def install(self, server_config, template, install_dir): # Custom installation logic return {"success": True} async def verify(self, server_config, template, install_dir): # Verification logic return True .. py:method:: can_handle(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate) -> bool :abstractmethod: :async: Check if this installer can handle the given configuration. :param server_config: Server configuration :param template: Server template :returns: True if this installer can handle the installation .. py:method:: install(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> dict[str, Any] :abstractmethod: :async: Install the MCP server. :param server_config: Server configuration :param template: Server template :param install_dir: Installation directory :returns: Dict with installation results including success status .. py:method:: verify(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> bool :abstractmethod: :async: Verify the installation was successful. :param server_config: Server configuration :param template: Server template :param install_dir: Installation directory :returns: True if installation is verified .. py:class:: NPMInstaller Bases: :py:obj:`MCPInstaller` Installer for NPM-based MCP servers. Handles installation of MCP servers distributed as NPM packages. Supports both global and local installations. .. rubric:: Examples NPM installation: .. code-block:: python installer = NPMInstaller() result = await installer.install( server_config, template, Path("/home/user/.mcp/servers") ) .. py:method:: can_handle(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate) -> bool :async: Check if this is an NPM installation. :returns: True if template uses NPM installation method .. py:method:: install(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> dict[str, Any] :async: Install NPM package. Attempts global installation first, falls back to local if that fails. :param server_config: Server configuration :param template: Server template :param install_dir: Installation directory :returns: Installation result dictionary .. py:method:: verify(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> bool :async: Verify NPM installation. Checks if the package is accessible via npx. :returns: True if package is installed and accessible .. py:class:: PipInstaller Bases: :py:obj:`MCPInstaller` Installer for Python pip-based MCP servers. Handles installation of MCP servers distributed as Python packages. .. rubric:: Examples Pip installation: .. code-block:: python installer = PipInstaller() result = await installer.install( server_config, template, install_dir ) .. py:method:: can_handle(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate) -> bool :async: Check if this is a pip installation. .. py:method:: install(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> dict[str, Any] :async: Install Python package via pip. :param server_config: Server configuration :param template: Server template :param install_dir: Installation directory :returns: Installation result dictionary .. py:method:: verify(server_config: haive.mcp.downloader.config.ServerConfig, template: haive.mcp.downloader.config.ServerTemplate, install_dir: pathlib.Path) -> bool :async: Verify pip installation. Checks if the module can be imported. :returns: True if module is installed and importable .. py:data:: logger