haive.mcp.downloader¶
MCP Server Downloader - Download, install, and manage MCP servers.
- class haive.mcp.downloader.BinaryInstaller[source]¶
Installer for binary executable MCP servers.
Downloads and installs pre-compiled binary executables.
Examples
Binary installation:
- async can_handle(server_config, template)[source]¶
Check if this is a binary installation.
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
- Return type:
- async install(server_config, template, install_dir)[source]¶
Download and install binary executable.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
install_dir (Path) – Installation directory
- Returns:
Installation result dictionary
- Return type:
- async verify(server_config, template, install_dir)[source]¶
Verify binary installation.
Checks if the binary exists and is executable.
- Returns:
True if binary exists and is executable
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
install_dir (Path)
- Return type:
- class haive.mcp.downloader.CurlInstaller[source]¶
Installer for direct HTTP downloads.
Downloads files directly via HTTP/HTTPS without package managers.
Examples
Curl installation:
- async can_handle(server_config, template)[source]¶
Check if this is a curl/HTTP download.
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
- Return type:
- async install(server_config, template, install_dir)[source]¶
Download files via HTTP.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
install_dir (Path) – Installation directory
- Returns:
Installation result dictionary
- Return type:
- async verify(server_config, template, install_dir)[source]¶
Verify curl installation.
Checks if the expected files exist.
- Returns:
True if installation directory exists with files
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
install_dir (Path)
- Return type:
- class haive.mcp.downloader.DiscoveredServer(*, name, source, source_url=None, description=None, package_name=None, repo_url=None, author=None, version=None, stars=None, tags=<factory>, metadata=<factory>)[source]¶
Information about a discovered MCP server.
- Parameters:
Examples
Discovered server info:
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.mcp.downloader.DiscoveryConfig(*, sources=<factory>, patterns=<factory>, auto_discover=False, discovery_interval=24, max_servers=100)[source]¶
Configuration for server discovery.
- Parameters:
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.mcp.downloader.DockerInstaller[source]¶
Installer for Docker-based MCP servers.
Handles pulling Docker images for containerized MCP servers.
Examples
Docker installation:
- async can_handle(server_config, template)[source]¶
Check if this is a Docker installation.
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
- Return type:
- async install(server_config, template, install_dir)[source]¶
Pull Docker image.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
install_dir (Path) – Installation directory
- Returns:
Installation result dictionary
- Return type:
- async verify(server_config, template, install_dir)[source]¶
Verify Docker installation.
Checks if the Docker image exists locally.
- Returns:
True if image is available
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
install_dir (Path)
- Return type:
- class haive.mcp.downloader.DownloadResult(*, total, successful, failed, success_rate, successful_servers=<factory>, failed_servers=<factory>, config_file=None, duration=None)[source]¶
Result of a download operation.
- Parameters:
Example
Checking results:
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.mcp.downloader.DownloaderConfig(*, install_dir=<factory>, config_dir=<factory>, log_dir=<factory>, max_concurrent=5, retry_attempts=3, retry_delay=5, health_check_enabled=True, health_check_timeout=30, backup_enabled=True, backup_dir=<factory>, templates=<factory>, servers=<factory>, discovery=<factory>)[source]¶
Overall configuration for the MCP downloader.
- Parameters:
data (Any)
install_dir (Path)
config_dir (Path)
log_dir (Path)
max_concurrent (int)
retry_attempts (int)
retry_delay (int)
health_check_enabled (bool)
health_check_timeout (int)
backup_enabled (bool)
backup_dir (Path)
templates (list[ServerTemplate])
servers (list[ServerConfig])
discovery (DiscoveryConfig)
- install_dir¶
Directory for server installations
- Type:
- config_dir¶
Directory for configuration files
- Type:
- log_dir¶
Directory for log files
- Type:
- backup_dir¶
Directory for backups
- Type:
- templates¶
List of server templates
- servers¶
List of server configurations
- discovery¶
Discovery configuration
Example
Full configuration:
- discovery: DiscoveryConfig¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- servers: list[ServerConfig]¶
- templates: list[ServerTemplate]¶
- class haive.mcp.downloader.GeneralMCPDownloader(config_file=None, install_dir=None)[source]¶
General MCP Server Downloader with configurable patterns and installers.
This is the main orchestrator class that manages the downloading, installation, and configuration of MCP servers from various sources using a plugin-based architecture.
- config¶
Downloader configuration
- installers¶
List of available installers
- discovery¶
Server discovery instance
- status_tracker¶
Server status tracking
Example
Creating and using downloader:
Note
The downloader automatically creates necessary directories and default configuration if not provided.
- __init__(config_file=None, install_dir=None)[source]¶
Initialize the General MCP Downloader.
- Parameters:
Example
Initialization:
- add_custom_server(server)[source]¶
Add a custom server configuration.
- Parameters:
server (ServerConfig) – ServerConfig to add
- Return type:
None
Example
Adding custom server:
- add_custom_template(template)[source]¶
Add a custom template.
- Parameters:
template (ServerTemplate) – ServerTemplate to add
- Return type:
None
Example
Adding custom template:
- async auto_discover_and_download(limit=None, auto_install=True)[source]¶
Auto-discover servers from registries and optionally download them.
This method discovers MCP servers from configured sources and can automatically install them.
- Parameters:
- Returns:
DownloadResult with discovery and installation details
- Return type:
Example
Auto-discover and install:
- async check_server_health(server_names=None)[source]¶
Check health status of installed servers.
- Parameters:
server_names (list[str] | None) – Specific servers to check. If None, checks all installed.
- Returns:
Dict with health check results
- Return type:
Example
Checking health:
- async download_servers(server_names=None, categories=None, tags=None, max_concurrent=None)[source]¶
Download and install MCP servers.
This is the main method for downloading servers. It supports filtering by name, category, or tags, and handles concurrent downloads with retry logic.
- Parameters:
server_names (list[str] | None) – Specific server names to download. If None, downloads all enabled servers.
categories (list[str] | None) – Filter servers by category (e.g., “official”, “community”)
tags (set[str] | None) – Filter servers by tags (e.g., {“database”, “file-operations”})
max_concurrent (int | None) – Maximum concurrent downloads. Uses config default if None.
- Returns:
DownloadResult with details of the operation
- Return type:
Example
Download specific servers:
- Raises:
ValueError – If no servers match the criteria
- Parameters:
- Return type:
- get_all_status()[source]¶
Get status for all servers.
- Returns:
Dict mapping server names to ServerStatus objects
- Return type:
- get_server_status(server_name)[source]¶
Get status for a specific server.
- Parameters:
server_name (str) – Name of the server
- Returns:
ServerStatus if found, None otherwise
- Return type:
ServerStatus | None
Example
Checking status:
- save_configuration(config_file)[source]¶
Save current configuration to file.
- Parameters:
config_file (Path) – Path to save configuration
- Return type:
None
Example
Saving config:
- property servers: list[ServerConfig]¶
Get list of server configurations.
- Returns:
List of ServerConfig objects
- Return type:
Example
Listing servers:
- property templates: dict[str, ServerTemplate]¶
Get templates as a dictionary.
- Returns:
Dict mapping template names to ServerTemplate objects
- Return type:
Example
Accessing templates:
- class haive.mcp.downloader.GitHubMCPDownloader(resources_dir='agent_resources/mcp_servers')[source]¶
Download all MCP servers from GitHub resources.
- Parameters:
resources_dir (str)
- class haive.mcp.downloader.GitInstaller[source]¶
Installer for Git repository-based MCP servers.
Handles cloning Git repositories and running post-install commands.
Examples
Git installation:
- async can_handle(server_config, template)[source]¶
Check if this is a Git installation.
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
- Return type:
- async install(server_config, template, install_dir)[source]¶
Clone Git repository and run post-install commands.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
install_dir (Path) – Installation directory
- Returns:
Installation result dictionary
- Return type:
- async verify(server_config, template, install_dir)[source]¶
Verify Git installation.
Checks if the repository was cloned successfully.
- Returns:
True if repository exists with .git directory
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
install_dir (Path)
- Return type:
- class haive.mcp.downloader.InstallationMethod(*values)[source]¶
Supported installation methods for MCP servers.
- NPM¶
Node Package Manager installation
- PIP¶
Python Package Index installation
- GIT¶
Git repository cloning
- DOCKER¶
Docker image pull
- BINARY¶
Binary executable download
- CURL¶
Direct HTTP download
- MANUAL¶
Manual installation process
- SCRIPT¶
Custom script execution
- BINARY = 'binary'¶
- CURL = 'curl'¶
- DOCKER = 'docker'¶
- GIT = 'git'¶
- MANUAL = 'manual'¶
- NPM = 'npm'¶
- PIP = 'pip'¶
- SCRIPT = 'script'¶
- class haive.mcp.downloader.MCPInstaller[source]¶
Abstract base class for MCP installers.
All installer implementations must inherit from this class and implement the required methods.
Examples
Creating a custom installer:
- abstractmethod async can_handle(server_config, template)[source]¶
Check if this installer can handle the given configuration.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
- Returns:
True if this installer can handle the installation
- Return type:
- abstractmethod async install(server_config, template, install_dir)[source]¶
Install the MCP server.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
install_dir (Path) – Installation directory
- Returns:
Dict with installation results including success status
- Return type:
- abstractmethod async verify(server_config, template, install_dir)[source]¶
Verify the installation was successful.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
install_dir (Path) – Installation directory
- Returns:
True if installation is verified
- Return type:
- class haive.mcp.downloader.NPMInstaller[source]¶
Installer for NPM-based MCP servers.
Handles installation of MCP servers distributed as NPM packages. Supports both global and local installations.
Examples
NPM installation:
- async can_handle(server_config, template)[source]¶
Check if this is an NPM installation.
- Returns:
True if template uses NPM installation method
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
- Return type:
- async install(server_config, template, install_dir)[source]¶
Install NPM package.
Attempts global installation first, falls back to local if that fails.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
install_dir (Path) – Installation directory
- Returns:
Installation result dictionary
- Return type:
- async verify(server_config, template, install_dir)[source]¶
Verify NPM installation.
Checks if the package is accessible via npx.
- Returns:
True if package is installed and accessible
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
install_dir (Path)
- Return type:
- class haive.mcp.downloader.PipInstaller[source]¶
Installer for Python pip-based MCP servers.
Handles installation of MCP servers distributed as Python packages.
Examples
Pip installation:
- async can_handle(server_config, template)[source]¶
Check if this is a pip installation.
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
- Return type:
- async install(server_config, template, install_dir)[source]¶
Install Python package via pip.
- Parameters:
server_config (ServerConfig) – Server configuration
template (ServerTemplate) – Server template
install_dir (Path) – Installation directory
- Returns:
Installation result dictionary
- Return type:
- async verify(server_config, template, install_dir)[source]¶
Verify pip installation.
Checks if the module can be imported.
- Returns:
True if module is installed and importable
- Parameters:
server_config (ServerConfig)
template (ServerTemplate)
install_dir (Path)
- Return type:
- class haive.mcp.downloader.ServerConfig(*, name, template, source, variables=<factory>, enabled=True, priority=0, tags=<factory>, env_vars=<factory>, version=None)[source]¶
Configuration for a specific MCP server.
Server configurations define individual servers to be installed, referencing a template and providing server-specific variables.
- Parameters:
Example
Filesystem server config:
- model_config: ClassVar[ConfigDict] = {'use_enum_values': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.mcp.downloader.ServerDiscovery(config)[source]¶
Discovers MCP servers from various sources.
This class provides methods to discover MCP servers from multiple registries and sources, with support for various search patterns and filtering options.
- Parameters:
config (DiscoveryConfig)
- config¶
Discovery configuration
- discovered_cache¶
Cache of discovered servers
- session¶
Aiohttp session for HTTP requests
Examples
Using discovery:
- __init__(config)[source]¶
Initialize server discovery.
- Parameters:
config (DiscoveryConfig) – Discovery configuration with sources and patterns
- determine_template(server_data)[source]¶
Determine the appropriate template for a discovered server.
- Parameters:
server_data (dict[str, Any]) – Discovered server information
- Returns:
Template name to use
- Return type:
Examples
Determining template:
- async discover_all(limit_per_source=None)[source]¶
Discover servers from all configured sources.
- Parameters:
limit_per_source (int | None) – Maximum servers to discover per source. Uses config default if not specified.
- Returns:
List of discovered server dictionaries
- Return type:
Examples
Discovering from all sources:
- async discover_from_github(api_url, limit=100)[source]¶
Discover servers from GitHub.
- Parameters:
- Returns:
List of discovered servers
- Return type:
Examples
GitHub discovery:
- async discover_from_npm_registry(registry_url, limit=100)[source]¶
Discover servers from npm registry.
- Parameters:
- Returns:
List of discovered servers
- Return type:
Examples
NPM discovery:
- async discover_from_url(url, limit=100)[source]¶
Discover servers from a generic URL (e.g., README).
- class haive.mcp.downloader.ServerStatus(*, name, status='pending', last_check=None, last_success=None, install_result=None, health_status=None, error=None)[source]¶
Status information for an MCP server.
- Parameters:
- last_check¶
Timestamp of last status check
- Type:
datetime.datetime | None
- last_success¶
Timestamp of last successful operation
- Type:
datetime.datetime | None
Example
Creating status:
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.mcp.downloader.ServerTemplate(*, name, installation_method, command_pattern, args_pattern=<factory>, env_vars=<factory>, capabilities=<factory>, category='general', health_check=None, prerequisites=<factory>, post_install=<factory>, timeout=300)[source]¶
Template for MCP server installation patterns.
Templates define reusable installation patterns that can be applied to multiple servers with similar installation requirements.
- Parameters:
- installation_method¶
Method to use for installation
Example
NPM template:
- installation_method: InstallationMethod¶
- model_config: ClassVar[ConfigDict] = {'use_enum_values': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- haive.mcp.downloader.load_config(config_file)[source]¶
Load configuration from YAML file.
- Parameters:
config_file (Path) – Path to YAML configuration file
- Returns:
Loaded configuration
- Return type:
- Raises:
FileNotFoundError – If config file doesn’t exist
ValueError – If config file is invalid
Example
Loading config:
- haive.mcp.downloader.save_config(config, config_file)[source]¶
Save configuration to YAML file.
- Parameters:
config (DownloaderConfig) – Configuration to save
config_file (Path) – Path to save file
- Return type:
None
Example
Saving config: