Production-grade hot-load registry for MCP providers
Project description
MCP Hangar
Production-grade MCP infrastructure with auto-discovery, observability, and resilience patterns.
Overview
MCP Hangar is a lifecycle management platform for Model Context Protocol providers, built for platform teams running MCP at scale. It replaces ad-hoc provider management with a unified control plane featuring auto-discovery from Kubernetes, Docker, and filesystem sources; circuit breakers and saga-based recovery for resilience; and first-class observability through Langfuse, OpenTelemetry, and Prometheus. The architecture follows Domain-Driven Design with CQRS and Event Sourcing, providing full audit trails for compliance-heavy environments.
Why MCP Hangar?
| Challenge | Without MCP Hangar | With MCP Hangar |
|---|---|---|
| Provider lifecycle | Manual start/stop, no health monitoring | State machine with circuit breaker, health checks, automatic GC |
| Observability | None or DIY | Built-in Langfuse, OpenTelemetry, Prometheus metrics |
| Dynamic environments | Restart required for new providers | Auto-discovery from K8s, Docker, filesystem, entrypoints |
| Failure handling | Cascading failures | Circuit breaker, saga-based recovery and failover |
| Audit & compliance | None | Event sourcing with full audit trail |
| Cold start latency | Wait for provider startup | Predefined tools visible immediately, lazy loading |
| Multi-provider routing | Manual coordination | Load balancing with weighted round-robin, priority, least connections |
Key Features
๐ Lifecycle Management
Provider lifecycle follows a strict state machine:
COLD โ INITIALIZING โ READY โ DEGRADED โ DEAD
- Lazy loading โ Providers start on first invocation, not at boot
- Predefined tools โ Tool schemas visible before provider starts (no cold start for discovery)
- Automatic GC โ Idle providers shutdown after configurable TTL
- Graceful shutdown โ Clean termination with timeout enforcement
๐ Auto-Discovery
Automatically detect and register providers from multiple sources:
| Source | Configuration |
|---|---|
| Kubernetes | Pod annotations (mcp.hangar.io/*) with namespace filtering |
| Docker/Podman | Container labels (mcp.hangar.*) |
| Filesystem | YAML configs with file watching |
| Python entrypoints | mcp.providers entry point group |
Discovery modes:
additiveโ Only adds providers, never removes (safe for static environments)authoritativeโ Adds and removes (for dynamic environments like K8s)
Conflict resolution: Static config > Kubernetes > Docker > Filesystem > Entrypoints
๐ Observability
Full observability stack for production operations:
Langfuse Integration
- End-to-end LLM tracing from prompt to provider response
- Cost attribution per provider, tool, user, or session
- Quality scoring and automated evals
OpenTelemetry
- Distributed tracing with context propagation
- OTLP export to Jaeger, Zipkin, or any collector
Prometheus Metrics
- Tool invocation latency and error rates
- Provider state transitions and cold starts
- Circuit breaker state and trip counts
- Health check results
Health Endpoints
/healthโ Liveness check/readyโ Readiness check (K8s compatible)/metricsโ Prometheus scrape endpoint
๐ก๏ธ Resilience
Production-grade failure handling:
Circuit Breaker
- Opens after configurable failure threshold
- Auto-reset after timeout period
- Prevents cascading failures to healthy providers
Saga-Based Recovery
ProviderRecoverySagaโ Automatic restart with exponential backoffProviderFailoverSagaโ Failover to backup providers with auto-failbackGroupRebalanceSagaโ Rebalance traffic when members change
Health Monitoring
- Configurable check intervals
- Consecutive failure thresholds
- Automatic state transitions (READY โ DEGRADED)
๐ Security
Enterprise security controls:
- Rate limiting โ Per-provider request limits
- Input validation โ Schema validation before provider invocation
- Secrets management โ Environment variable injection, never in config files
- Container isolation โ Read-only filesystems, resource limits, network policies
- Discovery security โ Namespace filtering, max providers per source, quarantine on failure
๐๏ธ Architecture
Domain-Driven Design with clean layer separation:
domain/ Core business logic, state machines, events, value objects
application/ Use cases, commands, queries, sagas
infrastructure/ Adapters for containers, subprocess, persistence, event bus
server/ MCP protocol handlers and validation
bootstrap/ Runtime initialization and dependency injection
- CQRS โ Separate command and query paths
- Event Sourcing โ All state changes emit domain events
- Port/Adapter โ Extensible infrastructure layer
- Thread-safe โ Lock hierarchy for concurrent access
Quick Start
Install:
pip install mcp-hangar
Configure (config.yaml):
providers:
math:
mode: subprocess
command: [python, -m, my_math_server]
idle_ttl_s: 300
sqlite:
mode: container
image: ghcr.io/modelcontextprotocol/server-sqlite:latest
volumes:
- "/data/sqlite:/data:rw"
Run:
# Stdio mode (Claude Desktop, Cursor, etc.)
mcp-hangar --config config.yaml
# HTTP mode (LM Studio, web clients)
mcp-hangar --config config.yaml --http
Architecture Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Hangar โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ FastMCP Server โ โ
โ โ (Stdio or HTTP transport) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Provider Manager โ โ
โ โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ โ
โ โ โ State โ โ Health โ โ Circuit โ โ โ
โ โ โ Machine โ โ Tracker โ โ Breaker โ โ โ
โ โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Providers โ โ
โ โ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โ โ
โ โ โ Subprocessโ โ Docker โ โ Remote โ โ โ
โ โ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Background: [GC Worker] [Health Worker] [Discovery Worker] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Registry Tools
| Tool | Description |
|---|---|
registry_list |
List all providers with state, health status, and available tools |
registry_start |
Explicitly start a provider |
registry_stop |
Stop a running provider |
registry_invoke |
Invoke a tool on a provider (auto-starts if needed) |
registry_invoke_ex |
Invoke with retry, correlation ID, and metadata |
registry_invoke_stream |
Invoke with real-time progress notifications |
registry_tools |
Get tool schemas for a provider |
registry_health |
Get health status and metrics |
registry_status |
Dashboard view of all providers |
registry_discover |
Trigger discovery cycle |
registry_sources |
List discovery sources with status |
registry_warm |
Pre-start providers to avoid cold start latency |
Configuration Reference
| Option | Description | Default |
|---|---|---|
mode |
Provider mode: subprocess, container, docker, remote, group |
required |
command |
Command for subprocess providers | โ |
image |
Container image for container providers | โ |
idle_ttl_s |
Seconds before idle provider shutdown | 300 |
health_check_interval_s |
Health check frequency in seconds | 60 |
max_consecutive_failures |
Failures before transition to DEGRADED | 3 |
tools |
Predefined tool schemas (visible before start) | โ |
volumes |
Container volume mounts | โ |
network |
Container network mode | none |
read_only |
Container read-only filesystem | true |
Observability Setup
observability:
langfuse:
enabled: true
public_key: ${LANGFUSE_PUBLIC_KEY}
secret_key: ${LANGFUSE_SECRET_KEY}
host: https://cloud.langfuse.com
tracing:
enabled: true
otlp_endpoint: http://localhost:4317
metrics:
enabled: true
endpoint: /metrics
Environment Variables:
| Variable | Description |
|---|---|
LANGFUSE_PUBLIC_KEY |
Langfuse public key |
LANGFUSE_SECRET_KEY |
Langfuse secret key |
OTEL_EXPORTER_OTLP_ENDPOINT |
OpenTelemetry collector endpoint |
MCP_TRACING_ENABLED |
Enable/disable tracing (true/false) |
Endpoints:
/metricsโ Prometheus metrics/healthโ Liveness probe/readyโ Readiness probe
Documentation
๐ Full Documentation
Contributing
See Contributing Guide for development setup, testing requirements, and code style.
git clone https://github.com/mapyr/mcp-hangar.git
cd mcp-hangar
uv sync --extra dev
uv run pytest tests/ -v
License
MIT License โ see LICENSE for details.
Project details
Release history Release notifications | RSS feed
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_hangar-0.1.4.tar.gz.
File metadata
- Download URL: mcp_hangar-0.1.4.tar.gz
- Upload date:
- Size: 541.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b393f62e31783fcfdd116a84ce835bc4acfcd62a71e129438f483b7ff8fd438
|
|
| MD5 |
cff33c9195df14a6adcd142507e0b8ac
|
|
| BLAKE2b-256 |
fbe9057b1dd0a08bcc23ff07f25e9629c981ce2716f8ff2006b701da651e7200
|
Provenance
The following attestation bundles were made for mcp_hangar-0.1.4.tar.gz:
Publisher:
release.yml on mapyr/mcp-hangar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_hangar-0.1.4.tar.gz -
Subject digest:
6b393f62e31783fcfdd116a84ce835bc4acfcd62a71e129438f483b7ff8fd438 - Sigstore transparency entry: 831314263
- Sigstore integration time:
-
Permalink:
mapyr/mcp-hangar@0be04ac05c698af7209493845cbddb5666a9785e -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/mapyr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0be04ac05c698af7209493845cbddb5666a9785e -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcp_hangar-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mcp_hangar-0.1.4-py3-none-any.whl
- Upload date:
- Size: 299.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4da95534172f43674d13791c1f3a348f280e6c07c6b8fe78978c89a0eec4e59e
|
|
| MD5 |
fda5ee6a1979440687189636eb8fd940
|
|
| BLAKE2b-256 |
37cfcecc24b3cbf33bb5228adb3f7fba95e0c612206f64871e810b4664033d4d
|
Provenance
The following attestation bundles were made for mcp_hangar-0.1.4-py3-none-any.whl:
Publisher:
release.yml on mapyr/mcp-hangar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_hangar-0.1.4-py3-none-any.whl -
Subject digest:
4da95534172f43674d13791c1f3a348f280e6c07c6b8fe78978c89a0eec4e59e - Sigstore transparency entry: 831314277
- Sigstore integration time:
-
Permalink:
mapyr/mcp-hangar@0be04ac05c698af7209493845cbddb5666a9785e -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/mapyr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0be04ac05c698af7209493845cbddb5666a9785e -
Trigger Event:
push
-
Statement type: