Documentation
¶
Overview ¶
Package status provides the StatusReporter interface for vMCP.
The reporter allows vMCP runtime to publish its operational status using shared vmcp status types (pkg/vmcp/types.go). Implementations are pluggable:
- LoggingReporter (CLI): logs updates at Debug level, no persistence. Debug logging is controlled by the --debug flag; logs may not be visible in production configurations where log level is set to Info.
- Future reporters: Kubernetes status writer, file/metrics sinks.
Reporter lifecycle: Start(ctx) returns a shutdown func; server collects and calls shutdown funcs during Stop(). ReportStatus(ctx, *vmcp.Status) is thread-safe and expected to be idempotent for repeated updates.
Package status provides abstractions for vMCP runtime status reporting.
Package status provides platform-agnostic status reporting for vMCP servers.
The StatusReporter abstraction enables vMCP runtime to report operational status back to the control plane (Kubernetes operator or CLI state manager). This allows the runtime to autonomously update backend discovery results, health status, and operational state without relying on the controller to infer it through polling.
This abstraction supports removing operator discovery in dynamic mode by allowing vMCP runtime to discover backends and report the results back.
Index ¶
Constants ¶
const ( // EnvVMCPName is the environment variable for the VirtualMCPServer name EnvVMCPName = "VMCP_NAME" // EnvVMCPNamespace is the environment variable for the VirtualMCPServer namespace EnvVMCPNamespace = "VMCP_NAMESPACE" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type K8sReporter ¶
type K8sReporter struct {
// contains filtered or unexported fields
}
K8sReporter implements Reporter for Kubernetes environments. It updates the VirtualMCPServer/status subresource with runtime status information.
func NewK8sReporter ¶
func NewK8sReporter(restConfig *rest.Config, name, namespace string) (*K8sReporter, error)
NewK8sReporter creates a new K8sReporter instance.
Parameters:
- restConfig: Kubernetes REST config for creating the client
- name: Name of the VirtualMCPServer resource
- namespace: Namespace of the VirtualMCPServer resource
Returns a K8sReporter and any error encountered during client creation.
func (*K8sReporter) ReportStatus ¶
ReportStatus sends a status update to the VirtualMCPServer/status subresource. This method uses optimistic concurrency control with automatic retries on conflicts.
type LoggingReporter ¶
type LoggingReporter struct{}
LoggingReporter is a CLI-mode implementation of Reporter that logs status updates. In CLI mode there is no persistence; status updates are logged at Debug level. Debug logging is controlled by the --debug flag; logs may not be visible in production configurations where log level is set to Info.
func NewLoggingReporter ¶
func NewLoggingReporter() *LoggingReporter
NewLoggingReporter creates a logging status reporter for CLI mode.
func (*LoggingReporter) ReportStatus ¶
ReportStatus logs the status update (non-persistent).
type Reporter ¶
type Reporter interface {
// ReportStatus updates the complete status atomically.
// This is the primary method for status reporting.
ReportStatus(ctx context.Context, status *vmcptypes.Status) error
// Start initializes the reporter.
//
// Returns:
// - shutdown: Function to stop the reporter and cleanup resources.
// Call this when shutting down (e.g., in server.Stop()).
// Blocks until all pending status updates are flushed.
// Safe to call multiple times (idempotent).
// - err: Non-nil if initialization fails.
// When err != nil, shutdown will be nil.
Start(ctx context.Context) (shutdown func(context.Context) error, err error)
}
Reporter provides a platform-agnostic interface for vMCP runtime to report status.
Implementations:
- K8sReporter: Updates VirtualMCPServer.Status in Kubernetes cluster (requires RBAC)
- LoggingReporter: Logs status at debug level for CLI mode (no persistent status)
The reporter is designed to be called by vMCP runtime during:
- Backend discovery (report discovered backends)
- Health checks (update backend health status)
- Lifecycle events (server starting, ready, degraded, failed)
func NewReporter ¶
NewReporter creates an appropriate Reporter based on the runtime environment.
Detection logic:
- If VMCP_NAME and VMCP_NAMESPACE env vars are set → Kubernetes mode → K8sReporter
- Otherwise → CLI mode → LoggingReporter
In Kubernetes mode, the function uses in-cluster configuration to create a Kubernetes client for updating VirtualMCPServer status.
Returns:
- Reporter instance (K8sReporter or LoggingReporter)
- Error if Kubernetes mode is detected but client creation fails