Documentation
¶
Index ¶
Constants ¶
const ( HealthDown = "down" // error, or cannot connect HealthWarn = "warn" // up but something needs a look HealthOK = "ok" // up HealthIdle = "idle" // stopped on purpose, starts on demand HealthDisabled = "disabled" // enabled: false in the config )
Server health classes, from worst to best. They drive the status dot.
Variables ¶
var ErrReadOnly = errors.New("the dashboard is read-only: start it with --dashboard-token (or run `leanproxy-mcp daemon install`) to manage servers from here")
ErrReadOnly is returned by the write endpoints of a dashboard that has no token.
Functions ¶
Types ¶
type Admin ¶ added in v1.1.1
type Admin interface {
Overview() Overview
Servers() []ServerStatus
Sessions() []Session
Calls(limit int, server string) []Call
RestartServer(ctx context.Context, name string) error
SetServerEnabled(ctx context.Context, name string, enabled bool) error
AddServer(ctx context.Context, spec ServerSpec) error
RemoveServer(ctx context.Context, name string) error
Reload(ctx context.Context) error
}
Admin is what the admin views show and drive: the proxy's upstream servers, its client sessions and its recent tool calls. The proxy supplies it (cmd); a nil Admin leaves the dashboard with usage only.
The read methods back views anyone who can open the dashboard sees. The write methods are only reachable when the dashboard has a token (see writable): adding a stdio server runs a command as the proxy's user, so it must never be open to every local process.
type Call ¶ added in v1.1.1
type Call struct {
Time time.Time `json:"time"`
SessionID string `json:"session_id,omitempty"`
Client string `json:"client,omitempty"`
Server string `json:"server"`
Tool string `json:"tool"`
DurationMs float64 `json:"duration_ms"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
ResponseBytes int `json:"response_bytes"`
}
Call is one recent tool call: who called what, how long it took, how it ended. Never its arguments or its result.
type Config ¶
type Config struct {
Bind string
Token string
// AllowedHosts lists extra Host header values (--dashboard-allowed-hosts)
// accepted in addition to the bind host, localhost, 127.0.0.1 and ::1.
// Each is combined with the dashboard's own port unless it already
// names one. See pkg/httpsec.AllowedHosts.
AllowedHosts []string
// Usage supplies the today / week-to-date figures, read from the usage
// store (pkg/usage.Live). A nil func, or one returning nil (the store
// could not be read), renders an "unavailable" state instead of zeros.
Usage func() *metrics.UsageSummary
// Admin supplies the servers, clients and calls views and their write
// actions. Nil: the dashboard shows usage only. The write actions are
// available only when Token is set.
Admin Admin
}
type DashboardData ¶
type DashboardData struct {
// Available is false when there is no usage data source.
Available bool
Estimator string
TodaySaved string
TodayOriginal string
TodayPercent string
WeekSaved string
WeekOriginal string
WeekPercent string
TopServer string
TopTool string
ServerCount int
ToolCount int
// NoToolData is true when today has no per-tool rows, which is what
// the response governor being off (the default) looks like.
NoToolData bool
Servers []ServerRow
// HasAdmin and Admin carry the admin views of the index page.
HasAdmin bool
Admin adminPage
}
DashboardData is what the index and summary cards render: the usage store's today and week-to-date windows (see metrics.UsageWindow), with token counts pre-formatted.
type Overview ¶ added in v1.1.1
type Overview struct {
Version string `json:"version"`
PID int `json:"pid"`
StartedAt time.Time `json:"started_at"`
Frontend string `json:"frontend"`
ConfigPath string `json:"config_path"`
// LastReloadAt is when the server list was last (re)read from the
// config file; LastReloadError is why the latest attempt failed.
LastReloadAt time.Time `json:"last_reload_at,omitzero"`
LastReloadError string `json:"last_reload_error,omitempty"`
}
Overview is the proxy process itself.
type ServerDrillDown ¶ added in v1.1.1
ServerDrillDown is one server's tools in today's window.
type ServerRow ¶
type ServerRow struct {
// Name is the server's name, empty for tool results the governor did
// not attribute to a server; Label is what the table shows and Path is
// Name escaped for the drill-down URL.
Name string
Label string
Path string
Tools int
Calls int64
Original string
Returned string
Saved string
}
ServerRow is one row of the server table (today's window).
type ServerSpec ¶ added in v1.1.1
type ServerSpec struct {
Name string
Transport string
// Stdio.
Command string
Args []string
Env []string
CWD string
// HTTP / SSE.
URL string
Headers map[string]string
}
ServerSpec is a server to add: a command (stdio) or a URL (http, sse).
type ServerStatus ¶ added in v1.1.1
type ServerStatus struct {
Name string `json:"name"`
Transport string `json:"transport"`
// Target is the command (stdio) or URL (HTTP/SSE), without arguments,
// query string or credentials.
Target string `json:"target,omitempty"`
Enabled bool `json:"enabled"`
State string `json:"state"`
Health string `json:"health"`
// Summary is one short line saying what Health means here.
Summary string `json:"summary"`
// SummaryIsError is true when Summary quotes the server's error text
// rather than a fixed sentence (see withoutDetails).
SummaryIsError bool `json:"-"`
Tools int `json:"tools"`
ToolsKnown bool `json:"tools_known"`
// PendingPins is how many tool definitions await approval (tool
// pinning).
PendingPins int `json:"pending_pins"`
Requests int64 `json:"requests"`
Errors int64 `json:"errors"`
AvgLatencyMs float64 `json:"avg_latency_ms"`
InFlight int `json:"in_flight"`
LastRequestAt time.Time `json:"last_request_at,omitzero"`
LastError string `json:"last_error,omitempty"`
LastErrorAt time.Time `json:"last_error_at,omitzero"`
Initialized bool `json:"initialized"`
ProtocolVersion string `json:"protocol_version,omitempty"`
ServerName string `json:"server_name,omitempty"`
ServerVersion string `json:"server_version,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
PID int `json:"pid,omitempty"`
Since time.Time `json:"since,omitzero"`
Restarts int `json:"restarts,omitempty"`
RecentStderr string `json:"recent_stderr,omitempty"`
// RefreshFailures counts consecutive failed tools/list refreshes;
// NextRetryAt is when the next one is due.
RefreshFailures int `json:"refresh_failures,omitempty"`
NextRetryAt time.Time `json:"next_retry_at,omitzero"`
}
ServerStatus is one configured upstream server and its runtime state.
type Session ¶ added in v1.1.1
type Session struct {
ID string `json:"id"`
Client string `json:"client"`
ClientVersion string `json:"client_version,omitempty"`
ProtocolVersion string `json:"protocol_version,omitempty"`
Exposure string `json:"exposure,omitempty"`
Initialized bool `json:"initialized"`
OpenedAt time.Time `json:"opened_at"`
LastCallAt time.Time `json:"last_call_at,omitzero"`
Calls int64 `json:"calls"`
}
Session is one connected MCP client.