Movatterモバイル変換


[0]ホーム

URL:


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

Support GITHUB_ACCESS_TOKEN for OAuth and PAT compatibility#1677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Copilot wants to merge5 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/update-env-var-name-access-token
Open
Show file tree
Hide file tree
Changes fromall 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
36 changes: 19 additions & 17 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,9 +132,11 @@ GitHub Enterprise Server does not support remote server hosting. Please refer to

1. To run the server in a container, you will need to have [Docker](https://www.docker.com/) installed.
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`.
3. Lastly you will need to [Create a GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new).
3. Lastly you will need to [Create a GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) or use an OAuth token from your IDE/toolchain.
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)).

> **Note**: The server accepts any valid GitHub access token (PAT or OAuth). The `GITHUB_ACCESS_TOKEN` environment variable is preferred over the deprecated `GITHUB_PERSONAL_ACCESS_TOKEN` variable.

<details><summary><b>Handling PATs Securely</b></summary>

### Environment Variables (Recommended)
Expand All@@ -158,11 +160,11 @@ To keep your GitHub PAT secure and reusable across different MCP hosts:
3. **Reference the token in configurations**
```bash
# CLI usage
claude mcp update github -eGITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT
claude mcp update github -eGITHUB_ACCESS_TOKEN=$GITHUB_PAT

# In config files (where supported)
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PAT"
"GITHUB_ACCESS_TOKEN": "$GITHUB_PAT"
}
```

Expand DownExpand Up@@ -199,13 +201,13 @@ the hostname for GitHub Enterprise Server or GitHub Enterprise Cloud with data r
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_ACCESS_TOKEN",
"-e",
"GITHUB_HOST",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}",
"GITHUB_ACCESS_TOKEN": "${input:github_token}",
"GITHUB_HOST": "https://<your GHES or ghe.com domain name>"
}
}
Expand DownExpand Up@@ -242,11 +244,11 @@ Add the following JSON block to your IDE's MCP settings.
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
}
Expand DownExpand Up@@ -278,11 +280,11 @@ Optionally, you can add a similar example (i.e. without the mcp key) to a file c
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
}
Expand All@@ -308,7 +310,7 @@ For a complete overview of all installation options, see our **[Installation Gui
### Build from source

If you don't have Docker, you can use `go build` to build the binary in the
`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:
`cmd/github-mcp-server` directory, and use the `github-mcp-server stdio` command with the `GITHUB_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:

```JSON
{
Expand All@@ -318,7 +320,7 @@ If you don't have Docker, you can use `go build` to build the binary in the
"command": "/path/to/github-mcp-server",
"args": ["stdio"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
"GITHUB_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
Expand DownExpand Up@@ -392,7 +394,7 @@ When using Docker, you can pass the toolsets as environment variables:

```bash
docker run -i --rm \
-eGITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
-eGITHUB_ACCESS_TOKEN=<your-token> \
-e GITHUB_TOOLSETS="repos,issues,pull_requests,actions,code_security" \
ghcr.io/github/github-mcp-server
```
Expand All@@ -404,13 +406,13 @@ When using Docker, you can pass specific tools as environment variables. You can
```bash
# Tools only
docker run -i --rm \
-eGITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
-eGITHUB_ACCESS_TOKEN=<your-token> \
-e GITHUB_TOOLS="get_file_contents,issue_read,create_pull_request" \
ghcr.io/github/github-mcp-server

# Tools combined with toolsets (additive)
docker run -i --rm \
-eGITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
-eGITHUB_ACCESS_TOKEN=<your-token> \
-e GITHUB_TOOLSETS="repos,issues" \
-e GITHUB_TOOLS="get_gist" \
ghcr.io/github/github-mcp-server
Expand DownExpand Up@@ -1344,7 +1346,7 @@ When using Docker, you can pass the toolsets as environment variables:

```bash
docker run -i --rm \
-eGITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
-eGITHUB_ACCESS_TOKEN=<your-token> \
-e GITHUB_DYNAMIC_TOOLSETS=1 \
ghcr.io/github/github-mcp-server
```
Expand All@@ -1361,7 +1363,7 @@ When using Docker, you can pass the read-only mode as an environment variable:

```bash
docker run -i --rm \
-eGITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
-eGITHUB_ACCESS_TOKEN=<your-token> \
-e GITHUB_READ_ONLY=1 \
ghcr.io/github/github-mcp-server
```
Expand All@@ -1378,7 +1380,7 @@ When running with Docker, set the corresponding environment variable:

```bash
docker run -i --rm \
-eGITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
-eGITHUB_ACCESS_TOKEN=<your-token> \
-e GITHUB_LOCKDOWN_MODE=1 \
ghcr.io/github/github-mcp-server
```
Expand Down
9 changes: 7 additions & 2 deletionscmd/github-mcp-server/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,9 +32,14 @@ var (
Short: "Start stdio server",
Long: `Start a server that communicates via standard input/output streams using JSON-RPC messages.`,
RunE: func(_ *cobra.Command, _ []string) error {
token := viper.GetString("personal_access_token")
// Check for GITHUB_ACCESS_TOKEN first (preferred), then fall back to
// GITHUB_PERSONAL_ACCESS_TOKEN (deprecated but still supported)
token := viper.GetString("access_token")
if token == "" {
return errors.New("GITHUB_PERSONAL_ACCESS_TOKEN not set")
token = viper.GetString("personal_access_token")
}
if token == "" {
return errors.New("GITHUB_ACCESS_TOKEN or GITHUB_PERSONAL_ACCESS_TOKEN not set")
}

// If you're wondering why we're not using viper.GetStringSlice("toolsets"),
Expand Down
4 changes: 2 additions & 2 deletionsdocs/installation-guides/install-antigravity.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,11 +85,11 @@ If you prefer running the server locally with Docker:
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
"GITHUB_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
}
}
}
Expand Down
10 changes: 5 additions & 5 deletionsdocs/installation-guides/install-claude.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,12 +45,12 @@ claude mcp add --transport http github https://api.githubcopilot.com/mcp -H "Aut
### With Docker
1. Run the following command in the Claude Code CLI:
```bash
claude mcp add github -eGITHUB_PERSONAL_ACCESS_TOKEN=YOUR_GITHUB_PAT -- docker run -i --rm -eGITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
claude mcp add github -eGITHUB_ACCESS_TOKEN=YOUR_GITHUB_PAT -- docker run -i --rm -eGITHUB_ACCESS_TOKEN ghcr.io/github/github-mcp-server
```

With an environment variable:
```bash
claude mcp add github -eGITHUB_PERSONAL_ACCESS_TOKEN=$(grep GITHUB_PAT .env | cut -d '=' -f2) -- docker run -i --rm -eGITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
claude mcp add github -eGITHUB_ACCESS_TOKEN=$(grep GITHUB_PAT .env | cut -d '=' -f2) -- docker run -i --rm -eGITHUB_ACCESS_TOKEN ghcr.io/github/github-mcp-server
```
2. Restart Claude Code
3. Run `claude mcp list` to see if the GitHub server is configured
Expand All@@ -61,7 +61,7 @@ claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=$(grep GITHUB_PAT .env | c
2. Add to your `PATH`
3. Run:
```bash
claude mcp add-json github '{"command": "github-mcp-server", "args": ["stdio"], "env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT"}}'
claude mcp add-json github '{"command": "github-mcp-server", "args": ["stdio"], "env": {"GITHUB_ACCESS_TOKEN": "YOUR_GITHUB_PAT"}}'
```
2. Restart Claude Code
3. Run `claude mcp list` to see if the GitHub server is configured
Expand DownExpand Up@@ -104,11 +104,11 @@ Add this codeblock to your `claude_desktop_config.json`:
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
"GITHUB_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletionsdocs/installation-guides/install-cursor.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,11 +61,11 @@ The local GitHub MCP server runs via Docker and requires Docker Desktop to be in
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
"GITHUB_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletionsdocs/installation-guides/install-gemini-cli.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,11 +72,11 @@ With docker running, you can run the GitHub MCP server in a container:
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_MCP_PAT"
"GITHUB_ACCESS_TOKEN": "$GITHUB_MCP_PAT"
}
}
}
Expand All@@ -97,7 +97,7 @@ Then, replacing `/path/to/binary` with the actual path to your binary, configure
"command": "/path/to/binary",
"args": ["stdio"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_MCP_PAT"
"GITHUB_ACCESS_TOKEN": "$GITHUB_MCP_PAT"
}
}
}
Expand Down
16 changes: 8 additions & 8 deletionsdocs/installation-guides/install-other-copilot-ides.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,11 +56,11 @@ For users who prefer to run the GitHub MCP server locally. Requires Docker insta
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"run", "-i", "--rm", "-e", "GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_pat}"
"GITHUB_ACCESS_TOKEN": "${input:github_pat}"
}
}
}
Expand DownExpand Up@@ -116,11 +116,11 @@ For users who prefer to run the GitHub MCP server locally. Requires Docker insta
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"-e", "GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
"GITHUB_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
}
}
}
Expand DownExpand Up@@ -172,11 +172,11 @@ For users who prefer to run the GitHub MCP server locally. Requires Docker insta
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"-e", "GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
"GITHUB_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
}
}
}
Expand DownExpand Up@@ -229,11 +229,11 @@ For users who prefer to run the GitHub MCP server locally. Requires Docker insta
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"-e", "GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
"GITHUB_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletionsdocs/installation-guides/install-windsurf.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,11 +40,11 @@ Windsurf supports Streamable HTTP servers with a `serverUrl` field:
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN":"YOUR_GITHUB_PAT"
"GITHUB_ACCESS_TOKEN":"YOUR_GITHUB_PAT"
}
}
}
Expand Down
14 changes: 7 additions & 7 deletionsdocs/server-configuration.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,7 @@ The examples below use VS Code configuration format to illustrate the concepts.
"--tools=get_file_contents,get_me,pull_request_read"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
```
Expand DownExpand Up@@ -108,7 +108,7 @@ The examples below use VS Code configuration format to illustrate the concepts.
"--toolsets=issues,pull_requests"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
```
Expand DownExpand Up@@ -156,7 +156,7 @@ Enable entire toolsets, then add individual tools from toolsets you don't want f
"--tools=get_gist,pull_request_read"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
```
Expand DownExpand Up@@ -217,7 +217,7 @@ When active, this mode will disable all tools that are not read-only even if the
"--read-only"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
```
Expand DownExpand Up@@ -252,7 +252,7 @@ Starts with only discovery tools (`enable_toolset`, `list_available_toolsets`, `
"--dynamic-toolsets"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
```
Expand All@@ -270,7 +270,7 @@ Starts with only discovery tools (`enable_toolset`, `list_available_toolsets`, `
"--tools=get_me,search_code"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
```
Expand DownExpand Up@@ -319,7 +319,7 @@ Lockdown mode ensures the server only surfaces content in public repositories fr
"--lockdown-mode"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
"GITHUB_ACCESS_TOKEN": "${input:github_token}"
}
}
```
Expand Down
Binary file removede2e.test
View file
Open in desktop
Binary file not shown.
2 changes: 1 addition & 1 deletione2e/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ Since these tests require a token to interact with real resources on the GitHub
GITHUB_MCP_SERVER_E2E_TOKEN=<YOUR TOKEN> go test -v --tags e2e ./e2e
```

The`GITHUB_MCP_SERVER_E2E_TOKEN` environment variable is mapped to`GITHUB_PERSONAL_ACCESS_TOKEN` internally, but separated to avoid accidental reuse of credentials.
The`GITHUB_MCP_SERVER_E2E_TOKEN` environment variable is mapped to`GITHUB_ACCESS_TOKEN` internally, but separated to avoid accidental reuse of credentials.

##Example

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp