admin

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 22 Imported by: 0

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.

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 AddResponse

type AddResponse struct {
	Success bool    `json:"success"`
	Name    string  `json:"name"`
	Status  string  `json:"status,omitempty"`
	Port    *int    `json:"port,omitempty"`
	Error   *string `json:"error,omitempty"`
}

AddResponse is the response for vision_add.

type Config

type Config struct {
	Registry            *server.Registry
	Catalog             *catalog.Catalog
	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
	Metrics             *metrics.DaemonMetrics
}

Config configures the Admin MCP server.

type GuidanceEntry

type GuidanceEntry struct {
	Name      string   `json:"name"`
	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"`
	Port   *int    `json:"port"`
	PID    *int    `json:"pid"`
	Uptime *string `json:"uptime"`
	Error  *string `json:"error"`
}

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"`
}

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 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 RestartResponse

type RestartResponse struct {
	Success bool    `json:"success"`
	Name    string  `json:"name"`
	Status  string  `json:"status,omitempty"`
	Port    *int    `json:"port,omitempty"`
	Error   *string `json:"error,omitempty"`
}

RestartResponse is the response for vision_restart.

type SearchResponse

type SearchResponse struct {
	Success bool                `json:"success"`
	Results []SearchResultEntry `json:"results"`
	Error   *string             `json:"error,omitempty"`
}

SearchResponse is the response for vision_search.

type SearchResultEntry

type SearchResultEntry struct {
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	Capabilities []string `json:"capabilities"`
	Installed    bool     `json:"installed"`
}

SearchResultEntry represents a server in search results.

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) 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 SlotDetail

type SlotDetail struct {
	Name           string `json:"name"`
	Port           int    `json:"port"`
	ActiveSessions int    `json:"active_sessions"`
	MaxSessions    int    `json:"max_sessions"`
}

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"`
}

Tool represents an MCP tool definition.

type ToolCallResult

type ToolCallResult struct {
	Content []ToolContent `json:"content"`
	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