Documentation
¶
Index ¶
- Variables
- func AllTools() []mcp.Tool
- func CreateExecuteInstantQueryTool() mcp.Tool
- func CreateExecuteRangeQueryTool() mcp.Tool
- func CreateGetAlertsTool() mcp.Tool
- func CreateGetLabelNamesTool() mcp.Tool
- func CreateGetLabelValuesTool() mcp.Tool
- func CreateGetSeriesTool() mcp.Tool
- func CreateGetSilencesTool() mcp.Tool
- func CreateListMetricsTool() mcp.Tool
- func CreateShowTimeseriesTool() mcp.Tool
- func ExecuteInstantQueryHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.InstantQueryInput, tools.InstantQueryOutput]
- func ExecuteRangeQueryHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.RangeQueryInput, tools.RangeQueryOutput]
- func GetAlertsHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.AlertsInput, tools.AlertsOutput]
- func GetLabelNamesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.LabelNamesInput, tools.LabelNamesOutput]
- func GetLabelValuesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.LabelValuesInput, tools.LabelValuesOutput]
- func GetSeriesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.SeriesInput, tools.SeriesOutput]
- func GetSilencesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.SilencesInput, tools.SilencesOutput]
- func ListMetricsHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.ListMetricsInput, tools.ListMetricsOutput]
- func NewMCPServer(opts ObsMCPOptions) (*mcp.Server, error)
- func NewStructuredResult(content string, structuredContent any, err error) *mcp.CallToolResult
- func Serve(ctx context.Context, mcpServer *mcp.Server, listenAddr string, ...) error
- func ServerToolToGoSdkTool(mgr *kubernetes.Manager, cfg api.BaseConfig, tool api.ServerTool) (*mcp.Tool, mcp.ToolHandler, error)
- func SetupTools(mcpServer *mcp.Server, opts ObsMCPOptions) error
- func ShowTimeseriesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.ShowTimeseriesInput, struct{}]
- type ContextKey
- type ObsMCPOptions
- type ToolCallRequest
- type ToolGroup
- type Toolset
Constants ¶
This section is empty.
Variables ¶
var AllToolsets = []string{string(ToolsetMetrics), string(ToolsetTraces), string(ToolsetLogs), string(ToolsetOtelcol)}
Functions ¶
func AllTools ¶
AllTools returns all available MCP tools. When adding a new tool, add it to pkg/tools/definitions.go to keep both MCP and Toolset in sync, as well as docs.
func CreateGetAlertsTool ¶
func CreateGetLabelNamesTool ¶
func CreateGetSeriesTool ¶
func CreateGetSilencesTool ¶
func CreateListMetricsTool ¶
Individual tool creation functions for backward compatibility and testing
func ExecuteInstantQueryHandler ¶
func ExecuteInstantQueryHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.InstantQueryInput, tools.InstantQueryOutput]
ExecuteInstantQueryHandler handles the execution of Prometheus instant queries.
func ExecuteRangeQueryHandler ¶
func ExecuteRangeQueryHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.RangeQueryInput, tools.RangeQueryOutput]
ExecuteRangeQueryHandler handles the execution of Prometheus range queries.
func GetAlertsHandler ¶
func GetAlertsHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.AlertsInput, tools.AlertsOutput]
GetAlertsHandler handles the retrieval of alerts from Alertmanager.
func GetLabelNamesHandler ¶
func GetLabelNamesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.LabelNamesInput, tools.LabelNamesOutput]
GetLabelNamesHandler handles the retrieval of label names.
func GetLabelValuesHandler ¶
func GetLabelValuesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.LabelValuesInput, tools.LabelValuesOutput]
GetLabelValuesHandler handles the retrieval of label values.
func GetSeriesHandler ¶
func GetSeriesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.SeriesInput, tools.SeriesOutput]
GetSeriesHandler handles the retrieval of time series.
func GetSilencesHandler ¶
func GetSilencesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.SilencesInput, tools.SilencesOutput]
GetSilencesHandler handles the retrieval of silences from Alertmanager.
func ListMetricsHandler ¶
func ListMetricsHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.ListMetricsInput, tools.ListMetricsOutput]
ListMetricsHandler handles the listing of available Prometheus metrics.
func NewMCPServer ¶
func NewMCPServer(opts ObsMCPOptions) (*mcp.Server, error)
func NewStructuredResult ¶ added in v0.6.0
func NewStructuredResult(content string, structuredContent any, err error) *mcp.CallToolResult
NewStructuredResult creates an MCP CallToolResult with structured content. The Content field contains the JSON-serialized form of structuredContent for backward compatibility with MCP clients that don't support structuredContent.
Per the MCP specification, structuredContent must marshal to a JSON object. If structuredContent is a slice/array, it is automatically wrapped in {"items": [...]} to satisfy this requirement.
Per the MCP specification: "For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block." https://modelcontextprotocol.io/specification/2025-11-25/server/tools#structured-content
Use this for tools that return typed/structured data that MCP clients can parse programmatically.
func ServerToolToGoSdkTool ¶ added in v0.6.0
func ServerToolToGoSdkTool(mgr *kubernetes.Manager, cfg api.BaseConfig, tool api.ServerTool) (*mcp.Tool, mcp.ToolHandler, error)
func SetupTools ¶
func SetupTools(mcpServer *mcp.Server, opts ObsMCPOptions) error
func ShowTimeseriesHandler ¶
func ShowTimeseriesHandler(opts ObsMCPOptions) mcp.ToolHandlerFor[tools.ShowTimeseriesInput, struct{}]
ShowTimeseriesHandler handles the show_timeseries tool.
Types ¶
type ContextKey ¶
type ContextKey string
const ( // TestPromClientKey is the context key for injecting a test Prometheus client TestPromClientKey ContextKey = "test-prometheus-client" // TestAlertmanagerClientKey is the context key for injecting a test Alertmanager client TestAlertmanagerClientKey ContextKey = "test-alertmanager-client" )
type ObsMCPOptions ¶
type ObsMCPOptions struct {
Toolsets []Toolset
AuthMode auth.AuthMode
MetricsBackendURL string
AlertmanagerURL string
Insecure bool
Guardrails *prometheus.Guardrails
FullRangeQueryResponse bool
Traces *traces.Config
Otelcol *otelcol.Config
Logs *logs.Config
}
ObsMCPOptions contains configuration options for the MCP server
type ToolCallRequest ¶ added in v0.6.0
type ToolCallRequest struct {
Name string
// contains filtered or unexported fields
}
func GoSdkToolCallParamsToToolCallRequest ¶ added in v0.6.0
func GoSdkToolCallParamsToToolCallRequest(toolCallParams *mcp.CallToolParamsRaw) (*ToolCallRequest, error)
func GoSdkToolCallRequestToToolCallRequest ¶ added in v0.6.0
func GoSdkToolCallRequestToToolCallRequest(request *mcp.CallToolRequest) (*ToolCallRequest, error)
func (*ToolCallRequest) GetArguments ¶ added in v0.6.0
func (t *ToolCallRequest) GetArguments() map[string]any
type ToolGroup ¶ added in v0.4.0
ToolGroup holds a named category of tools for documentation generation.
func GroupedTools ¶ added in v0.4.0
func GroupedTools() []ToolGroup
GroupedTools returns tools organized by category for documentation.