controlplane

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package controlplane lists, applies and reports on MCPServer resources and their Deployments.

Manager wraps k8sclient.Clients. ListServers combines each MCPServer with its rollout status into ServerInfo, and the apply, get and delete helpers give the CLI, operator and runtime API one consistent view of server state, including the public MCP endpoint of a server.

Index

Constants

This section is empty.

Variables

MCPServerGVR is the dynamic-client resource identity for MCPServer objects.

Functions

func DeploymentDesiredReplicas

func DeploymentDesiredReplicas(d appsv1.Deployment, defaultReplicas int32) int32

DeploymentDesiredReplicas returns the desired replica count, using defaultReplicas when the Deployment does not set spec.replicas.

func DeploymentReady

func DeploymentReady(d appsv1.Deployment, defaultReplicas int32) bool

DeploymentReady reports whether the Deployment has the desired number of ready replicas.

func PublicMCPEndpoint

func PublicMCPEndpoint(mcpServer mcpv1alpha1.MCPServer) string

PublicMCPEndpoint returns the public MCP endpoint path or URL for a server. The operator publishes the canonical URL in status.url, derived with the same scheme, host, and path rules the ingress and gateway use; that value wins. The fallback covers servers the operator has not reconciled yet.

Types

type ListServersOptions

type ListServersOptions struct {
	LabelSelector        string
	SkipDeploymentStatus bool
}

type ListServersResult

type ListServersResult struct {
	Servers                []ServerInfo
	CRDError               error
	UsedDeploymentFallback bool
}

ListServersResult contains MCPServer summaries and metadata about fallback behavior used while reading them.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager reads and mutates MCP Runtime control-plane resources in Kubernetes.

func New

func New(clients *k8sclient.Clients) *Manager

New creates a control-plane manager backed by Kubernetes clients.

func (*Manager) ApplyServer

func (m *Manager) ApplyServer(ctx context.Context, server *mcpv1alpha1.MCPServer) (*mcpv1alpha1.MCPServer, error)

ApplyServer creates or updates an MCPServer resource.

func (*Manager) DeleteServer

func (m *Manager) DeleteServer(ctx context.Context, namespace, name string) error

DeleteServer deletes one MCPServer resource.

func (*Manager) GetServer

func (m *Manager) GetServer(ctx context.Context, namespace, name string) (*mcpv1alpha1.MCPServer, error)

GetServer retrieves one MCPServer resource.

func (*Manager) GetServerInfo

func (m *Manager) GetServerInfo(ctx context.Context, namespace, name string) (ServerInfo, error)

GetServerInfo retrieves one MCPServer and joins it with its backing Deployment readiness when the Deployment is available.

func (*Manager) ListServers

func (m *Manager) ListServers(ctx context.Context, namespace string) (ListServersResult, error)

ListServers lists MCPServer resources in namespace and joins them with the readiness of their stable backing Deployments. If the MCPServer resource is unavailable, it falls back to legacy managed Deployments.

func (*Manager) ListServersWithOptions

func (m *Manager) ListServersWithOptions(ctx context.Context, namespace string, opts ListServersOptions) (ListServersResult, error)

ListServersWithOptions lists MCPServer resources in namespace using optional Kubernetes list filters.

type ServerDeploymentStatus

type ServerDeploymentStatus struct {
	Ready  string
	Status string
}

ServerDeploymentStatus summarizes readiness for the Deployment that backs an MCPServer.

func StatusForDeployment

func StatusForDeployment(d appsv1.Deployment) ServerDeploymentStatus

StatusForDeployment summarizes Deployment readiness in the format used by runtime server listings.

type ServerEgressInfo

type ServerEgressInfo struct {
	Hosts    []string `json:"hosts"`
	Ports    []int32  `json:"ports"`
	Approved bool     `json:"approved"`
}

ServerEgressInfo summarizes spec.egress and its admin approval.

type ServerInfo

type ServerInfo struct {
	Name        string             `json:"name"`
	Namespace   string             `json:"namespace"`
	UID         string             `json:"uid,omitempty"`
	TeamID      string             `json:"team_id,omitempty"`
	Image       string             `json:"image,omitempty"`
	ImageTag    string             `json:"imageTag,omitempty"`
	Description string             `json:"description,omitempty"`
	Ready       string             `json:"ready"`
	Status      string             `json:"status"`
	Message     string             `json:"message,omitempty"`
	Conditions  []metav1.Condition `json:"conditions,omitempty"`
	Labels      map[string]string  `json:"labels,omitempty"`
	Age         string             `json:"age"`
	Endpoint    string             `json:"endpoint,omitempty"`
	// AuthMode is "header" when the server delegates credential checks to
	// upstream headers, or "oauth" when OAuth support is configured.
	// Empty means authentication support is not reported.
	AuthMode string `json:"authMode,omitempty"`
	// AuthHeaders are credential header names for header auth. Values are
	// never copied onto this summary.
	AuthHeaders []string `json:"authHeaders,omitempty"`
	// CredentialPresence is "any" or "all" for header auth.
	CredentialPresence string                      `json:"credentialPresence,omitempty"`
	GatewayEnabled     bool                        `json:"gatewayEnabled"`
	ServicePort        int32                       `json:"servicePort,omitempty"`
	Generation         int64                       `json:"generation,omitempty"`
	Tools              []mcpv1alpha1.ToolConfig    `json:"tools,omitempty"`
	Prompts            []mcpv1alpha1.InventoryItem `json:"prompts"`
	Resources          []mcpv1alpha1.InventoryItem `json:"resources"`
	Tasks              []mcpv1alpha1.InventoryItem `json:"tasks"`
	RuntimeStatus      ServerRuntimeStatus         `json:"runtimeStatus"`
	// Egress reports the declared external egress and whether an administrator
	// approved it. Nil when the server declares none.
	Egress *ServerEgressInfo `json:"egress,omitempty"`
}

ServerInfo is the control-plane projection of an MCPServer and its backing workload status.

func ServerInfoFromMCPServer

func ServerInfoFromMCPServer(mcpServer mcpv1alpha1.MCPServer, deploymentStatus ServerDeploymentStatus) ServerInfo

ServerInfoFromMCPServer projects an MCPServer plus optional Deployment status into the control-plane server summary shape.

type ServerLastSession

type ServerLastSession struct {
	ID        string `json:"id"`
	Namespace string `json:"namespace,omitempty"`
	UsedAt    string `json:"usedAt"`
	ToolName  string `json:"toolName,omitempty"`
}

ServerLastSession identifies the latest observed gateway call using an MCP session. It deliberately omits caller identity and request payloads.

type ServerRuntimeStatus

type ServerRuntimeStatus struct {
	Transport        string                           `json:"transport,omitempty"`
	ConnectionState  string                           `json:"connectionState,omitempty"`
	AuthSource       string                           `json:"authSource,omitempty"`
	LastError        *mcpv1alpha1.MCPServerErrorEvent `json:"lastError,omitempty"`
	LastProbeTime    string                           `json:"lastProbeTime,omitempty"`
	LastSession      *ServerLastSession               `json:"lastSession,omitempty"`
	LastSessionState string                           `json:"lastSessionState,omitempty"`
}

ServerRuntimeStatus combines operator-owned rollout state with observations available from the runtime API. Session details are populated only for callers allowed to inspect server activity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL