Skip to content

Commit 739f39a

Browse files
committed
error out in the builder if there are unrecognized tools
1 parent 9bf817a commit 739f39a

File tree

102 files changed

+756
-752
lines changed

Some content is hidden

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

102 files changed

+756
-752
lines changed

cmd/github-mcp-server/generate_docs.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ func generateReadmeDocs(readmePath string) error {
5151
t, _ := translations.TranslationHelper()
5252

5353
// (not available to regular users) while including tools with FeatureFlagDisable.
54-
r := github.NewInventory(t).WithToolsets([]string{"all"}).Build()
54+
// Build() can only fail if WithTools specifies invalid tools - not used here
55+
r, _ := github.NewInventory(t).WithToolsets([]string{"all"}).Build()
5556

5657
// Generate toolsets documentation
5758
toolsetsDoc := generateToolsetsDoc(r)
@@ -341,7 +342,8 @@ func generateRemoteToolsetsDoc() string {
341342
t, _ := translations.TranslationHelper()
342343

343344
// Build inventory - stateless
344-
r := github.NewInventory(t).Build()
345+
// Build() can only fail if WithTools specifies invalid tools - not used here
346+
r, _ := github.NewInventory(t).Build()
345347

346348
// Generate table header (icon is combined with Name column)
347349
buf.WriteString("| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) |\n")

cmd/github-mcp-server/list_scopes.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ func runListScopes() error {
121121
inventoryBuilder = inventoryBuilder.WithTools(enabledTools)
122122
}
123123

124-
inv := inventoryBuilder.Build()
124+
inv, err := inventoryBuilder.Build()
125+
if err != nil {
126+
return fmt.Errorf("failed to build inventory: %w", err)
127+
}
125128

126129
// Collect all tools and their scopes
127130
output := collectToolScopes(inv, readOnly)

internal/ghmcp/server.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,15 @@ func NewMCPServer(cfg MCPServerConfig) (*mcp.Server, error) {
229229
inventoryBuilder = inventoryBuilder.WithFilter(github.CreateToolScopeFilter(cfg.TokenScopes))
230230
}
231231

232-
inventory := inventoryBuilder.Build()
232+
inventory, err := inventoryBuilder.Build()
233+
if err != nil {
234+
return nil, fmt.Errorf("failed to build inventory: %w", err)
235+
}
233236

234237
if unrecognized := inventory.UnrecognizedToolsets(); len(unrecognized) > 0 {
235238
fmt.Fprintf(os.Stderr, "Warning: unrecognized toolsets ignored: %s\n", strings.Join(unrecognized, ", "))
236239
}
237240

238-
// Check for unrecognized tools and error out (unlike toolsets which just warn)
239-
if unrecognized := inventory.UnrecognizedTools(); len(unrecognized) > 0 {
240-
return nil, fmt.Errorf("unrecognized tools: %s", strings.Join(unrecognized, ", "))
241-
}
242-
243241
// Register GitHub tools/resources/prompts from the inventory.
244242
// In dynamic mode with no explicit toolsets, this is a no-op since enabledToolsets
245243
// is empty - users enable toolsets at runtime via the dynamic tools below (but can

pkg/github/__toolsnaps__/actions_get.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
"description": "Get details about specific GitHub Actions resources.\nUse this tool to get details about individual workflows, workflow runs, jobs, and artifacts by their unique IDs.\n",
77
"inputSchema": {
88
"type": "object",
9-
"required": [
10-
"method",
11-
"owner",
12-
"repo",
13-
"resource_id"
14-
],
159
"properties": {
1610
"method": {
1711
"type": "string",
@@ -37,7 +31,13 @@
3731
"type": "string",
3832
"description": "The unique identifier of the resource. This will vary based on the \"method\" provided, so ensure you provide the correct ID:\n- Provide a workflow ID or workflow file name (e.g. ci.yaml) for 'get_workflow' method.\n- Provide a workflow run ID for 'get_workflow_run', 'get_workflow_run_usage', and 'get_workflow_run_logs_url' methods.\n- Provide an artifact ID for 'download_workflow_run_artifact' method.\n- Provide a job ID for 'get_workflow_job' method.\n"
3933
}
40-
}
34+
},
35+
"required": [
36+
"method",
37+
"owner",
38+
"repo",
39+
"resource_id"
40+
]
4141
},
4242
"name": "actions_get"
4343
}

