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

Commit 66fabb7

Browse files
tonytrgCopilot
andauthored
Adding default toolset as configuration (#1229)
* add toolset default to make configuration easier * fix readme * adding transformer to cleanly handle special toolsets * cleaning code * fixing cli message * remove duplicated test * Update internal/ghmcp/server.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update internal/ghmcp/server_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * adding error message for invalid toolsets * fix merge conflict * add better formatting --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7b4b292 commit 66fabb7

File tree

5 files changed

+390
-23
lines changed

5 files changed

+390
-23
lines changed

‎README.md‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,12 @@ Alternatively, to manually configure VS Code, choose the appropriate JSON block
8787
8888
### Configuration
8989

90-
#### Default toolset configuration
91-
92-
The default configuration is:
93-
- context
94-
- repos
95-
- issues
96-
- pull_requests
97-
- users
90+
#### Toolset configuration
9891

9992
See [Remote Server Documentation](docs/remote-server.md) for full details on remote server configuration, toolsets, headers, and advanced usage. This file provides comprehensive instructions and examples for connecting, customizing, and installing the remote GitHub MCP Server in VS Code and other MCP hosts.
10093

94+
When no toolsets are specified, [default toolsets](#default-toolset) are used.
95+
10196
#### Enterprise Cloud with data residency (ghe.com)
10297

10398
GitHub Enterprise Cloud can also make use of the remote server.
@@ -329,7 +324,7 @@ The GitHub MCP Server supports enabling or disabling specific groups of function
329324

330325
_Toolsets are not limited to Tools. Relevant MCP Resources and Prompts are also included where applicable._
331326

332-
The Local GitHub MCP Server follows the same [default toolset configuration](#default-toolset-configuration) as the remote version.
327+
When no toolsets are specified, [default toolsets](#default-toolset) are used.
333328

334329
#### Specifying Toolsets
335330

@@ -359,7 +354,9 @@ docker run -i --rm \
359354
ghcr.io/github/github-mcp-server
360355
```
361356

362-
### The "all" Toolset
357+
### Special toolsets
358+
359+
#### "all" toolset
363360

364361
The special toolset `all` can be provided to enable all available toolsets regardless of any other configuration:
365362

@@ -373,6 +370,22 @@ Or using the environment variable:
373370
GITHUB_TOOLSETS="all" ./github-mcp-server
374371
```
375372

373+
#### "default" toolset
374+
The default toolset `default` is the configuration that gets passed to the server if no toolsets are specified.
375+
376+
The default configuration is:
377+
- context
378+
- repos
379+
- issues
380+
- pull_requests
381+
- users
382+
383+
To keep the default configuration and add additional toolsets:
384+
385+
```bash
386+
GITHUB_TOOLSETS="default,stargazers" ./github-mcp-server
387+
```
388+
376389
### Available Toolsets
377390

378391
The following sets of tools are available:

‎cmd/github-mcp-server/main.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ var (
4545
return fmt.Errorf("failed to unmarshal toolsets: %w", err)
4646
}
4747

48+
// No passed toolsets configuration means we enable the default toolset
4849
if len(enabledToolsets) == 0 {
49-
enabledToolsets = github.GetDefaultToolsetIDs()
50+
enabledToolsets = []string{github.ToolsetMetadataDefault.ID}
5051
}
5152

5253
stdioServerConfig := ghmcp.StdioServerConfig{

‎internal/ghmcp/server.go‎

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,10 @@ func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {
106106
},
107107
}
108108

109-
enabledToolsets := cfg.EnabledToolsets
110-
if cfg.DynamicToolsets {
111-
// filter "all" from the enabled toolsets
112-
enabledToolsets = make([]string, 0, len(cfg.EnabledToolsets))
113-
for _, toolset := range cfg.EnabledToolsets {
114-
if toolset != "all" {
115-
enabledToolsets = append(enabledToolsets, toolset)
116-
}
117-
}
109+
enabledToolsets, invalidToolsets := cleanToolsets(cfg.EnabledToolsets, cfg.DynamicToolsets)
110+
111+
if len(invalidToolsets) > 0 {
112+
fmt.Fprintf(os.Stderr, "Invalid toolsets ignored: %s\n", strings.Join(invalidToolsets, ", "))
118113
}
119114

120115
// Generate instructions based on enabled toolsets
@@ -470,3 +465,57 @@ func (t *bearerAuthTransport) RoundTrip(req *http.Request) (*http.Response, erro
470465
req.Header.Set("Authorization", "Bearer "+t.token)
471466
return t.transport.RoundTrip(req)
472467
}
468+
469+
// cleanToolsets cleans and handles special toolset keywords:
470+
// - Duplicates are removed from the result
471+
// - Removes whitespaces
472+
// - Validates toolset names and returns invalid ones separately
473+
// - "all": Returns ["all"] immediately, ignoring all other toolsets
474+
// - when dynamicToolsets is true, filters out "all" from the enabled toolsets
475+
// - "default": Replaces with the actual default toolset IDs from GetDefaultToolsetIDs()
476+
// Returns: (validToolsets, invalidToolsets)
477+
func cleanToolsets(enabledToolsets []string, dynamicToolsets bool) ([]string, []string) {
478+
seen := make(map[string]bool)
479+
result := make([]string, 0, len(enabledToolsets))
480+
invalid := make([]string, 0)
481+
validIDs := github.GetValidToolsetIDs()
482+
483+
// Add non-default toolsets, removing duplicates and trimming whitespace
484+
for _, toolset := range enabledToolsets {
485+
trimmed := strings.TrimSpace(toolset)
486+
if trimmed == "" {
487+
continue
488+
}
489+
if !seen[trimmed] {
490+
seen[trimmed] = true
491+
if trimmed != github.ToolsetMetadataDefault.ID && trimmed != github.ToolsetMetadataAll.ID {
492+
// Validate the toolset name
493+
if validIDs[trimmed] {
494+
result = append(result, trimmed)
495+
} else {
496+
invalid = append(invalid, trimmed)
497+
}
498+
}
499+
}
500+
}
501+
502+
hasDefault := seen[github.ToolsetMetadataDefault.ID]
503+
hasAll := seen[github.ToolsetMetadataAll.ID]
504+
505+
// Handle "all" keyword - return early if not in dynamic mode
506+
if hasAll && !dynamicToolsets {
507+
return []string{github.ToolsetMetadataAll.ID}, invalid
508+
}
509+
510+
// Expand "default" keyword to actual default toolsets
511+
if hasDefault {
512+
for _, defaultToolset := range github.GetDefaultToolsetIDs() {
513+
if !seen[defaultToolset] {
514+
result = append(result, defaultToolset)
515+
seen[defaultToolset] = true
516+
}
517+
}
518+
}
519+
520+
return result, invalid
521+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /