Skip to content

Commit 6d3954d

Browse files
authored
Merge branch 'main' into tonytrg/add-secret-scanning-tools
2 parents 47fdf2e + 614f226 commit 6d3954d

File tree

8 files changed

+52
-32
lines changed

8 files changed

+52
-32
lines changed

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

cmd/github-mcp-server/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
Use: "server",
3030
Short: "GitHub MCP Server",
3131
Long: `A GitHub MCP server that handles various tools and resources.`,
32-
Version: fmt.Sprintf("%s (%s) %s", version, commit, date),
32+
Version: fmt.Sprintf("Version: %s\nCommit: %s\nBuild Date: %s", version, commit, date),
3333
}
3434

3535
stdioCmd = &cobra.Command{
@@ -65,6 +65,8 @@ var (
6565
func init() {
6666
cobra.OnInitialize(initConfig)
6767

68+
rootCmd.SetVersionTemplate("{{.Short}}\n{{.Version}}\n")
69+
6870
// Add global flags that will be shared by all commands
6971
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools, "An optional comma separated list of groups of tools to allow, defaults to enabling all")
7072
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets")

pkg/github/code_scanning.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,16 @@ func ListCodeScanningAlerts(getClient GetClientFn, t translations.TranslationHel
8686
mcp.Description("The Git reference for the results you want to list."),
8787
),
8888
mcp.WithString("state",
89-
mcp.Description("State of the code scanning alerts to list. Set to closed to list only closed code scanning alerts. Default: open"),
89+
mcp.Description("Filter code scanning alerts by state. Defaults to open"),
9090
mcp.DefaultString("open"),
91+
mcp.Enum("open", "closed", "dismissed", "fixed"),
9192
),
9293
mcp.WithString("severity",
93-
mcp.Description("Only code scanning alerts with this severity will be returned. Possible values are: critical, high, medium, low, warning, note, error."),
94+
mcp.Description("Filter code scanning alerts by severity"),
95+
mcp.Enum("critical", "high", "medium", "low", "warning", "note", "error"),
96+
),
97+
mcp.WithString("tool_name",
98+
mcp.Description("The name of the tool used for code scanning."),
9499
),
95100
),
96101
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
@@ -114,12 +119,16 @@ func ListCodeScanningAlerts(getClient GetClientFn, t translations.TranslationHel
114119
if err != nil {
115120
return mcp.NewToolResultError(err.Error()), nil
116121
}
122+
toolName, err := OptionalParam[string](request, "tool_name")
123+
if err != nil {
124+
return mcp.NewToolResultError(err.Error()), nil
125+
}
117126

118127
client, err := getClient(ctx)
119128
if err != nil {
120129
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
121130
}
122-
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})
123132
if err != nil {
124133
return nil, fmt.Errorf("failed to list alerts: %w", err)
125134
}

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,

