admin

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package admin provides the Admin MCP server for Vision management. It exposes MCP tools for server lifecycle management on port 6275.

Index

Constants

View Source
const DefaultPort = 6275

DefaultPort is the default port for the Admin MCP server.

View Source
const DefaultReachabilityGrace = 30 * time.Second

Variables

View Source
var (
	Version   = "dev"
	BuildInfo = ""
)

Version and BuildInfo are populated by the cmd/vision entry point at process startup (usually via ldflags). Empty string is acceptable and will surface as "dev" in the /version response for local builds.

Functions

func NewValidationError

func NewValidationError(msg string) error

NewValidationError creates a new validation error.

Types

type Config

type Config struct {
	Registry *server.Registry
	// RestartServer performs the restart and returns a receipt only for a shared
	// target whose drain completed or timed out. It may return a receipt with an
	// error. When nil, vision_restart uses Registry.Restart.
	RestartServer            func(context.Context, string) (*RestartDrain, error)
	Instructions             *config.Instructions
	DaemonConfig             *config.Config // Mutable reference for persisting changes
	ConfigPath               string         // Path to servers.yaml for config persistence
	Port                     int
	Logger                   *slog.Logger
	SlotSessionAccessor      SlotSessionAccessor      // Optional: provides live session counts
	ServerMetricsAccessor    ServerMetricsAccessor    // Optional: provides per-server session metrics
	SessionLifecycleAccessor SessionLifecycleAccessor // Optional managed-HTTP lifecycle projection
	ReachabilityStore        *reachability.Store
	ReachabilityGrace        time.Duration
	Metrics                  *metrics.DaemonMetrics
}

Config configures the Admin MCP server.

type EffectiveStatus added in v1.4.5

type EffectiveStatus struct {
	Status       string
	Reason       string
	Reachability ReachabilityDetails
}

type GuidanceEntry

type GuidanceEntry struct {
	Name           string   `json:"name"`
	NamespacedName string   `json:"namespaced_name,omitempty"`
	Priority       string   `json:"priority,omitempty"`
	Guidance       string   `json:"guidance,omitempty"`
	PreferFor      []string `json:"prefer_for,omitempty"`
	AvoidFor       []string `json:"avoid_for,omitempty"`
	Examples       []string `json:"examples,omitempty"`
}

GuidanceEntry represents guidance for a single server or tool.

type GuidanceResponse

type GuidanceResponse struct {
	Success        bool            `json:"success"`
	GlobalGuidance string          `json:"global_guidance,omitempty"`
	Servers        []GuidanceEntry `json:"servers,omitempty"`
	Tools          []GuidanceEntry `json:"tools,omitempty"`
	Context        string          `json:"context,omitempty"`
	Error          *string         `json:"error,omitempty"`
}

GuidanceResponse is the response for vision_guidance.

type InitResponse

type InitResponse struct {
	Success           bool     `json:"success"`
	Path              string   `json:"path"`
	Servers           []string `json:"servers"`
	ReconciledServers []string `json:"reconciled_servers,omitempty"`
	BackedUp          bool     `json:"backed_up,omitempty"`
	BackupPath        string   `json:"backup_path,omitempty"`
	Error             *string  `json:"error,omitempty"`
}

InitResponse is the response for vision_init.

type InputSchema

type InputSchema struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties,omitempty"`
	Required   []string            `json:"required,omitempty"`
}

InputSchema defines the JSON schema for tool inputs.

type ListResponse

type ListResponse struct {
	Servers    []ListServerEntry `json:"servers"`
	SlotGroups []SlotGroupEntry  `json:"slot_groups"`
}

ListResponse is the response for vision_list.

type ListServerEntry

type ListServerEntry struct {
	Name            string  `json:"name"`
	Status          string  `json:"status"`
	EffectiveReason *string `json:"effective_reason,omitempty"`
	ProcessState    string  `json:"process_state"`
	ReachabilityDetails
	Port             *int                           `json:"port"`
	PID              *int                           `json:"pid"`
	Uptime           *string                        `json:"uptime"`
	Error            *string                        `json:"error"`
	SessionMetrics   *metrics.ServerMetricsSnapshot `json:"session_metrics,omitempty"`
	SessionLifecycle *SessionLifecycleSnapshot      `json:"session_lifecycle,omitempty"`
}

ListServerEntry represents a server in the vision_list response.

type MetricsResponse

type MetricsResponse struct {
	SessionsActive     int64                                     `json:"sessions_active"`
	ToolCallsTotal     int64                                     `json:"tool_calls_total"`
	ErrorsTotal        int64                                     `json:"errors_total"`
	SubprocessesActive int64                                     `json:"subprocesses_active"`
	Servers            map[string]*metrics.ServerMetricsSnapshot `json:"servers"`
}

MetricsResponse is the response for vision_metrics.

type Property

type Property struct {
	Type        string `json:"type"`
	Description string `json:"description"`
	Default     any    `json:"default,omitempty"`
}

Property defines a single property in the input schema.

type ReachabilityDetails added in v1.5.0

type ReachabilityDetails struct {
	Reachability             string     `json:"reachability"`
	ProbeDepth               string     `json:"probe_depth"`
	LastProbeAt              *time.Time `json:"last_probe_at"`
	LastProbeOutcome         string     `json:"last_probe_outcome"`
	LastProbeError           string     `json:"last_probe_error"`
	ConsecutiveProbeFailures int        `json:"consecutive_probe_failures"`
}

ReachabilityDetails is the additive, flat projection shared by every admin status response. LastProbeAt is the completed-outcome time: when the standing success or failure completed, never when a later inconclusive or in-flight attempt merely ran. A nil LastProbeAt is encoded as JSON null when no probe has completed yet; the remaining fields retain stable zero values.

type RemoveResponse

type RemoveResponse struct {
	Success bool    `json:"success"`
	Name    string  `json:"name"`
	Error   *string `json:"error,omitempty"`
}

RemoveResponse is the response for vision_remove.

type RestartDrain added in v1.8.3

type RestartDrain struct {
	Outcome           string   `json:"outcome" jsonschema:"drained or timed_out"`
	TimeoutMS         int64    `json:"timeout_ms" jsonschema:"Positive drain timeout in milliseconds"`
	RemainingRequests []uint64 `json:"remaining_requests" jsonschema:"Opaque IDs of requests remaining when the drain ended"`
}

RestartDrain reports the bounded drain of requests for a shared target. Outcome is "drained" or "timed_out". TimeoutMS must be positive. RemainingRequests contains opaque request IDs; it must be empty when drained. A "timed_out" restart is aborted: the target is not restarted, held requests keep running, and admission reopens. The response has success=false and an error.

type RestartResponse

type RestartResponse struct {
	Success         bool          `json:"success"`
	Name            string        `json:"name"`
	Status          string        `json:"status,omitempty"`
	EffectiveReason *string       `json:"effective_reason,omitempty"`
	ProcessState    string        `json:"process_state,omitempty"`
	Port            *int          `json:"port,omitempty"`
	Error           *string       `json:"error,omitempty"`
	Drain           *RestartDrain `json:"drain,omitempty"`
	ReachabilityDetails
}

RestartResponse is the response for vision_restart.

type Server

type Server struct {
	Metrics *metrics.DaemonMetrics
	// contains filtered or unexported fields
}

Server is the Admin MCP server that provides management tools.

func NewServer

func NewServer(cfg Config) *Server

NewServer creates a new Admin MCP server.

func (*Server) IsRunning

func (s *Server) IsRunning() bool

IsRunning returns whether the server is currently running.

func (*Server) Port

func (s *Server) Port() int

Port returns the port the server is configured to run on.

func (*Server) SetReachabilityStore added in v1.5.0

func (s *Server) SetReachabilityStore(store *reachability.Store)

SetReachabilityStore wires the daemon-owned probe evidence store after the admin server has been constructed.

func (*Server) SetServerMetricsAccessor added in v1.2.5

func (s *Server) SetServerMetricsAccessor(a ServerMetricsAccessor)

SetServerMetricsAccessor wires the per-server metrics accessor after construction.

func (*Server) SetSessionLifecycleAccessor added in v1.3.3

func (s *Server) SetSessionLifecycleAccessor(a SessionLifecycleAccessor)

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start begins serving the Admin MCP server.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts down the Admin MCP server.

type ServerMetricsAccessor added in v1.2.5

type ServerMetricsAccessor interface {
	ServerMetricsSnapshot(serverName string) *metrics.ServerMetricsSnapshot
}

