Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements platform-agnostic status reporting infrastructure for Virtual MCP Servers, enabling runtime operational visibility in both Kubernetes and CLI environments.
Motivation
While exploring Issue #2853 (Health Monitoring), I identified that vMCP lacks a mechanism to report operational status. The Virtual MCP Server proposal explicitly requires "status reporting includes backend health summary" in its Integration Points section (line 6).
This PR provides the reporting foundation that Issue #2853's health monitoring will use, without implementing the health checking logic itself.
What This PR Implements
Core Components
Reporter interface: Platform-agnostic contract (
Report/Start/Stop/SetStatusCallback)K8sReporter: Updates
VirtualMCPServer.statusCRD in KubernetesLogReporter: Logs status to stdout for CLI environments
Factory pattern: Automatic environment detection via
KUBERNETES_SERVICE_HOSTRuntimeStatus: Data structure for operational state (phase, backends, tool counts)
Integration
VMCP_NAMEandVMCP_NAMESPACE(set by operator)virtualmcpservers/statusread/write accessStatus Data Model
What This PR Does NOT Implement
Health checking logic (that's Issue #2853)
Circuit breaker patterns
Backend health monitoring
Metrics emission (future work)
Why Merge This Separately From #2853
Standalone Value
Foundation for #2853
RuntimeStatus.Backendsholds health dataTesting
Unit Tests
added 15 Unit Test they all pass
Test coverage:
Integration Testing
Deployed to kind cluster and verified:
Factory detects Kubernetes environment correctly
K8sReporter creates with correct name/namespace from env vars
Reporter starts successfully and reports every 30s
Status updates call
client.Status().Update()successfullyRBAC permissions allow status updates
No goroutine leaks on shutdown
Evidence:
{"msg":"Detected Kubernetes environment, using K8sReporter"} {"msg":"Starting status reporter (interval: 30s)"} {"msg":"[toolhive-system/test-vmcp] Updated K8s status: phase=Ready, backends=0/0"}Relationship to Virtual MCP Proposal
From the Virtual MCP Server Proposal:
This PR implements the reporting mechanism. Issue #2853 will populate it with health data.
Current Behavior
CLI Environment
Kubernetes Environment
Known Limitations & Future Work
StatusReporter is Foundation, Not Complete Feature
Currently reports dummy status because:
GetStatus()method to collect real-time dataThis is intentional - provides infrastructure for future work:
Server.GetStatus()methodOperator Status Ownership
The operator controller also updates
VirtualMCPServer.statusfields. Status ownership between operator and StatusReporter should be clarified:phase,message,backendCount)This design question is deferred to follow-up discussion.
Follow-up Work (Separate PRs)
Server.GetStatus()to collect real backend dataFiles Changed
New Package: pkg/vmcp/status/ (8 files)
factory.go(31 lines): Environment detection and reporter creationfactory_test.go(180 lines): Factory pattern testsk8s_reporter.go(146 lines): Kubernetes implementationlog_reporter.go(94 lines): CLI implementationlog_reporter_test.go(196 lines): LogReporter testsreporter.go(15 lines): Interface definitiontypes.go(45 lines): Data structurestypes_test.go(102 lines): Type validation testsModified Files
pkg/vmcp/server/server.go: Added reporter field, start/stop integrationcmd/vmcp/app/commands.go: Reporter creation from environment variablescmd/thv-operator/controllers/virtualmcpserver_deployment.go: RBAC permissionsBreaking Changes
None. This is purely additive functionality.
Migration Guide
No migration needed. Reporter is optional and automatically enabled.
Questions for Reviewers
Related Issues
I'm happy to adjust scope, address design questions, or split this further based on feedback. Thanks for reviewing! I really liked to work that i didnt noticed from sunday morning as i started that its already monday