Skip to content

feat(mcp): add cluster filter to list_alert_rules (#4288)#4302

Open
AvijitBhattacharjee wants to merge 1 commit into
NetApp:mainfrom
AvijitBhattacharjee:feature/4288-filter-list-alert-rules-by-cluster
Open

feat(mcp): add cluster filter to list_alert_rules (#4288)#4302
AvijitBhattacharjee wants to merge 1 commit into
NetApp:mainfrom
AvijitBhattacharjee:feature/4288-filter-list-alert-rules-by-cluster

Conversation

@AvijitBhattacharjee
Copy link
Copy Markdown

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()

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 23, 2026

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.
After signing the CCLA, you can ask us to recheck this PR by posting @cla-bot check as a comment to the PR.

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
@AvijitBhattacharjee AvijitBhattacharjee force-pushed the feature/4288-filter-list-alert-rules-by-cluster branch from 4670a2b to 6cf0758 Compare May 23, 2026 04:58
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 23, 2026

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.
After signing the CCLA, you can ask us to recheck this PR by posting @cla-bot check as a comment to the PR.

@rahulguptajss
Copy link
Copy Markdown
Contributor

@AvijitBhattacharjee Thanks for the contribution. Could you refill the CCLA form as your username in the filled form has a space as Avijit Bhattacharjee. It should be AvijitBhattacharjee. Once you do that, we can review the PR. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: allow filtering list_alert_rules by cluster

2 participants