Skip to content

Commit 614f226

Browse files
authored
Add Tool Name property for List Code Scanning Alerts tool (#272)
1 parent 4457d0a commit 614f226

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
436436
- `ref`: Git reference (string, optional)
437437
- `state`: Alert state (string, optional)
438438
- `severity`: Alert severity (string, optional)
439+
- `tool_name`: The name of the tool used for code scanning (string, optional)
439440

440441
## Resources
441442

Diff for: pkg/github/code_scanning.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func ListCodeScanningAlerts(getClient GetClientFn, t translations.TranslationHel
9494
mcp.Description("Filter code scanning alerts by severity"),
9595
mcp.Enum("critical", "high", "medium", "low", "warning", "note", "error"),
9696
),
97+
mcp.WithString("tool_name",
98+
mcp.Description("The name of the tool used for code scanning."),
99+
),
97100
),
98101
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
99102
owner, err := requiredParam[string](request, "owner")
@@ -116,12 +119,16 @@ func ListCodeScanningAlerts(getClient GetClientFn, t translations.TranslationHel
116119
if err != nil {
117120
return mcp.NewToolResultError(err.Error()), nil
118121
}
122+
toolName, err := OptionalParam[string](request, "tool_name")
123+
if err != nil {
124+
return mcp.NewToolResultError(err.Error()), nil
125+
}
119126

120127
client, err := getClient(ctx)
121128
if err != nil {
122129
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
123130
}
124-
alerts, resp, err := client.CodeScanning.ListAlertsForRepo(ctx, owner, repo, &github.AlertListOptions{Ref: ref, State: state, Severity: severity})
131+
alerts, resp, err := client.CodeScanning.ListAlertsForRepo(ctx, owner, repo, &github.AlertListOptions{Ref: ref, State: state, Severity: severity, ToolName: toolName})
125132
if err != nil {
126133
return nil, fmt.Errorf("failed to list alerts: %w", err)
127134
}

Diff for: pkg/github/code_scanning_test.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func Test_ListCodeScanningAlerts(t *testing.T) {
127127
assert.Contains(t, tool.InputSchema.Properties, "ref")
128128
assert.Contains(t, tool.InputSchema.Properties, "state")
129129
assert.Contains(t, tool.InputSchema.Properties, "severity")
130+
assert.Contains(t, tool.InputSchema.Properties, "tool_name")
130131
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo"})
131132

132133
// Setup mock alerts for success case
@@ -159,20 +160,22 @@ func Test_ListCodeScanningAlerts(t *testing.T) {
159160
mock.WithRequestMatchHandler(
160161
mock.GetReposCodeScanningAlertsByOwnerByRepo,
161162
expectQueryParams(t, map[string]string{
162-
"ref": "main",
163-
"state": "open",
164-
"severity": "high",
163+
"ref": "main",
164+
"state": "open",
165+
"severity": "high",
166+
"tool_name": "codeql",
165167
}).andThen(
166168
mockResponse(t, http.StatusOK, mockAlerts),
167169
),
168170
),
169171
),
170172
requestArgs: map[string]interface{}{
171-
"owner": "owner",
172-
"repo": "repo",
173-
"ref": "main",
174-
"state": "open",
175-
"severity": "high",
173+
"owner": "owner",
174+
"repo": "repo",
175+
"ref": "main",
176+
"state": "open",
177+
"severity": "high",
178+
"tool_name": "codeql",
176179
},
177180
expectError: false,
178181
expectedAlerts: mockAlerts,

0 commit comments

Comments
 (0)