fix(mcp): filter list_incidents by the token's visible servers
This commit is contained in:
@@ -187,6 +187,12 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// Metric incidents name a server, so a server-scoped token sees only
|
||||
// the ones on servers it can see, matching the REST endpoint.
|
||||
visible, restricted, err := services.VisibleServerIDs(c.InstanceID, c.TokenScope)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not resolve visible servers: %w", err)
|
||||
}
|
||||
out := []incidentSummary{}
|
||||
for _, mid := range monitorIDs {
|
||||
if len(out) >= int(limit) {
|
||||
@@ -196,6 +202,7 @@ func init() {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not list incidents: %w", err)
|
||||
}
|
||||
incidents = services.FilterByVisibleServer(incidents, func(i models.Incident) string { return i.ServerID }, visible, restricted)
|
||||
name := mid
|
||||
if monitorNames != nil {
|
||||
if n, ok := monitorNames[mid]; ok {
|
||||
|
||||
Reference in New Issue
Block a user