mcp-host-agent
The host-level deployment & supervision agent for the MCP Worker platform.
Install once per host, manage every local Worker service end to end — deployment, health polling, heartbeat aggregation, crash self-healing, and Git-service-driven continuous delivery.
Why
Deploying MCP Workers by hand means writing the same git clone + pip install + systemctl restart + heartbeat + self-healing glue every time — multiplied by the
number of Workers and hosts you manage. mcp-host-agent turns that glue into a
single, declarative, docker-style CLI.
- One agent per host manages N Worker services.
- Coolify-like Git UX — private/public Git repos plus push-to-deploy webhooks.
- Rich three-tier health — status, queue backpressure, and latency/reliability profile flow up to the Hub for smarter scheduling.
- Self-healing — process-level restart, rollback to the previous commit, and structured escalation.
Install
pip install mcp-host-agent
Requires Python 3.10+.
Quick start
# 1. Generate a standard agent.yaml.
mcp-host-agent config init \
--hub-url https://hub.example.com \
--agent-id agent-sandbox
# 2. Add a worker (writes back to agent.yaml atomically).
mcp-host-agent worker add \
--name demo-worker \
--repo https://git.example.com/owner/demo-worker.git \
--port 9101
# 3. Validate, then run (bootstrap first → supervision loop → control API).
mcp-host-agent config validate --config /etc/mavis/agent.yaml
mcp-host-agent deploy run --config /etc/mavis/agent.yaml
Verify:
curl http://127.0.0.1:9200/health
curl http://127.0.0.1:9200/meta
curl http://127.0.0.1:9200/api/v1/agent/status -H "X-Agent-Token: <agent-token>"
Features
| Capability | Description |
|---|---|
| Deployment | git clone/pull, pip install, and systemd/launchd service management |
| Supervision | Polls each Worker's /health + /meta, derives status, aggregates heartbeat |
| Self-healing | Decision tree: restart → rollback (git checkout HEAD~1) → give up + escalate |
| Rich telemetry | Forwards degraded_reason, avg/p95 latency, estimated_wait_ms, success_rate through Heartbeat.health |
| Git CD | Gitea and GitHub webhook push-to-deploy with HMAC signature verification |
| Private repos | Credentials via git_username + git_token_env (token stays out of YAML) or the host credential helper |
| Docker-style CLI | config / worker / deploy grouped subcommands |
| Hot reload | deploy reload sends SIGHUP; newly added Workers bootstrap without a restart |
Configuration
The agent is driven by a single agent.yaml:
hub_url: "https://hub.example.com"
agent_id: "agent-sandbox"
jwt_token: "<jwt>" # register with the Hub
agent_token: "<agent-token>" # protect control endpoints
webhook_secret: "<webhook-secret>" # Gitea/GitHub webhook signature
platform: linux # linux | macos
agent_port: 9200 # control API port
workers:
- name: sandbox-worker
repo: "https://git.example.com/owner/worker-sandbox.git"
branch: main
port: 9101
git_username: "will" # private repo username
git_token_env: "GITEA_TOKEN" # token read from env, never written to YAML
# self-healing defaults (overridable by Worker /meta.recovery)
auto_restart: true
max_restart: 3
restart_interval: 5
fail_threshold: 3
graceful_timeout: 10
The token referenced by
git_token_envis read from the environment at clone time and is not persisted to disk. If bothgit_usernameandgit_token_envare omitted, the host's own Git credential helper (or SSH config) is used.
Set up push-to-deploy (Gitea / GitHub)
-
Point your webhook at the agent:
- Payload URL:
http://<host-agent-ip>:9200/webhook - Content type:
application/json - Secret: the same value as
webhook_secretinagent.yaml
- Payload URL:
-
Gitea — enable “Push” events.
-
GitHub — enable “Just the push event”.
Every push with a valid signature triggers git pull → pip install → service restart and reports commit status back.
Supported platforms
| Platform | Runner |
|---|---|
| Linux | systemd |
| macOS | launchd |
Windows is not supported in v1. The agent manages native host processes (systemd/launchd). Containers such as Docker/K3s pods are self-healed by their own orchestrators, not by the agent.
Programmatic API
from mcp_host_agent import (
AgentConfig,
WorkerConfig,
WorkerManager,
Supervisor,
create_app,
SystemdRunner,
)
config = AgentConfig(
hub_url="https://hub.example.com",
agent_id="agent-sandbox",
jwt_token="<jwt>",
workers=[WorkerConfig(name="demo", repo="https://git.example.com/o/demo.git", port=9101)],
)
manager = WorkerManager(config)
manager.ensure_cloned(config.workers[0])
manager.install_deps(config.workers[0])
manager.start(config.workers[0])
supervisor = Supervisor(config, manager)
supervisor.poll_all()
heartbeats = supervisor.build_heartbeats("2026-08-16T00:00:00+00:00")
app = create_app(config, supervisor, manager) # FastAPI control plane
See docs/mcp-host-agent/DELIVERY_INTEGRATION.md for the full integration guide.
Development
pip install -e ".[dev]"
pytest # unit + integration + contract + compatibility
ruff check .
License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_host_agent-1.1.0.tar.gz.
File metadata
- Download URL: mcp_host_agent-1.1.0.tar.gz
- Upload date:
- Size: 27.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70c008aabb1555203c55ddfa79ff0022ebd1726331c64cc3b19428f64d40d871
|
|
| MD5 |
8840f97d7a883fdc0e9c3154a1a7d741
|
|
| BLAKE2b-256 |
3cd0d4d7e522aae600431d13bb50e8cfd1449a6dc94dd6d9101e9d6f3d485b78
|
File details
Details for the file mcp_host_agent-1.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_host_agent-1.1.0-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4095246ec98971fc317e445029b8623133f0eddb18e09efc291907408054c9d7
|
|
| MD5 |
31537539e0a8da1f4d33c184e9a346dc
|
|
| BLAKE2b-256 |
da6ba772ce439b9a10ce8a5f3e05148cc556a1c490f83a30cd9d27cc101a605d
|