Skip to content

Commit 48eb4cb

Browse files
committed
Merge branch 'main' into token-scopes-context
2 parents f1d372e + bbc675a commit 48eb4cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+410
-6957
lines changed

.github/workflows/docker-publish.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,14 @@ jobs:
9393
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
9494

9595
- name: Inject go-build-cache
96-
uses: reproducible-containers/buildkit-cache-dance@4b2444fec0c0fb9dbf175a96c094720a692ef810 # v2.1.4
96+
uses: reproducible-containers/buildkit-cache-dance@6f699a72a59e4252f05a7435430009b77e25fe06 # v3.3.1
9797
with:
98-
cache-source: go-build-cache
98+
cache-map: |
99+
{
100+
"go-build-cache/apk": "/var/cache/apk",
101+
"go-build-cache/pkg": "/go/pkg/mod",
102+
"go-build-cache/build": "/root/.cache/go-build"
103+
}
99104
100105
# Build and push Docker image with Buildx (don't push on PR)
101106
# https://github.com/docker/build-push-action

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v6
1717
- uses: actions/setup-go@v6
1818
with:
19-
go-version: stable
19+
go-version: '1.25'
2020
- name: golangci-lint
2121
uses: golangci/golangci-lint-action@v9
2222
with:

Dockerfile

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

44
# Set the working directory
@@ -26,6 +26,8 @@ LABEL io.modelcontextprotocol.server.name="io.github.github/github-mcp-server"
2626
WORKDIR /server
2727
# Copy the binary from the build stage
2828
COPY --from=build /bin/github-mcp-server .
29+
# Expose the default port
30+
EXPOSE 8082
2931
# Set the entrypoint to the server binary
3032
ENTRYPOINT ["/server/github-mcp-server"]
3133
# Default arguments for ENTRYPOINT

docs/installation-guides/install-copilot-cli.md

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,48 @@
11
# Install GitHub MCP Server in Copilot CLI
22

3-
## Prerequisites
3+
The GitHub MCP server comes pre-installed in Copilot CLI, with read-only tools enabled by default.
44

5-
1. Copilot CLI installed (see [official Copilot CLI documentation](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli))
6-
2. [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) with appropriate scopes
7-
3. For local installation: [Docker](https://www.docker.com/) installed and running
5+
## Built-in Server
6+
7+
To verify the server is available, from an active Copilot CLI session:
8+
9+
```bash
10+
/mcp show github-mcp-server
11+
```
12+
13+
### Per-Session Customization
14+
15+
Use CLI flags to customize the server for a session:
16+
17+
```bash
18+
# Enable an additional toolset
19+
copilot --add-github-mcp-toolset discussions
20+
21+
# Enable multiple additional toolsets
22+
copilot --add-github-mcp-toolset discussions --add-github-mcp-toolset stargazers
23+
24+
# Enable all toolsets
25+
copilot --enable-all-github-mcp-tools
26+
27+
# Enable a specific tool
28+
copilot --add-github-mcp-tool list_discussions
29+
30+
# Disable the built-in server entirely
31+
copilot --disable-builtin-mcps
32+
```
33+
34+
Run `copilot --help` for all available flags. For the list of toolsets, see [Available toolsets](../../README.md#available-toolsets); for the list of tools, see [Tools](../../README.md#tools).
35+
36+
## Custom Configuration
37+
38+
You can configure the GitHub MCP server in Copilot CLI using either the interactive command or by manually editing the configuration file.
39+
40+
> **Server naming:** Name your server `github-mcp-server` to replace the built-in server, or use a different name (e.g., `github`) to run alongside it.
41+
42+
### Prerequisites
43+
44+
1. [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) with appropriate scopes
45+
2. For local server: [Docker](https://www.docker.com/) installed and running
846

947
<details>
1048
<summary><b>Storing Your PAT Securely</b></summary>
@@ -19,21 +57,17 @@ export GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here
1957

2058
</details>
2159

22-
## GitHub MCP Server Configuration
23-
24-
You can configure the GitHub MCP server in Copilot CLI using either the interactive command or by manually editing the configuration file.
25-
2660
### Method 1: Interactive Setup (Recommended)
2761

28-
Use the Copilot CLI to interactively add the MCP server:
62+
From an active Copilot CLI session, run the interactive command:
2963

3064
```bash
3165
/mcp add
3266
```
3367

34-
Follow the prompts to configure the GitHub MCP server.
68+
Follow the prompts to configure the server.
3569

36-
### Method 2: Manual Configuration
70+
### Method 2: Manual Setup
3771

3872
Create or edit the configuration file `~/.copilot/mcp-config.json` and add one of the following configurations:
3973

@@ -45,6 +79,7 @@ Connect to the hosted MCP server:
4579
{
4680
"mcpServers": {
4781
"github": {
82+
"type": "http",
4883
"url": "https://api.githubcopilot.com/mcp/",
4984
"headers": {
5085
"Authorization": "Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}"
@@ -54,6 +89,8 @@ Connect to the hosted MCP server:
5489
}
5590
```
5691

92+
For additional options like toolsets and read-only mode, see the [remote server documentation](../remote-server.md#optional-headers).
93+
5794
#### Local Docker
5895

5996
With Docker running, you can run the GitHub MCP server in a container:
@@ -81,9 +118,13 @@ With Docker running, you can run the GitHub MCP server in a container:
81118

82119
#### Binary
83120

84-
You can download the latest binary release from the [GitHub releases page](https://github.com/github/github-mcp-server/releases) or build it from source by running `go build -o github-mcp-server ./cmd/github-mcp-server`.
121+
You can download the latest binary release from the [GitHub releases page](https://github.com/github/github-mcp-server/releases) or build it from source by running:
85122

86-
Then, replacing `/path/to/binary` with the actual path to your binary, configure Copilot CLI with:
123+
```bash
124+
go build -o github-mcp-server ./cmd/github-mcp-server
125+
```
126+
127+
Then configure (replace `/path/to/binary` with the actual path):
87128

88129
```json
89130
{
@@ -101,35 +142,30 @@ Then, replacing `/path/to/binary` with the actual path to your binary, configure
101142

102143
## Verification
103144

104-
To verify that the GitHub MCP server has been configured:
105-
106-
1. Start or restart Copilot CLI
107-
2. The GitHub tools should be available for use in your conversations
145+
1. Restart Copilot CLI
146+
2. Run `/mcp show` to list configured servers
147+
3. Try: "List my GitHub repositories"
108148

109149
## Troubleshooting
110150

111151
### Local Server Issues
112152

113153
- **Docker errors**: Ensure Docker Desktop is running
114-
```bash
115-
docker --version
116-
```
117154
- **Image pull failures**: Try `docker logout ghcr.io` then retry
118-
- **Docker not found**: Install Docker Desktop and ensure it's running
119155

120156
### Authentication Issues
121157

122158
- **Invalid PAT**: Verify your GitHub PAT has correct scopes:
123-
- `repo` - Repository operations
124-
- `read:packages` - Docker image access (if using Docker)
159+
- `repo` - Repository operations
160+
- `read:packages` - Docker image access (if using Docker)
125161
- **Token expired**: Generate a new GitHub PAT
126162

127163
### Configuration Issues
128164

129165
- **Invalid JSON**: Validate your configuration:
130-
```bash
131-
cat ~/.copilot/mcp-config.json | jq .
132-
```
166+
```bash
167+
cat ~/.copilot/mcp-config.json | jq .
168+
```
133169

134170
## References
135171

docs/streamable-http.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Streamable HTTP Server
2+
3+
The Streamable HTTP mode enables the GitHub MCP Server to run as an HTTP service, allowing clients to connect via standard HTTP protocols. This mode is ideal for deployment scenarios where stdio transport isn't suitable, such as reverse proxy setups, containerized environments, or distributed architectures.
4+
5+
## Features
6+
7+
- **Streamable HTTP Transport** — Full HTTP server with streaming support for real-time tool responses
8+
- **OAuth Metadata Endpoints** — Standard `.well-known/oauth-protected-resource` discovery for OAuth clients
9+
- **Scope Challenge Support** — Automatic scope validation with proper HTTP 403 responses and `WWW-Authenticate` headers
10+
- **Scope Filtering** — Restrict available tools based on authenticated credentials and permissions
11+
- **Custom Base Paths** — Support for reverse proxy deployments with customizable base URLs
12+
13+
## Running the Server
14+
15+
### Basic HTTP Server
16+
17+
Start the server on the default port (8082):
18+
19+
```bash
20+
github-mcp-server http
21+
```
22+
23+
The server will be available at `http://localhost:8082`.
24+
25+
### With Scope Challenge
26+
27+
Enable scope validation to enforce GitHub permission checks:
28+
29+
```bash
30+
github-mcp-server http --scope-challenge
31+
```
32+
33+
When `--scope-challenge` is enabled, requests with insufficient scopes receive a `403 Forbidden` response with a `WWW-Authenticate` header indicating the required scopes.
34+
35+
### With OAuth Metadata Discovery
36+
37+
For use behind reverse proxies or with custom domains, expose OAuth metadata endpoints:
38+
39+
```bash
40+
github-mcp-server http --scope-challenge --base-url https://myserver.com --base-path /mcp
41+
```
42+
43+
The OAuth protected resource metadata's `resource` attribute will be populated with the full URL to the server's protected resource endpoint:
44+
45+
```json
46+
{
47+
"resource_name": "GitHub MCP Server",
48+
"resource": "https://myserver.com/mcp",
49+
"authorization_servers": [
50+
"https://github.com/login/oauth"
51+
],
52+
"scopes_supported": [
53+
"repo",
54+
...
55+
],
56+
...
57+
}
58+
```
59+
60+
This allows OAuth clients to discover authentication requirements and endpoint information automatically.
61+
62+
## Client Configuration
63+
64+
### Using OAuth Authentication
65+
66+
If your IDE or client has GitHub credentials configured (i.e. VS Code), simply reference the HTTP server:
67+
68+
```json
69+
{
70+
"type": "http",
71+
"url": "http://localhost:8082"
72+
}
73+
```
74+
75+
The server will use the client's existing GitHub authentication.
76+
77+
### Using Bearer Tokens or Custom Headers
78+
79+
To provide PAT credentials, or to customize server behavior preferences, you can include additional headers in the client configuration:
80+
81+
```json
82+
{
83+
"type": "http",
84+
"url": "http://localhost:8082",
85+
"headers": {
86+
"Authorization": "Bearer ghp_yourtokenhere",
87+
"X-MCP-Toolsets": "default",
88+
"X-MCP-Readonly": "true"
89+
}
90+
}
91+
```
92+
93+
See [Remote Server](./remote-server.md) documentation for more details on client configuration options.

go.mod

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.0
55
require (
66
github.com/google/go-github/v79 v79.0.0
77
github.com/google/jsonschema-go v0.4.2
8-
github.com/josephburnett/jd v1.9.2
8+
github.com/josephburnett/jd/v2 v2.4.0
99
github.com/microcosm-cc/bluemonday v1.0.27
1010
github.com/muesli/cache2go v0.0.0-20221011235721-518229cd8021
1111
github.com/spf13/cobra v1.10.2
@@ -17,20 +17,19 @@ require (
1717
github.com/aymerick/douceur v0.2.0 // indirect
1818
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1919
github.com/fsnotify/fsnotify v1.9.0 // indirect
20-
github.com/go-chi/chi/v5 v5.2.3
21-
github.com/go-openapi/jsonpointer v0.19.5 // indirect
22-
github.com/go-openapi/swag v0.21.1 // indirect
20+
github.com/go-chi/chi/v5 v5.2.5
21+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
22+
github.com/go-openapi/swag v0.23.0 // indirect
2323
github.com/go-viper/mapstructure/v2 v2.5.0
2424
github.com/google/go-querystring v1.1.0 // indirect
2525
github.com/gorilla/css v1.0.1 // indirect
2626
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2727
github.com/josharian/intern v1.0.0 // indirect
2828
github.com/lithammer/fuzzysearch v1.1.8
2929
github.com/mailru/easyjson v0.7.7 // indirect
30-
github.com/modelcontextprotocol/go-sdk v1.2.0
30+
github.com/modelcontextprotocol/go-sdk v1.3.0
3131
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
3232
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
33-
github.com/rogpeppe/go-internal v1.13.1 // indirect
3433
github.com/sagikazarmark/locafero v0.11.0 // indirect
3534
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7
3635
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466
@@ -41,14 +40,11 @@ require (
4140
github.com/stretchr/objx v0.5.2 // indirect
4241
github.com/subosito/gotenv v1.6.0 // indirect
4342
github.com/yosida95/uritemplate/v3 v3.0.2
44-
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
4543
go.yaml.in/yaml/v3 v3.0.4 // indirect
46-
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
44+
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
4745
golang.org/x/net v0.38.0 // indirect
4846
golang.org/x/oauth2 v0.30.0 // indirect
4947
golang.org/x/sys v0.31.0 // indirect
5048
golang.org/x/text v0.28.0 // indirect
51-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
52-
gopkg.in/yaml.v2 v2.4.0 // indirect
5349
gopkg.in/yaml.v3 v3.0.1 // indirect
5450
)

0 commit comments

Comments
 (0)