Add Tool Name property for List Code Scanning Alerts tool (#272)
This commit is contained in:
@@ -436,6 +436,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
|
||||
- `ref`: Git reference (string, optional)
|
||||
- `state`: Alert state (string, optional)
|
||||
- `severity`: Alert severity (string, optional)
|
||||
- `tool_name`: The name of the tool used for code scanning (string, optional)
|
||||
|
||||
## Resources
|
||||
|
||||
|
||||
@@ -94,6 +94,9 @@ func ListCodeScanningAlerts(getClient GetClientFn, t translations.TranslationHel
|
||||
mcp.Description("Filter code scanning alerts by severity"),
|
||||
mcp.Enum("critical", "high", "medium", "low", "warning", "note", "error"),
|
||||
),
|
||||
mcp.WithString("tool_name",
|
||||
mcp.Description("The name of the tool used for code scanning."),
|
||||
),
|
||||
),
|
||||
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
owner, err := requiredParam[string](request, "owner")
|
||||
@@ -116,12 +119,16 @@ func ListCodeScanningAlerts(getClient GetClientFn, t translations.TranslationHel
|
||||
if err != nil {
|
||||
return mcp.NewToolResultError(err.Error()), nil
|
||||
}
|
||||
toolName, err := OptionalParam[string](request, "tool_name")
|
||||
if err != nil {
|
||||
return mcp.NewToolResultError(err.Error()), nil
|
||||
}
|
||||
|
||||
client, err := getClient(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
|
||||
}
|
||||
alerts, resp, err := client.CodeScanning.ListAlertsForRepo(ctx, owner, repo, &github.AlertListOptions{Ref: ref, State: state, Severity: severity})
|
||||
alerts, resp, err := client.CodeScanning.ListAlertsForRepo(ctx, owner, repo, &github.AlertListOptions{Ref: ref, State: state, Severity: severity, ToolName: toolName})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to list alerts: %w", err)
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ func Test_ListCodeScanningAlerts(t *testing.T) {
|
||||
assert.Contains(t, tool.InputSchema.Properties, "ref")
|
||||
assert.Contains(t, tool.InputSchema.Properties, "state")
|
||||
assert.Contains(t, tool.InputSchema.Properties, "severity")
|
||||
assert.Contains(t, tool.InputSchema.Properties, "tool_name")
|
||||
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo"})
|
||||
|
||||
// Setup mock alerts for success case
|
||||
@@ -159,20 +160,22 @@ func Test_ListCodeScanningAlerts(t *testing.T) {
|
||||
mock.WithRequestMatchHandler(
|
||||
mock.GetReposCodeScanningAlertsByOwnerByRepo,
|
||||
expectQueryParams(t, map[string]string{
|
||||
"ref": "main",
|
||||
"state": "open",
|
||||
"severity": "high",
|
||||
"ref": "main",
|
||||
"state": "open",
|
||||
"severity": "high",
|
||||
"tool_name": "codeql",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, mockAlerts),
|
||||
),
|
||||
),
|
||||
),
|
||||
requestArgs: map[string]interface{}{
|
||||
"owner": "owner",
|
||||
"repo": "repo",
|
||||
"ref": "main",
|
||||
"state": "open",
|
||||
"severity": "high",
|
||||
"owner": "owner",
|
||||
"repo": "repo",
|
||||
"ref": "main",
|
||||
"state": "open",
|
||||
"severity": "high",
|
||||
"tool_name": "codeql",
|
||||
},
|
||||
expectError: false,
|
||||
expectedAlerts: mockAlerts,
|
||||
|
||||
Reference in New Issue
Block a user