Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions cmd/obs-mcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/mark3labs/mcp-go/server"
"github.com/rhobs/obs-mcp/pkg/k8s"
"github.com/rhobs/obs-mcp/pkg/mcp"
"github.com/rhobs/obs-mcp/pkg/perses"
"github.com/rhobs/obs-mcp/pkg/prometheus"
)

Expand All @@ -29,6 +30,8 @@ func main() {
var guardrails = flag.String("guardrails", "all", "Guardrails configuration: 'all' (default), 'none', or comma-separated list of guardrails to enable (disallow-explicit-name-label, require-label-matcher, disallow-blanket-regex)")
var maxMetricCardinality = flag.Uint64("guardrails.max-metric-cardinality", 20000, "Maximum allowed series count per metric (0 = disabled)")
var maxLabelCardinality = flag.Uint64("guardrails.max-label-cardinality", 500, "Maximum allowed label value count for blanket regex (0 = always disallow blanket regex). Only takes effect if disallow-blanket-regex is enabled.")
var ootbDashboards = flag.String("ootb-dashboards", "", "Path to YAML file containing out-of-the-box PersesDashboard definitions")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be estimated dynamically from inside the cluster (based on certain OCP-specific annotations)?

I'm concerned about version skews leading to the MCP server thinking that something exists when it doesn't (or vice-versa)? Internal estimation would get us rid of having to update this file each release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be feasible to reuse the listing capability introduced in this PR to get all such in-house dashboards, and prepare an "OOTB" structured output from those?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that might actually be better, I guess we'll need some specific label/annotation!
Maybe operator.dev.perses/ocp-platform?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would operator.dev.perses/mcp-discovery make sense (keeping it in-line with the operator.dev.perses/mcp-help annotation introduced here)? No strong opinions, though.


flag.Parse()

// Configure slog with specified log level
Expand All @@ -55,12 +58,22 @@ func main() {
parsedGuardrails.MaxLabelCardinality = *maxLabelCardinality
}

// Load out-of-the-box dashboards if specified
ootbDashboardsList, err := perses.LoadOOTBDashboards(*ootbDashboards)
if err != nil {
log.Fatalf("Failed to load OOTB dashboards: %v", err)
}
if len(ootbDashboardsList) > 0 {
slog.Info("Loaded out-of-the-box dashboards", "count", len(ootbDashboardsList))
}

// Create MCP options
opts := mcp.ObsMCPOptions{
AuthMode: parsedAuthMode,
PromURL: promURL,
Insecure: *insecure,
Guardrails: parsedGuardrails,
AuthMode: parsedAuthMode,
PromURL: promURL,
Insecure: *insecure,
Guardrails: parsedGuardrails,
OOTBDashboards: ootbDashboardsList,
}

// Create MCP server
Expand Down
34 changes: 32 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,91 @@ go 1.24.6

require (
github.com/mark3labs/mcp-go v0.39.1
github.com/perses/perses-operator v0.2.0
github.com/prometheus/client_golang v1.23.2
github.com/prometheus/common v0.67.1
github.com/prometheus/prometheus v0.307.3
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.34.1
k8s.io/client-go v0.34.1
sigs.k8s.io/controller-runtime v0.22.4
)

require (
cel.dev/expr v0.24.0 // indirect
github.com/PaesslerAG/gval v1.2.4 // indirect
github.com/PaesslerAG/jsonpath v0.1.2-0.20240726212847-3a740cf7976f // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/brunoga/deep v1.2.5 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-jose/go-jose/v4 v4.1.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/cel-go v0.26.0 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/labstack/echo/v4 v4.13.4 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/nexucis/lamenv v0.5.2 // indirect
github.com/perses/common v0.27.1-0.20250326140707-96e439b14e0e // indirect
github.com/perses/perses v0.51.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
github.com/zitadel/oidc/v3 v3.38.1 // indirect
github.com/zitadel/schema v1.3.1 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/exp v0.0.0-20250808145144-a408d31f581a // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/oauth2 v0.31.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/term v0.35.0 // indirect
golang.org/x/text v0.29.0 // indirect
golang.org/x/time v0.13.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250922171735-9219d122eba9 // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.34.1 // indirect
k8s.io/apimachinery v0.34.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
Expand Down
Loading