Documentation
¶
Overview ¶
Package mcp implements a Model Context Protocol (MCP) server that exposes promql-cli over stdio transport (JSON-RPC 2.0, protocol 2024-11-05).
Capabilities:
tools — query_instant, query_range, list_metrics, list_labels,
load_metrics, execute_line (with optional streaming)
resources — promql://metrics, promql://metrics/list, promql://labels,
and one promql://metrics/<name> per loaded metric
prompts — parameterized PromQL templates (error-rate-by-service, etc.)
logging — logging/setLevel to adjust slog verbosity at runtime
executionStreaming — execute_line stream=true support
Lifecycle methods: initialize, ping, shutdown, notifications/initialized.
Source layout:
mcp.go — Server, transport framing, dispatch, lifecycle, logging tools.go — tool definitions, handlers, query execution, formatting resources.go — resources/list + resources/read prompts.go — prompts/list + prompts/get
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetServerVersion ¶ added in v0.6.2
func SetServerVersion(v string)
SetServerVersion overrides the version reported in the MCP initialize response (e.g. with the version resolved from build info at runtime).
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the MCP protocol over stdin/stdout.
func NewServer ¶
func NewServer(engine *promql.Engine, storage *sstorage.SimpleStorage) *Server
NewServer creates an MCP server over stdin/stdout.
func NewServerWithIO ¶ added in v0.6.1
func NewServerWithIO(engine *promql.Engine, storage *sstorage.SimpleStorage, in io.Reader, out io.Writer) *Server
NewServerWithIO creates an MCP server over the given reader/writer. The writer is captured once, so later swaps of os.Stdout (e.g. output capture during execute_line) never affect protocol frames.