Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Tool Name property for List Code Scanning Alerts tool#272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SamMorrowDrums merged 8 commits intomainfromaddToolName
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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

Expand Down
9 changes: 8 additions & 1 deletionpkg/github/code_scanning.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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")
Expand All@@ -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)
}
Expand Down
19 changes: 11 additions & 8 deletionspkg/github/code_scanning_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand DownExpand Up@@ -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,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp