mcp

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AllTools

func AllTools() []mcp.Tool

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 CreateExecuteInstantQueryTool

func CreateExecuteInstantQueryTool() mcp.Tool

func CreateExecuteRangeQueryTool

func CreateExecuteRangeQueryTool() mcp.Tool

func CreateGetAlertsTool

func CreateGetAlertsTool() mcp.Tool

func CreateGetLabelNamesTool

func CreateGetLabelNamesTool() mcp.Tool

func CreateGetLabelValuesTool

func CreateGetLabelValuesTool() mcp.Tool

func CreateGetSeriesTool

func CreateGetSeriesTool() mcp.Tool

func CreateGetSilencesTool

func CreateGetSilencesTool() mcp.Tool

func CreateListMetricsTool

func CreateListMetricsTool() mcp.Tool

Individual tool creation functions for backward compatibility and testing

func CreateShowTimeseriesTool

func CreateShowTimeseriesTool() mcp.Tool

func ExecuteInstantQueryHandler

ExecuteInstantQueryHandler handles the execution of Prometheus instant queries.

func ExecuteRangeQueryHandler

ExecuteRangeQueryHandler handles the execution of Prometheus range queries.

func GetAlertsHandler

GetAlertsHandler handles the retrieval of alerts from Alertmanager.

func GetLabelNamesHandler

GetLabelNamesHandler handles the retrieval of label names.

func GetLabelValuesHandler

GetLabelValuesHandler handles the retrieval of label values.

func GetSeriesHandler

GetSeriesHandler handles the retrieval of time series.

func GetSilencesHandler

GetSilencesHandler handles the retrieval of silences from Alertmanager.

func ListMetricsHandler

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 Serve

func Serve(ctx context.Context, mcpServer *mcp.Server, listenAddr string, authMode auth.AuthMode) error

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

type ToolGroup struct {
	Name  string
	Icon  string
	Tools []mcp.Tool
}

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.

type Toolset added in v0.2.0

type Toolset string
const (
	ToolsetMetrics Toolset = "observability/metrics"
	ToolsetTraces  Toolset = "observability/traces"
	ToolsetLogs    Toolset = "observability/logs"
	ToolsetOtelcol Toolset = "observability/otelcol"
)

Jump to

Keyboard shortcuts

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