Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,12 @@ Alternatively, to manually configure VS Code, choose the appropriate JSON block

### Configuration

#### Default toolset configuration

The default configuration is:
- context
- repos
- issues
- pull_requests
- users
#### Toolset configuration

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.

When no toolsets are specified, [default toolsets](#default-toolset) are used.

#### Enterprise Cloud with data residency (ghe.com)

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

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

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

#### Specifying Toolsets

Expand Down Expand Up @@ -359,7 +354,9 @@ docker run -i --rm \
ghcr.io/github/github-mcp-server
```

### The "all" Toolset
### Special toolsets

#### "all" toolset

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

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

#### "default" toolset
The default toolset `default` is the configuration that gets passed to the server if no toolsets are specified.

The default configuration is:
- context
- repos
- issues
- pull_requests
- users

To keep the default configuration and add additional toolsets:

```bash
GITHUB_TOOLSETS="default,stargazers" ./github-mcp-server
```

### Available Toolsets

The following sets of tools are available:
Expand Down
3 changes: 2 additions & 1 deletion cmd/github-mcp-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ var (
return fmt.Errorf("failed to unmarshal toolsets: %w", err)
}

// No passed toolsets configuration means we enable the default toolset
if len(enabledToolsets) == 0 {
enabledToolsets = github.GetDefaultToolsetIDs()
enabledToolsets = []string{github.ToolsetMetadataDefault.ID}
}

stdioServerConfig := ghmcp.StdioServerConfig{
Expand Down
67 changes: 58 additions & 9 deletions internal/ghmcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,10 @@ func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {
},
}

enabledToolsets := cfg.EnabledToolsets
if cfg.DynamicToolsets {
// filter "all" from the enabled toolsets
enabledToolsets = make([]string, 0, len(cfg.EnabledToolsets))
for _, toolset := range cfg.EnabledToolsets {
if toolset != "all" {
enabledToolsets = append(enabledToolsets, toolset)
}
}
enabledToolsets, invalidToolsets := cleanToolsets(cfg.EnabledToolsets, cfg.DynamicToolsets)

if len(invalidToolsets) > 0 {
fmt.Fprintf(os.Stderr, "Invalid toolsets ignored: %s\n", strings.Join(invalidToolsets, ", "))
}

// Generate instructions based on enabled toolsets
Expand Down Expand Up @@ -470,3 +465,57 @@ func (t *bearerAuthTransport) RoundTrip(req *http.Request) (*http.Response, erro
req.Header.Set("Authorization", "Bearer "+t.token)
return t.transport.RoundTrip(req)
}

// cleanToolsets cleans and handles special toolset keywords:
// - Duplicates are removed from the result
// - Removes whitespaces
// - Validates toolset names and returns invalid ones separately
// - "all": Returns ["all"] immediately, ignoring all other toolsets
// - when dynamicToolsets is true, filters out "all" from the enabled toolsets
// - "default": Replaces with the actual default toolset IDs from GetDefaultToolsetIDs()
// Returns: (validToolsets, invalidToolsets)
func cleanToolsets(enabledToolsets []string, dynamicToolsets bool) ([]string, []string) {
seen := make(map[string]bool)
result := make([]string, 0, len(enabledToolsets))
invalid := make([]string, 0)
validIDs := github.GetValidToolsetIDs()

// Add non-default toolsets, removing duplicates and trimming whitespace
for _, toolset := range enabledToolsets {
trimmed := strings.TrimSpace(toolset)
if trimmed == "" {
continue
}
if !seen[trimmed] {
seen[trimmed] = true
if trimmed != github.ToolsetMetadataDefault.ID && trimmed != github.ToolsetMetadataAll.ID {
// Validate the toolset name
if validIDs[trimmed] {
result = append(result, trimmed)
} else {
invalid = append(invalid, trimmed)
}
}
}
}

hasDefault := seen[github.ToolsetMetadataDefault.ID]
hasAll := seen[github.ToolsetMetadataAll.ID]

// Handle "all" keyword - return early if not in dynamic mode
if hasAll && !dynamicToolsets {
return []string{github.ToolsetMetadataAll.ID}, invalid
}

// Expand "default" keyword to actual default toolsets
if hasDefault {
for _, defaultToolset := range github.GetDefaultToolsetIDs() {
if !seen[defaultToolset] {
result = append(result, defaultToolset)
seen[defaultToolset] = true
}
}
}

return result, invalid
}
Loading
Loading