pkg/github/__toolsnaps__/actions_run_trigger.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
"description": "Trigger GitHub Actions workflow operations, including running, re-running, cancelling workflow runs, and deleting workflow run logs.",
77
"inputSchema": {
88
"type": "object",
9-
"required": [
10-
"method",
11-
"owner",
12-
"repo"
13-
],
149
"properties": {
1510
"inputs": {
1611
"type": "object",
@@ -47,7 +42,12 @@
4742
"type": "string",
4843
"description": "The workflow ID (numeric) or workflow file name (e.g., main.yml, ci.yaml). Required for 'run_workflow' method."
4944
}
50-
}
45+
},
46+
"required": [
47+
"method",
48+
"owner",
49+
"repo"
50+
]
5151
},
5252
"name": "actions_run_trigger"
5353
}

pkg/github/__toolsnaps__/add_comment_to_pending_review.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
"description": "Add review comment to the requester's latest pending pull request review. A pending review needs to already exist to call this (check with the user if not sure).",
66
"inputSchema": {
77
"type": "object",
8-
"required": [
9-
"owner",
10-
"repo",
11-
"pullNumber",
12-
"path",
13-
"body",
14-
"subjectType"
15-
],
168
"properties": {
179
"body": {
1810
"type": "string",
@@ -66,7 +58,15 @@
6658
"LINE"
6759
]
6860
}
69-
}
61+
},
62+
"required": [
63+
"owner",
64+
"repo",
65+
"pullNumber",
66+
"path",
67+
"body",
68+
"subjectType"
69+
]
7070
},
7171
"name": "add_comment_to_pending_review"
7272
}

pkg/github/__toolsnaps__/add_issue_comment.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
"description": "Add a comment to a specific issue in a GitHub repository. Use this tool to add comments to pull requests as well (in this case pass pull request number as issue_number), but only if user is not asking specifically to add review comments.",
66
"inputSchema": {
77
"type": "object",
8-
"required": [
9-
"owner",
10-
"repo",
11-
"issue_number",
12-
"body"
13-
],
148
"properties": {
159
"body": {
1610
"type": "string",
@@ -28,7 +22,13 @@
2822
"type": "string",
2923
"description": "Repository name"
3024
}
31-
}
25+
},
26+
"required": [
27+
"owner",
28+
"repo",
29+
"issue_number",
30+
"body"
31+
]
3232
},
3333
"name": "add_issue_comment"
3434
}

pkg/github/__toolsnaps__/add_project_item.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
"description": "Add a specific Project item for a user or org",
66
"inputSchema": {
77
"type": "object",
8-
"required": [
9-
"owner_type",
10-
"owner",
11-
"project_number",
12-
"item_type",
13-
"item_id"
14-
],
158
"properties": {
169
"item_id": {
1710
"type": "number",
@@ -41,7 +34,14 @@
4134
"type": "number",
4235
"description": "The project's number."
4336
}
44-
}
37+
},
38+
"required": [
39+
"owner_type",
40+
"owner",
41+
"project_number",
42+
"item_type",
43+
"item_id"
44+
]
4545
},
4646
"name": "add_project_item"
4747
}

pkg/github/__toolsnaps__/cancel_workflow_run.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
"description": "Cancel a workflow run",
66
"inputSchema": {
77
"type": "object",
8-
"required": [
9-
"owner",
10-
"repo",
11-
"run_id"
12-
],
138
"properties": {
149
"owner": {
1510
"type": "string",
@@ -23,7 +18,12 @@
2318
"type": "number",
2419
"description": "The unique identifier of the workflow run"
2520
}
26-
}
21+
},
22+
"required": [
23+
"owner",
24+
"repo",
25+
"run_id"
26+
]
2727
},
2828
"name": "cancel_workflow_run"
2929
}

pkg/github/__toolsnaps__/create_branch.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
"description": "Create a new branch in a GitHub repository",
66
"inputSchema": {
77
"type": "object",
8-
"required": [
9-
"owner",
10-
"repo",
11-
"branch"
12-
],
138
"properties": {
149
"branch": {
1510
"type": "string",
@@ -27,7 +22,12 @@
2722
"type": "string",
2823
"description": "Repository name"
2924
}
30-
}
25+
},
26+
"required": [
27+
"owner",
28+
"repo",
29+
"branch"
30+
]
3131
},
3232
"name": "create_branch"
3333
}

0 commit comments

Comments
 (0)