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
53 changes: 41 additions & 12 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,9 +370,25 @@ 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 (all are on by default):
The following sets of tools are available:

<!-- START AUTOMATED TOOLSETS -->
| Toolset | Description |
Expand All @@ -400,6 +413,14 @@ The following sets of tools are available (all are on by default):
| `users` | GitHub User related tools |
<!-- END AUTOMATED TOOLSETS -->

### Additional Toolsets in Remote Github MCP Server

| Toolset | Description |
| ----------------------- | ------------------------------------------------------------- |
| `copilot` | Copilot related tools (e.g. Copilot Coding Agent) |
| `copilot_spaces` | Copilot Spaces related tools |
| `github_support_docs_search` | Search docs to answer GitHub product and support questions |

## Tools

<!-- START AUTOMATED TOOLS -->
Expand Down Expand Up @@ -1167,7 +1188,7 @@ Possible options:

<details>

<summary>Copilot coding agent</summary>
<summary>Copilot</summary>

- **create_pull_request_with_copilot** - Perform task with GitHub Copilot coding agent
- `owner`: Repository owner. You can guess the owner, but confirm it with the user before proceeding. (string, required)
Expand All @@ -1189,6 +1210,14 @@ Possible options:
- **list_copilot_spaces** - List Copilot Spaces
</details>

<details>

<summary>GitHub Support Docs Search</summary>

- **github_support_docs_search** - Retrieve documentation relevant to answer GitHub product and support questions. Support topics include: GitHub Actions Workflows, Authentication, GitHub Support Inquiries, Pull Request Practices, Repository Maintenance, GitHub Pages, GitHub Packages, GitHub Discussions, Copilot Spaces
- `query`: Input from the user about the question they need answered. This is the latest raw unedited user message. You should ALWAYS leave the user message as it is, you should never modify it. (string, required)
</details>

## Dynamic Tool Discovery

**Note**: This feature is currently in beta and may not be available in all environments. Please test it out and let us know if you encounter any issues.
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
5 changes: 4 additions & 1 deletion docs/installation-guides/install-gemini-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ The simplest way is to use GitHub's hosted MCP server:
"mcpServers": {
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/",
"trust": true,
"headers": {
"Authorization": "Bearer $GITHUB_PAT"
}
Expand Down Expand Up @@ -122,6 +121,10 @@ To verify that the GitHub MCP server has been configured, start Gemini CLI in yo
List my GitHub repositories
```

## Additional Configuration

You can find more MCP configuration options for Gemini CLI here: [MCP Configuration Structure](https://google-gemini.github.io/gemini-cli/docs/tools/mcp-server.html#configuration-structure). For example, bypassing tool confirmations or excluding specific tools.

## Troubleshooting

### Local Server Issues
Expand Down
4 changes: 3 additions & 1 deletion docs/remote-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ These toolsets are only available in the remote GitHub MCP Server and are not in

| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) |
| -------------------- | --------------------------------------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Copilot coding agent | Perform task with GitHub Copilot coding agent | https://api.githubcopilot.com/mcp/x/copilot | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-copilot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcopilot%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/copilot/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-copilot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcopilot%2Freadonly%22%7D) |
| Copilot | Copilot related tools | https://api.githubcopilot.com/mcp/x/copilot | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-copilot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcopilot%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/copilot/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-copilot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcopilot%2Freadonly%22%7D) |
| Copilot Spaces | Copilot Spaces tools | https://api.githubcopilot.com/mcp/x/copilot_spaces | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-copilot_spaces&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcopilot_spaces%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/copilot_spaces/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-copilot_spaces&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcopilot_spaces%2Freadonly%22%7D) |
| GitHub support docs search | Retrieve documentation to answer GitHub product and support questions. Topics include: GitHub Actions Workflows, Authentication, ... | https://api.githubcopilot.com/mcp/x/github_support_docs_search | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-support&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fgithub_support_docs_search%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/github_support_docs_search/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-support&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fgithub_support_docs_search%2Freadonly%22%7D) |

### Optional Headers

Expand Down
114 changes: 103 additions & 11 deletions internal/ghmcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os/signal"
"strings"
"syscall"
"time"

"github.com/github/github-mcp-server/pkg/errors"
"github.com/github/github-mcp-server/pkg/github"
Expand Down Expand Up @@ -105,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 @@ -363,11 +359,30 @@ func newGHESHost(hostname string) (apiHost, error) {
return apiHost{}, fmt.Errorf("failed to parse GHES GraphQL URL: %w", err)
}

uploadURL, err := url.Parse(fmt.Sprintf("%s://%s/api/uploads/", u.Scheme, u.Hostname()))
// Check if subdomain isolation is enabled
// See https://docs.github.com/en/enterprise-server@3.17/admin/configuring-settings/hardening-security-for-your-enterprise/enabling-subdomain-isolation#about-subdomain-isolation
hasSubdomainIsolation := checkSubdomainIsolation(u.Scheme, u.Hostname())

var uploadURL *url.URL
if hasSubdomainIsolation {
// With subdomain isolation: https://uploads.hostname/
uploadURL, err = url.Parse(fmt.Sprintf("%s://uploads.%s/", u.Scheme, u.Hostname()))
} else {
// Without subdomain isolation: https://hostname/api/uploads/
uploadURL, err = url.Parse(fmt.Sprintf("%s://%s/api/uploads/", u.Scheme, u.Hostname()))
}
if err != nil {
return apiHost{}, fmt.Errorf("failed to parse GHES Upload URL: %w", err)
}
rawURL, err := url.Parse(fmt.Sprintf("%s://%s/raw/", u.Scheme, u.Hostname()))

var rawURL *url.URL
if hasSubdomainIsolation {
// With subdomain isolation: https://raw.hostname/
rawURL, err = url.Parse(fmt.Sprintf("%s://raw.%s/", u.Scheme, u.Hostname()))
} else {
// Without subdomain isolation: https://hostname/raw/
rawURL, err = url.Parse(fmt.Sprintf("%s://%s/raw/", u.Scheme, u.Hostname()))
}
if err != nil {
return apiHost{}, fmt.Errorf("failed to parse GHES Raw URL: %w", err)
}
Expand All @@ -380,6 +395,29 @@ func newGHESHost(hostname string) (apiHost, error) {
}, nil
}

// checkSubdomainIsolation detects if GitHub Enterprise Server has subdomain isolation enabled
// by attempting to ping the raw.<host>/_ping endpoint on the subdomain. The raw subdomain must always exist for subdomain isolation.
func checkSubdomainIsolation(scheme, hostname string) bool {
subdomainURL := fmt.Sprintf("%s://raw.%s/_ping", scheme, hostname)

client := &http.Client{
Timeout: 5 * time.Second,
// Don't follow redirects - we just want to check if the endpoint exists
//nolint:revive // parameters are required by http.Client.CheckRedirect signature
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}

resp, err := client.Get(subdomainURL)
if err != nil {
return false
}
defer resp.Body.Close()

return resp.StatusCode == http.StatusOK
}

// Note that this does not handle ports yet, so development environments are out.
func parseAPIHost(s string) (apiHost, error) {
if s == "" {
Expand Down Expand Up @@ -427,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