Skip to content

Commit 9ab8a95

Browse files
ysyneuclaude
andauthored
fix: send channel_ids array to backend in query_incidents/query_changes (#43)
Backend /incident/list and /change/list expect channel_ids ([]int64), not channel_id (int). The singular field was silently dropped, causing the channel filter to leak incidents/changes from every channel. Renames the MCP tool parameter channel_id → channel_ids (comma-separated string), parsed via the existing parseCommaSeparatedInts helper, and supports filtering by multiple channels in one call. BREAKING: callers passing channel_id: <n> must switch to channel_ids: "<n>". Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 96978ba commit 9ab8a95

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

pkg/flashduty/changes.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func QueryChanges(getClient GetFlashdutyClientFn, t translations.TranslationHelp
2323
ReadOnlyHint: ToBoolPtr(true),
2424
}),
2525
mcp.WithString("change_ids", mcp.Description("Comma-separated change IDs for direct lookup.")),
26-
mcp.WithNumber("channel_id", mcp.Description("Filter by collaboration space ID.")),
26+
mcp.WithString("channel_ids", mcp.Description("Filter by collaboration space IDs. Comma-separated for multiple.")),
2727
mcp.WithNumber("start_time", mcp.Description("Query start time in Unix timestamp (seconds). Must be < end_time. Max range: 31 days. Defaults to 1 hour ago.")),
2828
mcp.WithNumber("end_time", mcp.Description("Query end time in Unix timestamp (seconds). Defaults to now.")),
2929
mcp.WithString("type", mcp.Description("Filter by change type.")),
@@ -35,7 +35,8 @@ func QueryChanges(getClient GetFlashdutyClientFn, t translations.TranslationHelp
3535
}
3636

3737
changeIdsStr, _ := OptionalParam[string](request, "change_ids")
38-
channelID, _ := OptionalInt(request, "channel_id")
38+
channelIdsStr, _ := OptionalParam[string](request, "channel_ids")
39+
filterChannelIDs := parseCommaSeparatedInts(channelIdsStr)
3940
startTime, _ := OptionalInt(request, "start_time")
4041
endTime, _ := OptionalInt(request, "end_time")
4142
changeType, _ := OptionalParam[string](request, "type")
@@ -54,8 +55,8 @@ func QueryChanges(getClient GetFlashdutyClientFn, t translations.TranslationHelp
5455
changeIDs := parseCommaSeparatedStrings(changeIdsStr)
5556
requestBody["change_ids"] = changeIDs
5657
}
57-
if channelID > 0 {
58-
requestBody["channel_id"] = channelID
58+
if len(filterChannelIDs) > 0 {
59+
requestBody["channel_ids"] = filterChannelIDs
5960
}
6061
if startTime > 0 {
6162
requestBody["start_time"] = startTime

pkg/flashduty/incidents.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func QueryIncidents(getClient GetFlashdutyClientFn, t translations.TranslationHe
3030
mcp.WithString("incident_ids", mcp.Description("Comma-separated incident IDs for direct lookup. If provided, other filters are ignored.")),
3131
mcp.WithString("progress", mcp.Description("Filter by status. Valid values: Triggered, Processing, Closed. Comma-separated for multiple."), mcp.Enum("Triggered", "Processing", "Closed", "Triggered,Processing", "Processing,Closed", "Triggered,Closed", "Triggered,Processing,Closed")),
3232
mcp.WithString("severity", mcp.Description("Filter by severity level. Valid values: Info, Warning, Critical."), mcp.Enum("Info", "Warning", "Critical")),
33-
mcp.WithNumber("channel_id", mcp.Description("Filter by collaboration space ID.")),
33+
mcp.WithString("channel_ids", mcp.Description("Filter by collaboration space IDs. Comma-separated for multiple.")),
3434
mcp.WithNumber("start_time", mcp.Description("Query start time in Unix timestamp (seconds). Required if no incident_ids. Must be < end_time. Max range: 31 days.")),
3535
mcp.WithNumber("end_time", mcp.Description("Query end time in Unix timestamp (seconds). Required if no incident_ids. Must be within data retention period.")),
3636
mcp.WithString("title", mcp.Description("Keyword search in incident title.")),
@@ -46,7 +46,8 @@ func QueryIncidents(getClient GetFlashdutyClientFn, t translations.TranslationHe
4646
incidentIdsStr, _ := OptionalParam[string](request, "incident_ids")
4747
progress, _ := OptionalParam[string](request, "progress")
4848
severity, _ := OptionalParam[string](request, "severity")
49-
channelID, _ := OptionalInt(request, "channel_id")
49+
channelIdsStr, _ := OptionalParam[string](request, "channel_ids")
50+
channelIDs := parseCommaSeparatedInts(channelIdsStr)
5051
startTime, _ := OptionalInt(request, "start_time")
5152
endTime, _ := OptionalInt(request, "end_time")
5253
title, _ := OptionalParam[string](request, "title")
@@ -75,7 +76,7 @@ func QueryIncidents(getClient GetFlashdutyClientFn, t translations.TranslationHe
7576
if startTime == 0 || endTime == 0 {
7677
return mcp.NewToolResultError("Both start_time and end_time are required for time-based queries"), nil
7778
}
78-
rawIncidents, err = client.fetchIncidentsByFilters(ctx, progress, severity, channelID, startTime, endTime, title, limit)
79+
rawIncidents, err = client.fetchIncidentsByFilters(ctx, progress, severity, channelIDs, startTime, endTime, title, limit)
7980
}
8081

8182
if err != nil {
@@ -312,7 +313,7 @@ func (c *Client) fetchIncidentsByIDs(ctx context.Context, incidentIDs []string)
312313
}
313314

314315
// fetchIncidentsByFilters fetches incidents by filters
315-
func (c *Client) fetchIncidentsByFilters(ctx context.Context, progress, severity string, channelID int, startTime, endTime int, title string, limit int) ([]RawIncident, error) {
316+
func (c *Client) fetchIncidentsByFilters(ctx context.Context, progress, severity string, channelIDs []int, startTime, endTime int, title string, limit int) ([]RawIncident, error) {
316317
requestBody := map[string]interface{}{
317318
"p": 1,
318319
"limit": limit,
@@ -326,8 +327,8 @@ func (c *Client) fetchIncidentsByFilters(ctx context.Context, progress, severity
326327
if severity != "" {
327328
requestBody["incident_severity"] = severity
328329
}
329-
if channelID > 0 {
330-
requestBody["channel_id"] = channelID
330+
if len(channelIDs) > 0 {
331+
requestBody["channel_ids"] = channelIDs
331332
}
332333
if title != "" {
333334
requestBody["title"] = title

0 commit comments

Comments
 (0)