Skip to content

Commit 099ad57

Browse files
Update most tools with OAuth scope information
- Updated 60+ tools with required and accepted OAuth scopes - Added scopes to: gists, git, notifications, projects, code scanning, dependabot, secret scanning, security advisories, actions, discussions, issues (partial), labels, pull requests (partial), repositories (partial), search (partial) - Remaining: ~20 tools in issues, pullrequests, repositories, and search files Co-authored-by: SamMorrowDrums <[email protected]>
1 parent 669690b commit 099ad57

15 files changed

+189
-58
lines changed

pkg/github/actions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
buffer "github.com/github/github-mcp-server/pkg/buffer"
1414
ghErrors "github.com/github/github-mcp-server/pkg/errors"
1515
"github.com/github/github-mcp-server/pkg/inventory"
16+
"github.com/github/github-mcp-server/pkg/scopes"
1617
"github.com/github/github-mcp-server/pkg/translations"
1718
"github.com/github/github-mcp-server/pkg/utils"
1819
"github.com/google/go-github/v79/github"

pkg/github/code_scanning.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
ghErrors "github.com/github/github-mcp-server/pkg/errors"
1010
"github.com/github/github-mcp-server/pkg/inventory"
11+
"github.com/github/github-mcp-server/pkg/scopes"
1112
"github.com/github/github-mcp-server/pkg/translations"
1213
"github.com/github/github-mcp-server/pkg/utils"
1314
"github.com/google/go-github/v79/github"
@@ -16,7 +17,7 @@ import (
1617
)
1718

1819
func GetCodeScanningAlert(t translations.TranslationHelperFunc) inventory.ServerTool {
19-
return NewTool(
20+
return NewToolWithScopes(
2021
ToolsetMetadataCodeSecurity,
2122
mcp.Tool{
2223
Name: "get_code_scanning_alert",
@@ -44,6 +45,8 @@ func GetCodeScanningAlert(t translations.TranslationHelperFunc) inventory.Server
4445
Required: []string{"owner", "repo", "alertNumber"},
4546
},
4647
},
48+
scopes.ToStringSlice(scopes.SecurityEvents),
49+
scopes.ToStringSlice(scopes.SecurityEvents, scopes.Repo),
4750
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
4851
owner, err := RequiredParam[string](args, "owner")
4952
if err != nil {
@@ -92,7 +95,7 @@ func GetCodeScanningAlert(t translations.TranslationHelperFunc) inventory.Server
9295
}
9396

9497
func ListCodeScanningAlerts(t translations.TranslationHelperFunc) inventory.ServerTool {
95-
return NewTool(
98+
return NewToolWithScopes(
9699
ToolsetMetadataCodeSecurity,
97100
mcp.Tool{
98101
Name: "list_code_scanning_alerts",
@@ -135,6 +138,8 @@ func ListCodeScanningAlerts(t translations.TranslationHelperFunc) inventory.Serv
135138
Required: []string{"owner", "repo"},
136139
},
137140
},
141+
scopes.ToStringSlice(scopes.SecurityEvents),
142+
scopes.ToStringSlice(scopes.SecurityEvents, scopes.Repo),
138143
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
139144
owner, err := RequiredParam[string](args, "owner")
140145
if err != nil {

pkg/github/dependabot.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
ghErrors "github.com/github/github-mcp-server/pkg/errors"
1111
"github.com/github/github-mcp-server/pkg/inventory"
12+
"github.com/github/github-mcp-server/pkg/scopes"
1213
"github.com/github/github-mcp-server/pkg/translations"
1314
"github.com/github/github-mcp-server/pkg/utils"
1415
"github.com/google/go-github/v79/github"
@@ -17,7 +18,7 @@ import (
1718
)
1819

1920
func GetDependabotAlert(t translations.TranslationHelperFunc) inventory.ServerTool {
20-
return NewTool(
21+
return NewToolWithScopes(
2122
ToolsetMetadataDependabot,
2223
mcp.Tool{
2324
Name: "get_dependabot_alert",
@@ -45,6 +46,8 @@ func GetDependabotAlert(t translations.TranslationHelperFunc) inventory.ServerTo
4546
Required: []string{"owner", "repo", "alertNumber"},
4647
},
4748
},
49+
scopes.ToStringSlice(scopes.SecurityEvents),
50+
scopes.ToStringSlice(scopes.SecurityEvents, scopes.Repo),
4851
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
4952
owner, err := RequiredParam[string](args, "owner")
5053
if err != nil {
@@ -93,7 +96,7 @@ func GetDependabotAlert(t translations.TranslationHelperFunc) inventory.ServerTo
9396
}
9497

9598
func ListDependabotAlerts(t translations.TranslationHelperFunc) inventory.ServerTool {
96-
return NewTool(
99+
return NewToolWithScopes(
97100
ToolsetMetadataDependabot,
98101
mcp.Tool{
99102
Name: "list_dependabot_alerts",
@@ -128,6 +131,8 @@ func ListDependabotAlerts(t translations.TranslationHelperFunc) inventory.Server
128131
Required: []string{"owner", "repo"},
129132
},
130133
},
134+
scopes.ToStringSlice(scopes.SecurityEvents),
135+
scopes.ToStringSlice(scopes.SecurityEvents, scopes.Repo),
131136
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
132137
owner, err := RequiredParam[string](args, "owner")
133138
if err != nil {

pkg/github/discussions.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77

88
"github.com/github/github-mcp-server/pkg/inventory"
9+
"github.com/github/github-mcp-server/pkg/scopes"
910
"github.com/github/github-mcp-server/pkg/translations"
1011
"github.com/github/github-mcp-server/pkg/utils"
1112
"github.com/go-viper/mapstructure/v2"
@@ -123,7 +124,7 @@ func getQueryType(useOrdering bool, categoryID *githubv4.ID) any {
123124
}
124125

125126
func ListDiscussions(t translations.TranslationHelperFunc) inventory.ServerTool {
126-
return NewTool(
127+
return NewToolWithScopes(
127128
ToolsetMetadataDiscussions,
128129
mcp.Tool{
129130
Name: "list_discussions",
@@ -161,6 +162,8 @@ func ListDiscussions(t translations.TranslationHelperFunc) inventory.ServerTool
161162
Required: []string{"owner"},
162163
}),
163164
},
165+
scopes.ToStringSlice(scopes.Repo),
166+
scopes.ToStringSlice(scopes.Repo),
164167
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
165168
owner, err := RequiredParam[string](args, "owner")
166169
if err != nil {
@@ -275,7 +278,7 @@ func ListDiscussions(t translations.TranslationHelperFunc) inventory.ServerTool
275278
}
276279

277280
func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool {
278-
return NewTool(
281+
return NewToolWithScopes(
279282
ToolsetMetadataDiscussions,
280283
mcp.Tool{
281284
Name: "get_discussion",
@@ -303,6 +306,8 @@ func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool {
303306
Required: []string{"owner", "repo", "discussionNumber"},
304307
},
305308
},
309+
scopes.ToStringSlice(scopes.Repo),
310+
scopes.ToStringSlice(scopes.Repo),
306311
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
307312
// Decode params
308313
var params struct {
@@ -378,7 +383,7 @@ func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool {
378383
}
379384

380385
func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.ServerTool {
381-
return NewTool(
386+
return NewToolWithScopes(
382387
ToolsetMetadataDiscussions,
383388
mcp.Tool{
384389
Name: "get_discussion_comments",
@@ -406,6 +411,8 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve
406411
Required: []string{"owner", "repo", "discussionNumber"},
407412
}),
408413
},
414+
scopes.ToStringSlice(scopes.Repo),
415+
scopes.ToStringSlice(scopes.Repo),
409416
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
410417
// Decode params
411418
var params struct {
@@ -504,7 +511,7 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve
504511
}
505512

506513
func ListDiscussionCategories(t translations.TranslationHelperFunc) inventory.ServerTool {
507-
return NewTool(
514+
return NewToolWithScopes(
508515
ToolsetMetadataDiscussions,
509516
mcp.Tool{
510517
Name: "list_discussion_categories",
@@ -528,6 +535,8 @@ func ListDiscussionCategories(t translations.TranslationHelperFunc) inventory.Se
528535
Required: []string{"owner"},
529536
},
530537
},
538+
scopes.ToStringSlice(scopes.Repo),
539+
scopes.ToStringSlice(scopes.Repo),
531540
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
532541
owner, err := RequiredParam[string](args, "owner")
533542
if err != nil {

pkg/github/gists.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
ghErrors "github.com/github/github-mcp-server/pkg/errors"
1111
"github.com/github/github-mcp-server/pkg/inventory"
12+
"github.com/github/github-mcp-server/pkg/scopes"
1213
"github.com/github/github-mcp-server/pkg/translations"
1314
"github.com/github/github-mcp-server/pkg/utils"
1415
"github.com/google/go-github/v79/github"
@@ -18,7 +19,7 @@ import (
1819

1920
// ListGists creates a tool to list gists for a user
2021
func ListGists(t translations.TranslationHelperFunc) inventory.ServerTool {
21-
return NewTool(
22+
return NewToolWithScopes(
2223
ToolsetMetadataGists,
2324
mcp.Tool{
2425
Name: "list_gists",
@@ -41,6 +42,8 @@ func ListGists(t translations.TranslationHelperFunc) inventory.ServerTool {
4142
},
4243
}),
4344
},
45+
nil, // no required scopes
46+
nil, // no accepted scopes
4447
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
4548
username, err := OptionalParam[string](args, "username")
4649
if err != nil {
@@ -104,7 +107,7 @@ func ListGists(t translations.TranslationHelperFunc) inventory.ServerTool {
104107

105108
// GetGist creates a tool to get the content of a gist
106109
func GetGist(t translations.TranslationHelperFunc) inventory.ServerTool {
107-
return NewTool(
110+
return NewToolWithScopes(
108111
ToolsetMetadataGists,
109112
mcp.Tool{
110113
Name: "get_gist",
@@ -124,6 +127,8 @@ func GetGist(t translations.TranslationHelperFunc) inventory.ServerTool {
124127
Required: []string{"gist_id"},
125128
},
126129
},
130+
nil, // no required scopes
131+
nil, // no accepted scopes
127132
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
128133
gistID, err := RequiredParam[string](args, "gist_id")
129134
if err != nil {
@@ -161,7 +166,7 @@ func GetGist(t translations.TranslationHelperFunc) inventory.ServerTool {
161166

162167
// CreateGist creates a tool to create a new gist
163168
func CreateGist(t translations.TranslationHelperFunc) inventory.ServerTool {
164-
return NewTool(
169+
return NewToolWithScopes(
165170
ToolsetMetadataGists,
166171
mcp.Tool{
167172
Name: "create_gist",
@@ -194,6 +199,8 @@ func CreateGist(t translations.TranslationHelperFunc) inventory.ServerTool {
194199
Required: []string{"filename", "content"},
195200
},
196201
},
202+
scopes.ToStringSlice(scopes.Gist),
203+
scopes.ToStringSlice(scopes.Gist),
197204
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
198205
description, err := OptionalParam[string](args, "description")
199206
if err != nil {
@@ -263,7 +270,7 @@ func CreateGist(t translations.TranslationHelperFunc) inventory.ServerTool {
263270

264271
// UpdateGist creates a tool to edit an existing gist
265272
func UpdateGist(t translations.TranslationHelperFunc) inventory.ServerTool {
266-
return NewTool(
273+
return NewToolWithScopes(
267274
ToolsetMetadataGists,
268275
mcp.Tool{
269276
Name: "update_gist",
@@ -295,6 +302,8 @@ func UpdateGist(t translations.TranslationHelperFunc) inventory.ServerTool {
295302
Required: []string{"gist_id", "filename", "content"},
296303
},
297304
},
305+
scopes.ToStringSlice(scopes.Gist),
306+
scopes.ToStringSlice(scopes.Gist),
298307
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
299308
gistID, err := RequiredParam[string](args, "gist_id")
300309
if err != nil {

pkg/github/git.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
ghErrors "github.com/github/github-mcp-server/pkg/errors"
1010
"github.com/github/github-mcp-server/pkg/inventory"
11+
"github.com/github/github-mcp-server/pkg/scopes"
1112
"github.com/github/github-mcp-server/pkg/translations"
1213
"github.com/github/github-mcp-server/pkg/utils"
1314
"github.com/google/go-github/v79/github"
@@ -39,7 +40,7 @@ type TreeResponse struct {
3940

4041
// GetRepositoryTree creates a tool to get the tree structure of a GitHub repository.
4142
func GetRepositoryTree(t translations.TranslationHelperFunc) inventory.ServerTool {
42-
return NewTool(
43+
return NewToolWithScopes(
4344
ToolsetMetadataGit,
4445
mcp.Tool{
4546
Name: "get_repository_tree",
@@ -76,6 +77,8 @@ func GetRepositoryTree(t translations.TranslationHelperFunc) inventory.ServerToo
7677
Required: []string{"owner", "repo"},
7778
},
7879
},
80+
scopes.ToStringSlice(scopes.Repo),
81+
scopes.ToStringSlice(scopes.Repo),
7982
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
8083
owner, err := RequiredParam[string](args, "owner")
8184
if err != nil {

pkg/github/issues.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
ghErrors "github.com/github/github-mcp-server/pkg/errors"
1313
"github.com/github/github-mcp-server/pkg/inventory"
14+
"github.com/github/github-mcp-server/pkg/scopes"
1415
"github.com/github/github-mcp-server/pkg/lockdown"
1516
"github.com/github/github-mcp-server/pkg/octicons"
1617
"github.com/github/github-mcp-server/pkg/sanitize"
@@ -545,7 +546,7 @@ func GetIssueLabels(ctx context.Context, client *githubv4.Client, owner string,
545546

546547
// ListIssueTypes creates a tool to list defined issue types for an organization. This can be used to understand supported issue type values for creating or updating issues.
547548
func ListIssueTypes(t translations.TranslationHelperFunc) inventory.ServerTool {
548-
return NewTool(
549+
return NewToolWithScopes(
549550
ToolsetMetadataIssues,
550551
mcp.Tool{
551552
Name: "list_issue_types",
@@ -565,6 +566,8 @@ func ListIssueTypes(t translations.TranslationHelperFunc) inventory.ServerTool {
565566
Required: []string{"owner"},
566567
},
567568
},
569+
scopes.ToStringSlice(scopes.ReadOrg),
570+
scopes.ToStringSlice(scopes.ReadOrg, scopes.WriteOrg, scopes.AdminOrg),
568571
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
569572
owner, err := RequiredParam[string](args, "owner")
570573
if err != nil {
@@ -600,7 +603,7 @@ func ListIssueTypes(t translations.TranslationHelperFunc) inventory.ServerTool {
600603

601604
// AddIssueComment creates a tool to add a comment to an issue.
602605
func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool {
603-
return NewTool(
606+
return NewToolWithScopes(
604607
ToolsetMetadataIssues,
605608
mcp.Tool{
606609
Name: "add_issue_comment",
@@ -632,6 +635,8 @@ func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool
632635
Required: []string{"owner", "repo", "issue_number", "body"},
633636
},
634637
},
638+
scopes.ToStringSlice(scopes.Repo),
639+
scopes.ToStringSlice(scopes.Repo),
635640
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
636641
owner, err := RequiredParam[string](args, "owner")
637642
if err != nil {
@@ -683,7 +688,7 @@ func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool
683688

684689
// SubIssueWrite creates a tool to add a sub-issue to a parent issue.
685690
func SubIssueWrite(t translations.TranslationHelperFunc) inventory.ServerTool {
686-
return NewTool(
691+
return NewToolWithScopes(
687692
ToolsetMetadataIssues,
688693
mcp.Tool{
689694
Name: "sub_issue_write",
@@ -736,6 +741,8 @@ Options are:
736741
Required: []string{"method", "owner", "repo", "issue_number", "sub_issue_id"},
737742
},
738743
},
744+
scopes.ToStringSlice(scopes.Repo),
745+
scopes.ToStringSlice(scopes.Repo),
739746
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
740747
method, err := RequiredParam[string](args, "method")
741748
if err != nil {
@@ -971,7 +978,7 @@ func SearchIssues(t translations.TranslationHelperFunc) inventory.ServerTool {
971978

972979
// IssueWrite creates a tool to create a new or update an existing issue in a GitHub repository.
973980
func IssueWrite(t translations.TranslationHelperFunc) inventory.ServerTool {
974-
return NewTool(
981+
return NewToolWithScopes(
975982
ToolsetMetadataIssues,
976983
mcp.Tool{
977984
Name: "issue_write",
@@ -1052,6 +1059,8 @@ Options are:
10521059
Required: []string{"method", "owner", "repo"},
10531060
},
10541061
},
1062+
scopes.ToStringSlice(scopes.Repo),
1063+
scopes.ToStringSlice(scopes.Repo),
10551064
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
10561065
method, err := RequiredParam[string](args, "method")
10571066
if err != nil {

0 commit comments

Comments
 (0)