Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
8 changes: 5 additions & 3 deletions cmd/mcp-grafana/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type disabledTools struct {
prometheus, loki, elasticsearch, alerting,
dashboard, folder, oncall, asserts, sift, admin,
pyroscope, navigation, proxied, annotations, rendering, cloudwatch, write,
examples, clickhouse, searchlogs,
examples, clickhouse, searchlogs, graphite,
runpanelquery bool
}

Expand All @@ -64,7 +64,7 @@ type grafanaConfig struct {
}

func (dt *disabledTools) addFlags() {
flag.StringVar(&dt.enabledTools, "enabled-tools", "search,datasource,incident,prometheus,loki,alerting,dashboard,folder,oncall,asserts,sift,pyroscope,navigation,proxied,annotations,rendering", "A comma separated list of tools enabled for this server. Can be overwritten entirely or by disabling specific components, e.g. --disable-search.")
flag.StringVar(&dt.enabledTools, "enabled-tools", "search,datasource,incident,prometheus,loki,alerting,dashboard,folder,oncall,asserts,sift,pyroscope,navigation,proxied,annotations,rendering,graphite", "A comma separated list of tools enabled for this server. Can be overwritten entirely or by disabling specific components, e.g. --disable-search.")
flag.BoolVar(&dt.search, "disable-search", false, "Disable search tools")
flag.BoolVar(&dt.datasource, "disable-datasource", false, "Disable datasource tools")
flag.BoolVar(&dt.incident, "disable-incident", false, "Disable incident tools")
Expand All @@ -89,6 +89,7 @@ func (dt *disabledTools) addFlags() {
flag.BoolVar(&dt.clickhouse, "disable-clickhouse", false, "Disable ClickHouse tools")
flag.BoolVar(&dt.searchlogs, "disable-searchlogs", false, "Disable search logs tools")
flag.BoolVar(&dt.runpanelquery, "disable-runpanelquery", false, "Disable run panel query tools")
flag.BoolVar(&dt.graphite, "disable-graphite", false, "Disable Graphite tools")
}

func (gc *grafanaConfig) addFlags() {
Expand Down Expand Up @@ -129,6 +130,7 @@ func (dt *disabledTools) addTools(s *server.MCPServer) {
maybeAddTools(s, tools.AddClickHouseTools, enabledTools, dt.clickhouse, "clickhouse")
maybeAddTools(s, tools.AddSearchLogsTools, enabledTools, dt.searchlogs, "searchlogs")
maybeAddTools(s, tools.AddRunPanelQueryTools, enabledTools, dt.runpanelquery, "runpanelquery")
maybeAddTools(s, tools.AddGraphiteTools, enabledTools, dt.graphite, "graphite")
}

func newServer(transport string, dt disabledTools, obs *observability.Observability, sessionIdleTimeoutMinutes int) (*server.MCPServer, *mcpgrafana.ToolManager, *mcpgrafana.SessionManager) {
Expand Down Expand Up @@ -473,4 +475,4 @@ func parseLevel(level string) slog.Level {
return slog.LevelInfo
}
return l
}
}
7 changes: 5 additions & 2 deletions tools/fallback_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ func (t *datasourceFallbackTransport) RoundTrip(req *http.Request) (*http.Respon
return nil, retryErr
}

// If the fallback succeeded, remember it for future requests.
if retryResp.StatusCode != http.StatusForbidden && retryResp.StatusCode != http.StatusInternalServerError {
// Only cache the fallback path when the fallback actually returned a
// successful (2xx) response. A 4xx from the fallback means neither path
// is working for this particular request; caching it would silently break
// all subsequent calls that would otherwise succeed via the primary path.
if retryResp.StatusCode >= 200 && retryResp.StatusCode < 300 {
fallbackEndpoints.Store(t.primaryBase, true)
}

Expand Down
Loading