Skip to content

Commit 887f33d

Browse files
feat: Add OAuth scopes to tool metadata
- Add pkg/scopes package with OAuth scope constants and utilities - Add scopes to all ~90 tool definitions using mcp.Tool.Meta field - Update generate_docs.go to include scopes in README output - Add comprehensive test coverage for scopes package - Update all toolsnaps to include _meta.requiredOAuthScopes Scope assignments follow GitHub OAuth app documentation: - repo: Most repository operations (private repos) - public_repo: Star/unstar operations - notifications: Notification operations - gist: Gist write operations - security_events: Code scanning, dependabot, secret scanning - project/read:project: Project operations - read:org: Organization/team read operations - No scope: Public read operations (get_me, list_gists)
1 parent 609e6f6 commit 887f33d

File tree

113 files changed

+1208
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1208
-95
lines changed

README.md

Lines changed: 94 additions & 94 deletions
Large diffs are not rendered by default.

cmd/github-mcp-server/generate_docs.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/github/github-mcp-server/pkg/github"
1313
"github.com/github/github-mcp-server/pkg/lockdown"
1414
"github.com/github/github-mcp-server/pkg/raw"
15+
"github.com/github/github-mcp-server/pkg/scopes"
1516
"github.com/github/github-mcp-server/pkg/toolsets"
1617
"github.com/github/github-mcp-server/pkg/translations"
1718
gogithub "github.com/google/go-github/v79/github"
@@ -224,7 +225,20 @@ func generateToolDoc(tool mcp.Tool) string {
224225
var lines []string
225226

226227
// Tool name only (using annotation name instead of verbose description)
227-
lines = append(lines, fmt.Sprintf("- **%s** - %s", tool.Name, tool.Annotations.Title))
228+
toolLine := fmt.Sprintf("- **%s** - %s", tool.Name, tool.Annotations.Title)
229+
230+
// Add required scopes if present
231+
if tool.Meta != nil {
232+
toolScopes := scopes.GetScopesFromMeta(tool.Meta)
233+
if len(toolScopes) > 0 {
234+
scopeStrs := make([]string, len(toolScopes))
235+
for i, s := range toolScopes {
236+
scopeStrs[i] = fmt.Sprintf("`%s`", s.String())
237+
}
238+
toolLine += fmt.Sprintf(" (scopes: %s)", strings.Join(scopeStrs, ", "))
239+
}
240+
}
241+
lines = append(lines, toolLine)
228242

229243
// Parameters
230244
if tool.InputSchema == nil {

pkg/github/__toolsnaps__/add_comment_to_pending_review.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"_meta": {
3+
"requiredOAuthScopes": [
4+
"repo"
5+
]
6+
},
27
"annotations": {
38
"title": "Add review comment to the requester's latest pending pull request review"
49
},

pkg/github/__toolsnaps__/add_issue_comment.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"_meta": {
3+
"requiredOAuthScopes": [
4+
"repo"
5+
]
6+
},
27
"annotations": {
38
"title": "Add comment to issue"
49
},

pkg/github/__toolsnaps__/add_project_item.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"_meta": {
3+
"requiredOAuthScopes": [
4+
"project"
5+
]
6+
},
27
"annotations": {
38
"title": "Add project item"
49
},

pkg/github/__toolsnaps__/assign_copilot_to_issue.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"_meta": {
3+
"requiredOAuthScopes": [
4+
"repo"
5+
]
6+
},
27
"annotations": {
38
"idempotentHint": true,
49
"title": "Assign Copilot to issue"

pkg/github/__toolsnaps__/cancel_workflow_run.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"_meta": {
3+
"requiredOAuthScopes": [
4+
"repo"
5+
]
6+
},
27
"annotations": {
38
"title": "Cancel workflow run"
49
},

pkg/github/__toolsnaps__/create_branch.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"_meta": {
3+
"requiredOAuthScopes": [
4+
"repo"
5+
]
6+
},
27
"annotations": {
38
"title": "Create branch"
49
},

pkg/github/__toolsnaps__/create_gist.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"_meta": {
3+
"requiredOAuthScopes": [
4+
"gist"
5+
]
6+
},
27
"annotations": {
38
"title": "Create Gist"
49
},

pkg/github/__toolsnaps__/create_or_update_file.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"_meta": {
3+
"requiredOAuthScopes": [
4+
"repo"
5+
]
6+
},
27
"annotations": {
38
"title": "Create or update file"
49
},

0 commit comments

Comments
 (0)