Skip to content

Commit 4ebc718

Browse files
committed
Merge branch 'main' into docker
2 parents 011ce96 + 4e26dce commit 4ebc718

33 files changed

+2417
-898
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @juruen @sammorrowdrums @williammartin @toby
1+
* @github/github-mcp-server

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
.idea
22
cmd/github-mcp-server/github-mcp-server
3+
4+
# VSCode
5+
.vscode/*
6+
!.vscode/launch.json
7+
38
# Added by goreleaser init:
49
dist/
5-
__debug_bin*
10+
__debug_bin*
11+
12+
# Go
13+
vendor

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23.7-alpine AS build
1+
FROM golang:1.24.2-alpine AS build
22
ARG VERSION="dev"
33

44
# Set the working directory

README.md

Lines changed: 170 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,18 @@ automation and interaction capabilities for developers and tools.
1515
## Prerequisites
1616

1717
1. To run the server in a container, you will need to have [Docker](https://www.docker.com/) installed.
18-
2. Once Docker is installed, you will also need to ensure Docker is running.
18+
2. Once Docker is installed, you will also need to ensure Docker is running. The image is public; if you get errors on pull, you may have an expired token and need to `docker logout ghcr.io`.
1919
3. Lastly you will need to [Create a GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new).
2020
The MCP server can use many of the GitHub APIs, so enable the permissions that you feel comfortable granting your AI tools (to learn more about access tokens, please check out the [documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)).
2121

22-
23-
2422
## Installation
2523

2624
### Usage with VS Code
2725

28-
For quick installation, use one of the one-click install buttons at the top of this README.
26+
For quick installation, use one of the one-click install buttons at the top of this README. Once you complete that flow, toggle Agent mode (located by the Copilot Chat text input) and the server will start.
2927

3028
For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing `Ctrl + Shift + P` and typing `Preferences: Open User Settings (JSON)`.
3129

32-
Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with others.
33-
34-
> Note that the `mcp` key is not needed in the `.vscode/mcp.json` file.
35-
3630
```json
3731
{
3832
"mcp": {
@@ -64,6 +58,39 @@ Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace
6458
}
6559
```
6660

61+
Optionally, you can add a similar example (i.e. without the mcp key) to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with others.
62+
63+
64+
```json
65+
{
66+
"inputs": [
67+
{
68+
"type": "promptString",
69+
"id": "github_token",
70+
"description": "GitHub Personal Access Token",
71+
"password": true
72+
}
73+
],
74+
"servers": {
75+
"github": {
76+
"command": "docker",
77+
"args": [
78+
"run",
79+
"-i",
80+
"--rm",
81+
"-e",
82+
"GITHUB_PERSONAL_ACCESS_TOKEN",
83+
"ghcr.io/github/github-mcp-server"
84+
],
85+
"env": {
86+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
87+
}
88+
}
89+
}
90+
}
91+
92+
```
93+
6794
More about using MCP server tools in VS Code's [agent mode documentation](https://code.visualstudio.com/docs/copilot/chat/mcp-servers).
6895

6996
### Usage with Claude Desktop
@@ -91,14 +118,110 @@ More about using MCP server tools in VS Code's [agent mode documentation](https:
91118

92119
### Build from source
93120

94-
If you don't have Docker, you can use `go` to build the binary in the
95-
`cmd/github-mcp-server` directory, and use the `github-mcp-server stdio`
96-
command with the `GITHUB_PERSONAL_ACCESS_TOKEN` environment variable set to
97-
your token.
121+
If you don't have Docker, you can use `go build` to build the binary in the
122+
`cmd/github-mcp-server` directory, and use the `github-mcp-server stdio` command with the `GITHUB_PERSONAL_ACCESS_TOKEN` environment variable set to your token. To specify the output location of the build, use the `-o` flag. You should configure your server to use the built executable as its `command`. For example:
123+
124+
```JSON
125+
{
126+
"mcp": {
127+
"servers": {
128+
"github": {
129+
"command": "/path/to/github-mcp-server",
130+
"args": ["stdio"],
131+
"env": {
132+
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
133+
}
134+
}
135+
}
136+
}
137+
}
138+
```
139+
140+
## Tool Configuration
141+
142+
The GitHub MCP Server supports enabling or disabling specific groups of functionalities via the `--toolsets` flag. This allows you to control which GitHub API capabilities are available to your AI tools. Enabling only the toolsets that you need can help the LLM with tool choice and reduce the context size.
143+
144+
### Available Toolsets
145+
146+
The following sets of tools are available (all are on by default):
147+
148+
| Toolset | Description |
149+
| ----------------------- | ------------------------------------------------------------- |
150+
| `repos` | Repository-related tools (file operations, branches, commits) |
151+
| `issues` | Issue-related tools (create, read, update, comment) |
152+
| `users` | Anything relating to GitHub Users |
153+
| `pull_requests` | Pull request operations (create, merge, review) |
154+
| `code_security` | Code scanning alerts and security features |
155+
| `experiments` | Experimental features (not considered stable) |
156+
157+
#### Specifying Toolsets
158+
159+
To specify toolsets you want available to the LLM, you can pass an allow-list in two ways:
160+
161+
1. **Using Command Line Argument**:
162+
163+
```bash
164+
github-mcp-server --toolsets repos,issues,pull_requests,code_security
165+
```
166+
167+
2. **Using Environment Variable**:
168+
```bash
169+
GITHUB_TOOLSETS="repos,issues,pull_requests,code_security" ./github-mcp-server
170+
```
171+
172+
The environment variable `GITHUB_TOOLSETS` takes precedence over the command line argument if both are provided.
173+
174+
### Using Toolsets With Docker
175+
176+
When using Docker, you can pass the toolsets as environment variables:
177+
178+
```bash
179+
docker run -i --rm \
180+
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
181+
-e GITHUB_TOOLSETS="repos,issues,pull_requests,code_security,experiments" \
182+
ghcr.io/github/github-mcp-server
183+
```
184+
185+
### The "all" Toolset
186+
187+
The special toolset `all` can be provided to enable all available toolsets regardless of any other configuration:
188+
189+
```bash
190+
./github-mcp-server --toolsets all
191+
```
192+
193+
Or using the environment variable:
194+
195+
```bash
196+
GITHUB_TOOLSETS="all" ./github-mcp-server
197+
```
198+
199+
## Dynamic Tool Discovery
200+
201+
**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.
202+
203+
Instead of starting with all tools enabled, you can turn on dynamic toolset discovery. Dynamic toolsets allow the MCP host to list and enable toolsets in response to a user prompt. This should help to avoid situations where the model gets confused by the shear number of tools available.
204+
205+
### Using Dynamic Tool Discovery
206+
207+
When using the binary, you can pass the `--dynamic-toolsets` flag.
208+
209+
```bash
210+
./github-mcp-server --dynamic-toolsets
211+
```
212+
213+
When using Docker, you can pass the toolsets as environment variables:
214+
215+
```bash
216+
docker run -i --rm \
217+
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
218+
-e GITHUB_DYNAMIC_TOOLSETS=1 \
219+
ghcr.io/github/github-mcp-server
220+
```
98221

99222
## GitHub Enterprise Server
100223

101-
The flag `--gh-host` and the environment variable `GH_HOST` can be used to set
224+
The flag `--gh-host` and the environment variable `GITHUB_HOST` can be used to set
102225
the GitHub Enterprise Server hostname.
103226

104227
## i18n / Overriding Descriptions
@@ -288,6 +411,21 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
288411
- `draft`: Create as draft PR (boolean, optional)
289412
- `maintainer_can_modify`: Allow maintainer edits (boolean, optional)
290413

414+
- **add_pull_request_review_comment** - Add a review comment to a pull request or reply to an existing comment
415+
416+
- `owner`: Repository owner (string, required)
417+
- `repo`: Repository name (string, required)
418+
- `pull_number`: Pull request number (number, required)
419+
- `body`: The text of the review comment (string, required)
420+
- `commit_id`: The SHA of the commit to comment on (string, required unless using in_reply_to)
421+
- `path`: The relative path to the file that necessitates a comment (string, required unless using in_reply_to)
422+
- `line`: The line of the blob in the pull request diff that the comment applies to (number, optional)
423+
- `side`: The side of the diff to comment on (LEFT or RIGHT) (string, optional)
424+
- `start_line`: For multi-line comments, the first line of the range (number, optional)
425+
- `start_side`: For multi-line comments, the starting side of the diff (LEFT or RIGHT) (string, optional)
426+
- `subject_type`: The level at which the comment is targeted (line or file) (string, optional)
427+
- `in_reply_to`: The ID of the review comment to reply to (number, optional). When specified, only body is required and other parameters are ignored.
428+
291429
- **update_pull_request** - Update an existing pull request in a GitHub repository
292430

293431
- `owner`: Repository owner (string, required)
@@ -302,7 +440,6 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
302440
### Repositories
303441

304442
- **create_or_update_file** - Create or update a single file in a repository
305-
306443
- `owner`: Repository owner (string, required)
307444
- `repo`: Repository name (string, required)
308445
- `path`: File path (string, required)
@@ -312,50 +449,43 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
312449
- `sha`: File SHA if updating (string, optional)
313450

314451
- **list_branches** - List branches in a GitHub repository
315-
316452
- `owner`: Repository owner (string, required)
317453
- `repo`: Repository name (string, required)
318454
- `page`: Page number (number, optional)
319455
- `perPage`: Results per page (number, optional)
320456

321457
- **push_files** - Push multiple files in a single commit
322-
323458
- `owner`: Repository owner (string, required)
324459
- `repo`: Repository name (string, required)
325460
- `branch`: Branch to push to (string, required)
326461
- `files`: Files to push, each with path and content (array, required)
327462
- `message`: Commit message (string, required)
328463

329464
- **search_repositories** - Search for GitHub repositories
330-
331465
- `query`: Search query (string, required)
332466
- `sort`: Sort field (string, optional)
333467
- `order`: Sort order (string, optional)
334468
- `page`: Page number (number, optional)
335469
- `perPage`: Results per page (number, optional)
336470

337471
- **create_repository** - Create a new GitHub repository
338-
339472
- `name`: Repository name (string, required)
340473
- `description`: Repository description (string, optional)
341474
- `private`: Whether the repository is private (boolean, optional)
342475
- `autoInit`: Auto-initialize with README (boolean, optional)
343476

344477
- **get_file_contents** - Get contents of a file or directory
345-
346478
- `owner`: Repository owner (string, required)
347479
- `repo`: Repository name (string, required)
348480
- `path`: File path (string, required)
349481
- `ref`: Git reference (string, optional)
350482

351483
- **fork_repository** - Fork a repository
352-
353484
- `owner`: Repository owner (string, required)
354485
- `repo`: Repository name (string, required)
355486
- `organization`: Target organization name (string, optional)
356487

357488
- **create_branch** - Create a new branch
358-
359489
- `owner`: Repository owner (string, required)
360490
- `repo`: Repository name (string, required)
361491
- `branch`: New branch name (string, required)
@@ -376,18 +506,17 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
376506
- `page`: Page number, for files in the commit (number, optional)
377507
- `perPage`: Results per page, for files in the commit (number, optional)
378508

379-
### Search
380-
381509
- **search_code** - Search for code across GitHub repositories
382-
383510
- `query`: Search query (string, required)
384511
- `sort`: Sort field (string, optional)
385512
- `order`: Sort order (string, optional)
386513
- `page`: Page number (number, optional)
387514
- `perPage`: Results per page (number, optional)
388515

516+
### Users
517+
389518
- **search_users** - Search for GitHub users
390-
- `query`: Search query (string, required)
519+
- `q`: Search query (string, required)
391520
- `sort`: Sort field (string, optional)
392521
- `order`: Sort order (string, optional)
393522
- `page`: Page number (number, optional)
@@ -407,6 +536,22 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
407536
- `ref`: Git reference (string, optional)
408537
- `state`: Alert state (string, optional)
409538
- `severity`: Alert severity (string, optional)
539+
- `tool_name`: The name of the tool used for code scanning (string, optional)
540+
541+
### Secret Scanning
542+
543+
- **get_secret_scanning_alert** - Get a secret scanning alert
544+
545+
- `owner`: Repository owner (string, required)
546+
- `repo`: Repository name (string, required)
547+
- `alertNumber`: Alert number (number, required)
548+
549+
- **list_secret_scanning_alerts** - List secret scanning alerts for a repository
550+
- `owner`: Repository owner (string, required)
551+
- `repo`: Repository name (string, required)
552+
- `state`: Alert state (string, optional)
553+
- `secret_type`: The secret types to be filtered for in a comma-separated list (string, optional)
554+
- `resolution`: The resolution status (string, optional)
410555

411556
## Resources
412557

0 commit comments

Comments
 (0)