Repository navigation
Closed
Labels
apiItems related to the APIenhancementNew feature or requestgoPull requests that update go codetelemetryvmcpVirtual MCP Server related issues
Description
Description
Implement health monitoring and circuit breaker patterns to detect and handle backend failures gracefully.
Scope:
- Periodic health checks for backend MCP servers
- Backend health status tracking and reporting
- Circuit breaker implementation for failing backends
- Automatic backend removal/restoration based on health
- Health status reflected in vMCP status and capabilities
Key Components
1. Backend Health Checks
- Periodic health check requests to each backend
- Configurable check interval (default: 30s)
- Track consecutive failures
- Mark backend unhealthy after threshold (default: 3 failures)
- Health check endpoint: MCP
pingortools/list
2. Health Status Tracking
- Per-backend health state:
healthy,unhealthy,unknown - Last successful health check timestamp
- Failure count and error messages
- Health status exposed in vMCP status/metrics
3. Circuit Breaker
- Three states:
closed(normal),open(failing),half-open(testing recovery) - Configurable failure threshold (default: 5 failures)
- Configurable timeout for open state (default: 60s)
- Automatic transition to half-open for recovery testing
- Track circuit breaker state per backend
4. Backend Availability Management
- Remove unhealthy backend tools from aggregated capabilities
- Return error when routing to unavailable backend
- Automatically restore backend when health recovers
- Log backend state transitions (healthy ↔ unhealthy)
- Emit metrics for monitoring systems
5. Failure Modes
- fail mode (default): Fail entire request if backend unavailable
- best_effort mode: Return partial results, include errors for failed backends
- Configurable per vMCP instance
6. Integration Points
- Update aggregated capabilities when backend health changes
- Routing layer checks health before forwarding
- Status reporting includes backend health summary
- Metrics exported for Prometheus/observability
Implementation Notes
- Health checks run in background goroutines
- Use context for cancellation on shutdown
- Circuit breaker prevents cascading failures
- Health status should be cached to avoid repeated checks
- Transition events should be logged and emitted as metrics
- Follow existing ToolHive observability patterns in
pkg/telemetry/ - Consider using
sony/gobreakeror similar library
Reference
- vMCP Design Proposal - Backend Unavailability, Partial Failures, Circuit Breaker sections
Acceptance Criteria
- Periodic health check implementation
- Configurable health check interval
- Backend health state tracking (healthy/unhealthy/unknown)
- Consecutive failure counting
- Unhealthy threshold configuration
- Circuit breaker implementation (closed/open/half-open states)
- Configurable failure threshold for circuit breaker
- Configurable timeout for open state
- Automatic transition to half-open for recovery testing
- Remove unhealthy backend tools from capabilities
- Error response when routing to unavailable backend
- Automatic restoration when backend recovers
- Health state transition logging
- Partial failure mode support (fail vs best_effort)
- Metrics emission for observability
- Unit tests for health check logic
- Unit tests for circuit breaker state machine
- Integration tests with flaky mock backends
- E2E tests with backend failure and recovery scenarios
Activity
slyt3 commentedon Dec 8, 2025
Hello, Can you assign me to this? I was working this whole night and i need another 1-2 days to fix some issues for it.
Still have some bugs and issues but i am working on it
jhrozek commentedon Dec 8, 2025
Thank you for the continued interest in contributing to toolhive! This is an issue that requires an insight into how vMCP will be operationalized as well as it's a big issue that will most likely be split down into a bunch of smaller ones.
If you filter toolhive issues by "good first issue" there usually are a bunch that are a better fit to learn more about toolhive and can be completed in less amount of time. If there are none, I'm sure we can add more
slyt3 commentedon Dec 8, 2025
@jhrozek I understand this is a large issue that will be split into smaller pieces. I've implemented the status reporting foundation that this issue requires.
What I Built
I've created a separate PR (#2949) that implements the status reporting mechanism mentioned in this issue's Integration Points:
PR scope:
-StatusReporter interface (platform-agnostic)
-K8sReporter (updates VirtualMCPServer.status)
-LogReporter (CLI environments)
-Data structures for health data (
RuntimeStatus,BackendHealthReport)-15 unit tests, lint clean, tested in kind
What it does NOT include:
It doesnt include health checking logic, circuit breakers and backend monitoring
this just provides the reporting infrastructure this issue needs. The actual health monitoring implementation can build on top of this foundation.
How They Connect
Next Steps
If this approach makes sense, I'm happy to try to implement
Let me know if you'd like me to continue contributing to this issue's implementation! I spent a lot of time on it.
PR: #2949
jhrozek commentedon Dec 11, 2025
Related Issues
This issue can integrate with the vMCP K8s-aware refactor work:
Upsert/Removeoperations for automatic backend removal/restoration based on health statusBackendStatus; health monitoring would enhance thisThese are not hard dependencies - health monitoring can be implemented independently. But the integration is cleaner if these exist first.
slyt3 commentedon Dec 11, 2025
@jhrozek should i still look on that pr and fix everything and would love to spent time on it.
jhrozek commentedon Dec 11, 2025
I honestly think that this is pretty involved work that would better be done by someone from the core team. Your contributions are appreciated, but I think it's better to start small and gradually ramp up.
slyt3 commentedon Dec 12, 2025
Okey I understand it, thankyou for replay and honest answer. If someone from the core team will take this issue. I would love to help with some tasks.