feat(mcp): add cluster filter to list_alert_rules (#4288)#4302
feat(mcp): add cluster filter to list_alert_rules (#4288)#4302AvijitBhattacharjee wants to merge 1 commit into
Conversation
|
Thank you for your interest in contributing to the Harvest project! We require contributors to sign our Corporate contributor license agreement (CCLA), and we don"t have the user(s) @AvijitBhattacharjee on file. In order for us to review and merge your code, please follow the instructions in step 6 of creating a pull request. |
Add optional cluster and cluster_match parameters to the list_alert_rules MCP tool so users can scope results to a specific cluster. Filtering checks the rule's expr (substring) and labels["cluster"] (exact or regex), consistent with get_active_alerts and infrastructure_health. When neither parameter is provided, all rules are returned unchanged. Closes NetApp#4288
4670a2b to
6cf0758
Compare
|
Thank you for your interest in contributing to the Harvest project! We require contributors to sign our Corporate contributor license agreement (CCLA), and we don"t have the user(s) @AvijitBhattacharjee on file. In order for us to review and merge your code, please follow the instructions in step 6 of creating a pull request. |
|
@AvijitBhattacharjee Thanks for the contribution. Could you refill the CCLA form as your username in the filled form has a space as |
Title: feat(mcp): add cluster and cluster_match filter to list_alert_rules
Closes #4288
Summary
Adds optional cluster and cluster_match parameters to the list_alert_rules MCP tool, allowing users to scope results to a specific cluster instead of always returning every rule from alert_rules.yml and ems_alert_rules.yml.
Changes
mcp/pkg/mcptypes/types.go
Added ListAlertRulesRequest struct with cluster (exact match) and cluster_match (regex) fields, consistent with GetActiveAlertsRequest and InfrastructureHealthRequest.
mcp/cmd/server/main.go
Updated ListAlertRules handler signature from struct{} to mcptypes.ListAlertRulesRequest
Added input validation (rejects " and \ in cluster values) matching the pattern used by GetActiveAlerts and InfrastructureHealth
Added filterRulesByCluster — filters []rules.RuleInfo by checking the rule's expr (substring match) and labels["cluster"] (exact or regex match)
Added ruleMatchesCluster — core matching logic handling exact cluster name and compiled regex cases
Added filter annotation in response output when filtering is active
Updated Total Rules count to reflect filtered results
mcp/cmd/descriptions/descriptions.go
Added ListAlertRulesDesc constant with full documentation of the new parameters, replacing the previous inline string in createMCPServer()