ServerMetricsAccessor provides per-server session metrics. The daemon wires a concrete implementation; when nil, metrics are omitted.

type SessionLifecycleAccessor added in v1.3.3

type SessionLifecycleAccessor interface {
	SessionLifecycleSnapshot(serverName string) *SessionLifecycleSnapshot
}

type SessionLifecycleRow added in v1.3.3

type SessionLifecycleRow struct {
	SafeID                 string `json:"safe_id"`
	State                  string `json:"state"`
	AgeSeconds             int64  `json:"age_seconds"`
	ApplicationIdleSeconds int64  `json:"application_idle_seconds"`
	InFlight               int    `json:"in_flight"`
	SSEConnections         int    `json:"sse_connections"`
	LifecycleReason        string `json:"lifecycle_reason"`
}

SessionLifecycleRow is a secret-safe immutable projection of one managed native-HTTP session. SafeID is a bounded hash, never the MCP session ID.

type SessionLifecycleSnapshot added in v1.3.3

type SessionLifecycleSnapshot struct {
	BackendState  string                `json:"backend_state"`
	CapacityUsed  int                   `json:"capacity_used"`
	CapacityMax   int                   `json:"capacity_max"`
	Sessions      []SessionLifecycleRow `json:"sessions"`
	Closed        []SessionLifecycleRow `json:"closed"`
	Omitted       int                   `json:"omitted"`
	ClosedOmitted int                   `json:"closed_omitted"`
}

SessionLifecycleSnapshot is bounded by the lease manager: at most 100 active rows are projected and at most 1,000 closed rows are retained.

type SlotDetail

type SlotDetail struct {
	Name            string  `json:"name"`
	Port            int     `json:"port"`
	ActiveSessions  int     `json:"active_sessions"`
	MaxSessions     int     `json:"max_sessions"`
	EffectiveStatus string  `json:"effective_status"`
	EffectiveReason *string `json:"effective_reason,omitempty"`
	ReachabilityDetails
}

SlotDetail describes one slot within a group.

type SlotGroupEntry

type SlotGroupEntry struct {
	Name      string   `json:"name"`
	GroupPort int      `json:"group_port"`
	Slots     []string `json:"slots"`
}

SlotGroupEntry describes one slot group in the vision_list response.

type SlotGroupStatus

type SlotGroupStatus struct {
	GroupName string       `json:"group_name"`
	SlotCount int          `json:"slot_count"`
	Slots     []SlotDetail `json:"slots"`
}

SlotGroupStatus describes one slot group with per-slot session detail.

type SlotSessionAccessor

type SlotSessionAccessor interface {
	ActiveSessionCount(slotName string) int
}

SlotSessionAccessor provides active session counts for slot servers. The daemon wires a concrete implementation; when nil, active_sessions is 0.

type SlotStatusResponse

type SlotStatusResponse struct {
	Groups []SlotGroupStatus `json:"groups"`
}

SlotStatusResponse is the response for vision_slot_status.

type StatusResponse

type StatusResponse struct {
	Healthy  bool          `json:"healthy"`
	Uptime   string        `json:"uptime"`
	Servers  StatusServers `json:"servers"`
	MemoryMB float64       `json:"memory_mb"`
	Warnings []string      `json:"warnings,omitempty"`
}

StatusResponse is the response for vision_status.

type StatusServers

type StatusServers struct {
	Running int `json:"running"`
	Stopped int `json:"stopped"`
	Error   int `json:"error"`
}

StatusServers is the server counts in StatusResponse.

type Tool

type Tool struct {
	Name         string             `json:"name"`
	Description  string             `json:"description"`
	InputSchema  InputSchema        `json:"inputSchema"`
	OutputSchema *jsonschema.Schema `json:"outputSchema"`
}

Tool represents an MCP tool definition.

type ToolCallResult

type ToolCallResult struct {
	Content           []ToolContent `json:"content"`
	StructuredContent any           `json:"structuredContent,omitempty"`
	IsError           bool          `json:"isError,omitempty"`
}

ToolCallResult is the response to tools/call.

type ToolContent

type ToolContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

ToolContent is a single piece of content in a tool result.

type ValidationError

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

ValidationError is returned for invalid tool arguments.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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