Skip to content

Commit 2b5be7a

Browse files
committed
Merge branch 'http-stack-2' into oauth-handler-implementation
2 parents 5ef1fde + a4d6b20 commit 2b5be7a

File tree

13 files changed

+310
-76
lines changed

13 files changed

+310
-76
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Alternatively, to manually configure VS Code, choose the appropriate JSON block
8181

8282
### Install in other MCP hosts
8383

84+
- **[Copilot CLI](/docs/installation-guides/install-copilot-cli.md)** - Installation guide for GitHub Copilot CLI
8485
- **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot
8586
- **[Claude Applications](/docs/installation-guides/install-claude.md)** - Installation guide for Claude Desktop and Claude Code CLI
8687
- **[Codex](/docs/installation-guides/install-codex.md)** - Installation guide for OpenAI Codex
@@ -350,6 +351,7 @@ Optionally, you can add a similar example (i.e. without the mcp key) to a file c
350351

351352
For other MCP host applications, please refer to our installation guides:
352353

354+
- **[Copilot CLI](docs/installation-guides/install-copilot-cli.md)** - Installation guide for GitHub Copilot CLI
353355
- **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot
354356
- **[Claude Code & Claude Desktop](docs/installation-guides/install-claude.md)** - Installation guide for Claude Code and Claude Desktop
355357
- **[Cursor](docs/installation-guides/install-cursor.md)** - Installation guide for Cursor IDE

docs/installation-guides/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This directory contains detailed installation instructions for the GitHub MCP Server across different host applications and IDEs. Choose the guide that matches your development environment.
44

55
## Installation Guides by Host Application
6+
- **[Copilot CLI](install-copilot-cli.md)** - Installation guide for GitHub Copilot CLI
67
- **[GitHub Copilot in other IDEs](install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot
78
- **[Antigravity](install-antigravity.md)** - Installation for Google Antigravity IDE
89
- **[Claude Applications](install-claude.md)** - Installation guide for Claude Web, Claude Desktop and Claude Code CLI
@@ -15,6 +16,7 @@ This directory contains detailed installation instructions for the GitHub MCP Se
1516

1617
| Host Application | Local GitHub MCP Support | Remote GitHub MCP Support | Prerequisites | Difficulty |
1718
|-----------------|---------------|----------------|---------------|------------|
19+
| Copilot CLI || ✅ PAT + ❌ No OAuth | Docker or Go build, GitHub PAT | Easy |
1820
| Copilot in VS Code || ✅ Full (OAuth + PAT) | Local: Docker or Go build, GitHub PAT<br>Remote: VS Code 1.101+ | Easy |
1921
| Copilot Coding Agent || ✅ Full (on by default; no auth needed) | Any _paid_ copilot license | Default on |
2022
| Copilot in Visual Studio || ✅ Full (OAuth + PAT) | Local: Docker or Go build, GitHub PAT<br>Remote: Visual Studio 17.14+ | Easy |
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Install GitHub MCP Server in Copilot CLI
2+
3+
## Prerequisites
4+
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
8+
9+
<details>
10+
<summary><b>Storing Your PAT Securely</b></summary>
11+
<br>
12+
13+
To set your PAT as an environment variable:
14+
15+
```bash
16+
# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
17+
export GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here
18+
```
19+
20+
</details>
21+
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+
26+
### Method 1: Interactive Setup (Recommended)
27+
28+
Use the Copilot CLI to interactively add the MCP server:
29+
30+
```bash
31+
/mcp add
32+
```
33+
34+
Follow the prompts to configure the GitHub MCP server.
35+
36+
### Method 2: Manual Configuration
37+
38+
Create or edit the configuration file `~/.copilot/mcp-config.json` and add one of the following configurations:
39+
40+
#### Remote Server
41+
42+
Connect to the hosted MCP server:
43+
44+
```json
45+
{
46+
"mcpServers": {
47+
"github": {
48+
"url": "https://api.githubcopilot.com/mcp/",
49+
"headers": {
50+
"Authorization": "Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}"
51+
}
52+
}
53+
}
54+
}
55+
```
56+
57+
#### Local Docker
58+
59+
With Docker running, you can run the GitHub MCP server in a container:
60+
61+
```json
62+
{
63+
"mcpServers": {
64+
"github": {
65+
"command": "docker",
66+
"args": [
67+
"run",
68+
"-i",
69+
"--rm",
70+
"-e",
71+
"GITHUB_PERSONAL_ACCESS_TOKEN",
72+
"ghcr.io/github/github-mcp-server"
73+
],
74+
"env": {
75+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
76+
}
77+
}
78+
}
79+
}
80+
```
81+
82+
#### Binary
83+
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`.
85+
86+
Then, replacing `/path/to/binary` with the actual path to your binary, configure Copilot CLI with:
87+
88+
```json
89+
{
90+
"mcpServers": {
91+
"github": {
92+
"command": "/path/to/binary",
93+
"args": ["stdio"],
94+
"env": {
95+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
96+
}
97+
}
98+
}
99+
}
100+
```
101+
102+
## Verification
103+
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
108+
109+
## Troubleshooting
110+
111+
### Local Server Issues
112+
113+
- **Docker errors**: Ensure Docker Desktop is running
114+
```bash
115+
docker --version
116+
```
117+
- **Image pull failures**: Try `docker logout ghcr.io` then retry
118+
- **Docker not found**: Install Docker Desktop and ensure it's running
119+
120+
### Authentication Issues
121+
122+
- **Invalid PAT**: Verify your GitHub PAT has correct scopes:
123+
- `repo` - Repository operations
124+
- `read:packages` - Docker image access (if using Docker)
125+
- **Token expired**: Generate a new GitHub PAT
126+
127+
### Configuration Issues
128+
129+
- **Invalid JSON**: Validate your configuration:
130+
```bash
131+
cat ~/.copilot/mcp-config.json | jq .
132+
```
133+
134+
## References
135+
136+
- [Copilot CLI Documentation](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli)

docs/remote-server.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,15 @@ The Remote GitHub MCP server supports the following URL path patterns:
121121
- `/` - Default toolset (see ["default" toolset](../README.md#default-toolset))
122122
- `/readonly` - Default toolset in read-only mode
123123
- `/insiders` - Default toolset with insiders mode enabled
124-
- `/insiders/readonly` - Default toolset with insiders mode in read-only mode
124+
- `/readonly/insiders` - Default toolset in read-only mode with insiders mode enabled
125125
- `/x/all` - All available toolsets
126126
- `/x/all/readonly` - All available toolsets in read-only mode
127127
- `/x/all/insiders` - All available toolsets with insiders mode enabled
128+
- `/x/all/readonly/insiders` - All available toolsets in read-only mode with insiders mode enabled
128129
- `/x/{toolset}` - Single specific toolset
129130
- `/x/{toolset}/readonly` - Single specific toolset in read-only mode
130131
- `/x/{toolset}/insiders` - Single specific toolset with insiders mode enabled
132+
- `/x/{toolset}/readonly/insiders` - Single specific toolset in read-only mode with insiders mode enabled
131133

132134
Note: `{toolset}` can only be a single toolset, not a comma-separated list. To combine multiple toolsets, use the `X-MCP-Toolsets` header instead. Path modifiers like `/readonly` and `/insiders` can be combined with the `X-MCP-Insiders` or `X-MCP-Readonly` headers.
133135

internal/ghmcp/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ func NewStdioMCPServer(ctx context.Context, cfg github.MCPServerConfig) (*mcp.Se
135135
WithReadOnly(cfg.ReadOnly).
136136
WithToolsets(cfg.EnabledToolsets).
137137
WithTools(github.CleanTools(cfg.EnabledTools)).
138-
WithServerInstructions()
139-
// WithFeatureChecker(createFeatureChecker(cfg.EnabledFeatures))
138+
WithServerInstructions().
139+
WithFeatureChecker(featureChecker)
140140

141141
// Apply token scope filtering if scopes are known (for PAT filtering)
142142
if cfg.TokenScopes != nil {

pkg/context/request.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,35 @@ func IsLockdownMode(ctx context.Context) bool {
6565
}
6666
return false
6767
}
68+
69+
// insidersCtxKey is a context key for insiders mode
70+
type insidersCtxKey struct{}
71+
72+
// WithInsidersMode adds insiders mode state to the context
73+
func WithInsidersMode(ctx context.Context, enabled bool) context.Context {
74+
return context.WithValue(ctx, insidersCtxKey{}, enabled)
75+
}
76+
77+
// IsInsidersMode retrieves the insiders mode state from the context
78+
func IsInsidersMode(ctx context.Context) bool {
79+
if enabled, ok := ctx.Value(insidersCtxKey{}).(bool); ok {
80+
return enabled
81+
}
82+
return false
83+
}
84+
85+
// headerFeaturesCtxKey is a context key for raw header feature flags
86+
type headerFeaturesCtxKey struct{}
87+
88+
// WithHeaderFeatures stores the raw feature flags from the X-MCP-Features header into context
89+
func WithHeaderFeatures(ctx context.Context, features []string) context.Context {
90+
return context.WithValue(ctx, headerFeaturesCtxKey{}, features)
91+
}
92+
93+
// GetHeaderFeatures retrieves the raw feature flags from context
94+
func GetHeaderFeatures(ctx context.Context) []string {
95+
if features, ok := ctx.Value(headerFeaturesCtxKey{}).([]string); ok {
96+
return features
97+
}
98+
return nil
99+
}

pkg/github/dependencies.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ type RequestDeps struct {
248248
lockdownMode bool
249249
RepoAccessOpts []lockdown.RepoAccessOption
250250
T translations.TranslationHelperFunc
251-
Flags FeatureFlags
252251
ContentWindowSize int
253252

254253
// Feature flag checker for runtime checks
@@ -380,6 +379,7 @@ func (d *RequestDeps) GetT() translations.TranslationHelperFunc { return d.T }
380379
func (d *RequestDeps) GetFlags(ctx context.Context) FeatureFlags {
381380
return FeatureFlags{
382381
LockdownMode: d.lockdownMode && ghcontext.IsLockdownMode(ctx),
382+
InsidersMode: ghcontext.IsInsidersMode(ctx),
383383
}
384384
}
385385

pkg/http/features.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)