pkg/github/issues.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func AddIssueComment(getClient GetClientFn, t translations.TranslationHelperFunc
9090
),
9191
mcp.WithString("body",
9292
mcp.Required(),
93-
mcp.Description("Comment text"),
93+
mcp.Description("Comment content"),
9494
),
9595
),
9696
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
@@ -151,7 +151,7 @@ func SearchIssues(getClient GetClientFn, t translations.TranslationHelperFunc) (
151151
mcp.Description("Search query using GitHub issues search syntax"),
152152
),
153153
mcp.WithString("sort",
154-
mcp.Description("Sort field (comments, reactions, created, etc.)"),
154+
mcp.Description("Sort field by number of matches of categories, defaults to best match"),
155155
mcp.Enum(
156156
"comments",
157157
"reactions",
@@ -167,7 +167,7 @@ func SearchIssues(getClient GetClientFn, t translations.TranslationHelperFunc) (
167167
),
168168
),
169169
mcp.WithString("order",
170-
mcp.Description("Sort order ('asc' or 'desc')"),
170+
mcp.Description("Sort order"),
171171
mcp.Enum("asc", "desc"),
172172
),
173173
WithPagination(),
@@ -357,7 +357,7 @@ func ListIssues(getClient GetClientFn, t translations.TranslationHelperFunc) (to
357357
mcp.Description("Repository name"),
358358
),
359359
mcp.WithString("state",
360-
mcp.Description("Filter by state ('open', 'closed', 'all')"),
360+
mcp.Description("Filter by state"),
361361
mcp.Enum("open", "closed", "all"),
362362
),
363363
mcp.WithArray("labels",
@@ -369,11 +369,11 @@ func ListIssues(getClient GetClientFn, t translations.TranslationHelperFunc) (to
369369
),
370370
),
371371
mcp.WithString("sort",
372-
mcp.Description("Sort by ('created', 'updated', 'comments')"),
372+
mcp.Description("Sort order"),
373373
mcp.Enum("created", "updated", "comments"),
374374
),
375375
mcp.WithString("direction",
376-
mcp.Description("Sort direction ('asc', 'desc')"),
376+
mcp.Description("Sort direction"),
377377
mcp.Enum("asc", "desc"),
378378
),
379379
mcp.WithString("since",
@@ -485,7 +485,7 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
485485
mcp.Description("New description"),
486486
),
487487
mcp.WithString("state",
488-
mcp.Description("New state ('open' or 'closed')"),
488+
mcp.Description("New state"),
489489
mcp.Enum("open", "closed"),
490490
),
491491
mcp.WithArray("labels",

pkg/github/pullrequests.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func UpdatePullRequest(getClient GetClientFn, t translations.TranslationHelperFu
9494
mcp.Description("New description"),
9595
),
9696
mcp.WithString("state",
97-
mcp.Description("New state ('open' or 'closed')"),
97+
mcp.Description("New state"),
9898
mcp.Enum("open", "closed"),
9999
),
100100
mcp.WithString("base",
@@ -201,7 +201,8 @@ func ListPullRequests(getClient GetClientFn, t translations.TranslationHelperFun
201201
mcp.Description("Repository name"),
202202
),
203203
mcp.WithString("state",
204-
mcp.Description("Filter by state ('open', 'closed', 'all')"),
204+
mcp.Description("Filter by state"),
205+
mcp.Enum("open", "closed", "all"),
205206
),
206207
mcp.WithString("head",
207208
mcp.Description("Filter by head user/org and branch"),
@@ -210,10 +211,12 @@ func ListPullRequests(getClient GetClientFn, t translations.TranslationHelperFun
210211
mcp.Description("Filter by base branch"),
211212
),
212213
mcp.WithString("sort",
213-
mcp.Description("Sort by ('created', 'updated', 'popularity', 'long-running')"),
214+
mcp.Description("Sort by"),
215+
mcp.Enum("created", "updated", "popularity", "long-running"),
214216
),
215217
mcp.WithString("direction",
216-
mcp.Description("Sort direction ('asc', 'desc')"),
218+
mcp.Description("Sort direction"),
219+
mcp.Enum("asc", "desc"),
217220
),
218221
WithPagination(),
219222
),
@@ -313,7 +316,8 @@ func MergePullRequest(getClient GetClientFn, t translations.TranslationHelperFun
313316
mcp.Description("Extra detail for merge commit"),
314317
),
315318
mcp.WithString("merge_method",
316-
mcp.Description("Merge method ('merge', 'squash', 'rebase')"),
319+
mcp.Description("Merge method"),
320+
mcp.Enum("merge", "squash", "rebase"),
317321
),
318322
),
319323
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
@@ -671,21 +675,21 @@ func AddPullRequestReviewComment(getClient GetClientFn, t translations.Translati
671675
mcp.Description("The relative path to the file that necessitates a comment. Required unless in_reply_to is specified."),
672676
),
673677
mcp.WithString("subject_type",
674-
mcp.Description("The level at which the comment is targeted, 'line' or 'file'"),
678+
mcp.Description("The level at which the comment is targeted"),
675679
mcp.Enum("line", "file"),
676680
),
677681
mcp.WithNumber("line",
678682
mcp.Description("The line of the blob in the pull request diff that the comment applies to. For multi-line comments, the last line of the range"),
679683
),
680684
mcp.WithString("side",
681-
mcp.Description("The side of the diff to comment on. Can be LEFT or RIGHT"),
685+
mcp.Description("The side of the diff to comment on"),
682686
mcp.Enum("LEFT", "RIGHT"),
683687
),
684688
mcp.WithNumber("start_line",
685689
mcp.Description("For multi-line comments, the first line of the range that the comment applies to"),
686690
),
687691
mcp.WithString("start_side",
688-
mcp.Description("For multi-line comments, the starting side of the diff that the comment applies to. Can be LEFT or RIGHT"),
692+
mcp.Description("For multi-line comments, the starting side of the diff that the comment applies to"),
689693
mcp.Enum("LEFT", "RIGHT"),
690694
),
691695
mcp.WithNumber("in_reply_to",
@@ -893,7 +897,8 @@ func CreatePullRequestReview(getClient GetClientFn, t translations.TranslationHe
893897
),
894898
mcp.WithString("event",
895899
mcp.Required(),
896-
mcp.Description("Review action ('APPROVE', 'REQUEST_CHANGES', 'COMMENT')"),
900+
mcp.Description("Review action to perform"),
901+
mcp.Enum("APPROVE", "REQUEST_CHANGES", "COMMENT"),
897902
),
898903
mcp.WithString("commitId",
899904
mcp.Description("SHA of commit to review"),

pkg/github/repositories.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func ListCommits(getClient GetClientFn, t translations.TranslationHelperFunc) (t
9393
mcp.Description("Repository name"),
9494
),
9595
mcp.WithString("sha",
96-
mcp.Description("Branch name"),
96+
mcp.Description("SHA or Branch name"),
9797
),
9898
WithPagination(),
9999
),

pkg/github/search.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func SearchCode(getClient GetClientFn, t translations.TranslationHelperFunc) (to
7878
mcp.Description("Sort field ('indexed' only)"),
7979
),
8080
mcp.WithString("order",
81-
mcp.Description("Sort order ('asc' or 'desc')"),
81+
mcp.Description("Sort order"),
8282
mcp.Enum("asc", "desc"),
8383
),
8484
WithPagination(),
@@ -147,11 +147,11 @@ func SearchUsers(getClient GetClientFn, t translations.TranslationHelperFunc) (t
147147
mcp.Description("Search query using GitHub users search syntax"),
148148
),
149149
mcp.WithString("sort",
150-
mcp.Description("Sort field (followers, repositories, joined)"),
150+
mcp.Description("Sort field by category"),
151151
mcp.Enum("followers", "repositories", "joined"),
152152
),
153153
mcp.WithString("order",
154-
mcp.Description("Sort order ('asc' or 'desc')"),
154+
mcp.Description("Sort order"),
155155
mcp.Enum("asc", "desc"),
156156
),
157157
WithPagination(),

0 commit comments

Comments
 (0)