haive.mcp.configΒΆ

Configuration models for MCP Downloader.

This module defines the configuration models used throughout the MCP downloader system, including templates, server configurations, and installation methods.

Example

Creating a server template:


template = ServerTemplate(

name=”npm_official”, installation_method=InstallationMethod.NPM, command_pattern=”@modelcontextprotocol/server-{service}”, capabilities=[β€œtools”], category=”official”

)

Creating a server configuration:

config = ServerConfig(
name="filesystem",
template="npm_official",
source="npm",
variables={"service": "filesystem"},
tags={"official", "file-operations"}

)

Classes:

InstallationMethod: Enum of supported installation methods ServerTemplate: Template for server installation patterns ServerConfig: Configuration for a specific server DownloaderConfig: Overall downloader configuration

class config.DiscoveryConfig(*, sources=<factory>, patterns=<factory>, auto_discover=False, discovery_interval=24, max_servers=100)[source]ΒΆ

Configuration for server discovery.

Parameters:
sourcesΒΆ

List of discovery source URLs

Type:

list[str]

patternsΒΆ

Package naming patterns by registry

Type:

dict[str, list[str]]

auto_discoverΒΆ

Enable automatic discovery

Type:

bool

discovery_intervalΒΆ

Hours between discovery runs

Type:

int

max_serversΒΆ

Maximum servers to discover per source

Type:

int

auto_discover: boolΒΆ
discovery_interval: intΒΆ
max_servers: intΒΆ
model_config: ClassVar[ConfigDict] = {}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

patterns: dict[str, list[str]]ΒΆ
sources: list[str]ΒΆ
class config.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:
install_dirΒΆ

Directory for server installations

Type:

pathlib.Path

config_dirΒΆ

Directory for configuration files

Type:

pathlib.Path

log_dirΒΆ

Directory for log files

Type:

pathlib.Path

max_concurrentΒΆ

Maximum concurrent downloads

Type:

int

retry_attemptsΒΆ

Number of retry attempts

Type:

int

retry_delayΒΆ

Delay between retries in seconds

Type:

int

health_check_enabledΒΆ

Enable health checks after install

Type:

bool

health_check_timeoutΒΆ

Health check timeout in seconds

Type:

int

backup_enabledΒΆ

Enable configuration backups

Type:

bool

backup_dirΒΆ

Directory for backups

Type:

pathlib.Path

templatesΒΆ

List of server templates

Type:

list[config.ServerTemplate]

serversΒΆ

List of server configurations

Type:

list[config.ServerConfig]

discoveryΒΆ

Discovery configuration

Type:

config.DiscoveryConfig

Example

Full configuration:

backup_dir: PathΒΆ
backup_enabled: boolΒΆ
config_dir: PathΒΆ
discovery: DiscoveryConfigΒΆ
health_check_enabled: boolΒΆ
health_check_timeout: intΒΆ
install_dir: PathΒΆ
log_dir: PathΒΆ
max_concurrent: intΒΆ
model_config: ClassVar[ConfigDict] = {}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

retry_attempts: intΒΆ
retry_delay: intΒΆ
servers: list[ServerConfig]ΒΆ
templates: list[ServerTemplate]ΒΆ
class config.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 config.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:
nameΒΆ

Server name identifier

Type:

str

templateΒΆ

Template name to use

Type:

str

sourceΒΆ

Source location (npm, git URL, etc.)

Type:

str

variablesΒΆ

Variables to substitute in template patterns

Type:

dict[str, Any]

enabledΒΆ

Whether the server is enabled for installation

Type:

bool

priorityΒΆ

Installation priority (lower = higher priority)

Type:

int

tagsΒΆ

Set of tags for categorization

Type:

set[str]

env_varsΒΆ

Additional environment variables

Type:

dict[str, str]

versionΒΆ

Specific version to install

Type:

str | None

Example

Filesystem server config:

enabled: boolΒΆ
env_vars: dict[str, str]ΒΆ
model_config: ClassVar[ConfigDict] = {'use_enum_values': True}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: strΒΆ
priority: intΒΆ
source: strΒΆ
tags: set[str]ΒΆ
template: strΒΆ
variables: dict[str, Any]ΒΆ
version: str | NoneΒΆ
class config.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:
nameΒΆ

Unique template identifier

Type:

str

installation_methodΒΆ

Method to use for installation

Type:

config.InstallationMethod

command_patternΒΆ

Pattern for the command to run the server

Type:

str

args_patternΒΆ

Default arguments for the command

Type:

list[str]

env_varsΒΆ

Environment variables to set

Type:

dict[str, str]

capabilitiesΒΆ

List of server capabilities

Type:

list[str]

categoryΒΆ

Server category for organization

Type:

str

health_checkΒΆ

Command to verify server health

Type:

str | None

prerequisitesΒΆ

Required system dependencies

Type:

list[str]

post_installΒΆ

Commands to run after installation

Type:

list[str]

timeoutΒΆ

Installation timeout in seconds

Type:

int

Example

NPM template:

args_pattern: list[str]ΒΆ
capabilities: list[str]ΒΆ
category: strΒΆ
command_pattern: strΒΆ
env_vars: dict[str, str]ΒΆ
health_check: str | NoneΒΆ
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].

name: strΒΆ
post_install: list[str]ΒΆ
prerequisites: list[str]ΒΆ
timeout: intΒΆ
config.load_config(config_file)[source]ΒΆ

Load configuration from YAML file.

Parameters:

config_file (Path) – Path to YAML configuration file

Returns:

Loaded configuration

Return type:

DownloaderConfig

Raises:

Example

Loading config:

config.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: