Documentation
¶
Index ¶
Constants ¶
const ( // GetIncidentsDescription describes the get_incidents MCP tool. GetIncidentsDescription = `` /* 254-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func NewIncidentLoaders ¶
func NewIncidentLoaders(restConfig *rest.Config, prometheusURL, alertmanagerURL, caFile string) (prom.Loader, alertmanager.Loader, error)
NewIncidentLoaders creates HTTPS loaders using the caller's REST credentials and the supplied backend CA, rather than the Kubernetes API CA.
Types ¶
type GetIncidentsParams ¶
type GetIncidentsParams struct {
TimeRange float64 `json:"time_range"`
MinSeverity string `json:"min_severity"`
}
func NormalizeGetIncidentsParams ¶
func NormalizeGetIncidentsParams(params GetIncidentsParams, timeRangeSupplied, minSeveritySupplied bool) (GetIncidentsParams, error)
NormalizeGetIncidentsParams applies defaults to omitted arguments and validates supplied hours and severity. The supplied flags distinguish omission from an explicit zero or empty value.
type Incident ¶
type Incident struct {
GroupId string `json:"id"`
Severity string `json:"severity"`
StartTime string `json:"start_time"`
Status string `json:"status"`
EndTime string `json:"end_time"`
Cluster string `json:"cluster,omitempty"`
ClusterID string `json:"cluster_id,omitempty"`
URL string `json:"url_details"`
Alerts []model.LabelSet `json:"alerts"`
AlertsSet map[string]struct{} `json:"-"`
AffectedComponents []string `json:"affected_components"`
ComponentsSet map[string]struct{} `json:"-"`
}
func (*Incident) UpdateEndTime ¶
UpdateEndTime updates the end time of the incident following the following rules: if the new time is zero then set empty string if the existing time is empty (incident is active) then do nothing if the new time is after existing end time then update it with the new time, otherwise do nothing
func (*Incident) UpdateStatus ¶
func (i *Incident) UpdateStatus()
type IncidentTool ¶
func NewIncidentsTool ¶
func NewIncidentsTool(promURL, alertmanagerURL string) IncidentTool
NewIncidentsTool creates a new MCP tool for the incidents
func (*IncidentTool) GetIncidents ¶
func (i *IncidentTool) GetIncidents(ctx context.Context, params GetIncidentsParams, promLoader prom.Loader, amLoader alertmanager.Loader) (*mcp.CallToolResult, any, error)
GetIncidents retrieves incidents using the supplied clients, without depending on how the caller obtained its credentials.
func (*IncidentTool) IncidentsHandler ¶
func (i *IncidentTool) IncidentsHandler(ctx context.Context, request *mcp.CallToolRequest, params GetIncidentsParams) (*mcp.CallToolResult, any, error)
IncidentsHandler is the main handler for the Incidents. It connects to the in-cluster Prometheus and queries the Incidents metrics.
type MCPHealthServer ¶
type MCPHealthServer struct {
// contains filtered or unexported fields
}
MCPHealthServer is a helper and wrapper type providing basic methods to run the underlying SSE server and to register tools
func NewMCPHealthServer ¶
func NewMCPHealthServer(cfg MCPHealthServerCfg) (*MCPHealthServer, error)
NewMCPHealthServer returns an instance of the MCPHealthServer
func (*MCPHealthServer) RegisterTool ¶
func (m *MCPHealthServer) RegisterTool(t *mcp.Tool, handler mcp.ToolHandlerFor[any, any])
RegisterTool registers a new tool on the MCPHealthServer
func (*MCPHealthServer) Start ¶
func (m *MCPHealthServer) Start() error
Start runs the MCPHealthServer
type MCPHealthServerCfg ¶
type TokenReviewer ¶
type TokenReviewer struct {
// contains filtered or unexported fields
}
TokenReviewer validates bearer tokens using the Kubernetes TokenReview API.
func NewTokenReviewer ¶
func NewTokenReviewer(client kubernetes.Interface) *TokenReviewer
NewTokenReviewer creates a TokenReviewer with the given Kubernetes client.
func (*TokenReviewer) ValidateToken ¶
func (t *TokenReviewer) ValidateToken(ctx context.Context, token string) error
ValidateToken submits a TokenReview for the given token and returns an error when the token is invalid or nil when the token is authenticated.