Skip to content

Commit 7373e87

Browse files
committed
feat: Add automatic GitHub authentication with wrapper scripts
This enhancement addresses the limitation of Zed's WASM sandbox which cannot access host environment variables for GitHub authentication. Key improvements: - Add wrapper script auto-detection for seamless authentication - Support multiple auth methods: GitHub CLI, environment variables, token files - Provide wrapper scripts for cross-platform compatibility (JS/Bash/PowerShell) - Maintain backwards compatibility with manual token configuration - Reorganize documentation with dedicated configuration and troubleshooting guides Features: - Automatic detection of wrapper scripts in extension directory - Fallback to manual token configuration if wrapper not available - Improved error handling and user feedback - Comprehensive documentation with examples This enables users to authenticate with GitHub without manual token management while preserving all existing functionality.
1 parent 9350334 commit 7373e87

File tree

11 files changed

+2295
-73
lines changed

11 files changed

+2295
-73
lines changed

CHANGELOG.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Changelog
2+
3+
All notable changes to the GitHub MCP Extension for Zed will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.0.4] - 2025-01-19
9+
10+
### Added
11+
12+
- **Cross-Platform Wrapper Scripts**: Added `github-mcp-wrapper.sh` (Bash) and `github-mcp-wrapper.ps1` (PowerShell)
13+
- **Zero Dependencies**: Eliminated Node.js requirement - uses system shell (Bash/PowerShell)
14+
- **Auto-Detection**: Extension automatically finds and uses appropriate wrapper script for platform
15+
- **Wrapper Mode Setting**: New `use_wrapper_script` boolean setting to enable automatic authentication
16+
- **GitHub CLI Integration**: Automatic token detection via `gh auth token` command
17+
- **Environment Variable Support**: Fallback authentication using `GITHUB_TOKEN`, `GITHUB_PERSONAL_ACCESS_TOKEN`, `GH_TOKEN`
18+
- **Token File Support**: Reads tokens from `~/.config/gh/hosts.yml`, `~/.github_token`, and other common locations
19+
- **Token Validation**: Optional token validation against GitHub API before starting server
20+
- **Debug Mode**: Verbose logging support via `LOG_LEVEL=debug`
21+
22+
### Enhanced
23+
24+
- **Cross-Platform Compatibility**: Native support for Unix/Linux/macOS (Bash) and Windows (PowerShell)
25+
- **Documentation**: Updated README and installation instructions to reflect dependency removal
26+
- **Security**: No hardcoded tokens required in configuration files
27+
- **Performance**: Reduced overhead by eliminating Node.js runtime dependency
28+
29+
### Technical Details
30+
31+
- **Platform Detection**: Automatically selects Bash or PowerShell wrapper based on OS
32+
- **Backwards Compatibility**: Node.js wrapper (`github-mcp-wrapper.js`) maintained as fallback
33+
- **Authentication Priority**: CLI tokens → Environment variables → Token files
34+
- **WASM Sandbox Bypass**: Wrapper scripts run outside Zed's WASM sandbox to access system resources
35+
36+
### Breaking Changes
37+
38+
- None - all existing configurations remain functional
39+
40+
### Dependencies
41+
42+
- **Removed**: Node.js requirement (was previously required for wrapper script)
43+
- GitHub CLI (optional, recommended for automatic authentication)
44+
- Go (for GitHub's official MCP server)
45+
46+
### Configuration Examples
47+
48+
#### Traditional Method (Unchanged)
49+
50+
```json
51+
{
52+
"context_servers": {
53+
"mcp-server-github": {
54+
"source": "extension",
55+
"settings": {
56+
"github_personal_access_token": "ghp_your_token_here"
57+
}
58+
}
59+
}
60+
}
61+
```
62+
63+
#### Wrapper Method (Recommended - Zero Dependencies)
64+
65+
```json
66+
{
67+
"context_servers": {
68+
"mcp-server-github": {
69+
"source": "extension",
70+
"settings": {
71+
"use_wrapper_script": true
72+
}
73+
}
74+
}
75+
}
76+
```
77+
78+
### Benefits
79+
80+
-**Zero additional dependencies** - uses system shell
81+
-**Cross-platform ready** - supports Unix/Linux/macOS and Windows
82+
- ✅ No hardcoded tokens in Zed settings
83+
- ✅ Automatic token refresh via GitHub CLI
84+
- ✅ Auto-detection of wrapper script path
85+
- ✅ Better security practices
86+
- ✅ Seamless GitHub CLI integration
87+
88+
### Files Added
89+
90+
- `wrappers/github-mcp-wrapper.sh` - Bash wrapper script for Unix/Linux/macOS
91+
- `wrappers/github-mcp-wrapper.ps1` - PowerShell wrapper script for Windows
92+
- `wrappers/github-mcp-wrapper.js` - Node.js wrapper script (backwards compatibility)
93+
- `DEPENDENCY_REMOVAL_SUMMARY.md` - Technical details of dependency removal
94+
95+
### Files Modified
96+
97+
- `src/mcp_server_github.rs` - Platform-aware wrapper detection with wrappers/ subfolder support
98+
- `README.md` - Updated for cross-platform support and organized file structure
99+
- `docs/configuration.md` - Removed Node.js requirement and updated paths
100+
- `docs/default_settings.jsonc` - Updated prerequisite comments
101+
102+
## [0.0.3] - Previous Release
103+
104+
### Added
105+
106+
- Initial GitHub MCP server integration
107+
- Basic token authentication
108+
- Core GitHub API operations
109+
110+
---
111+
112+
**Migration Guide**: No migration required. Existing configurations continue to work. New wrapper approach is optional but recommended for better security and automation.

README.md

Lines changed: 84 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,104 @@
1-
# GitHub MCP Server Extension for Zed
1+
# GitHub MCP Extension for Zed
22

3-
This extension integrates [GitHub MCP Server](https://github.com/github/github-mcp-server) as a context server for
4-
[Zed's](https://zed.dev) [Agent Panel.](https://zed.dev/docs/ai/overview)
3+
A Zed extension that provides GitHub integration through the Model Context Protocol (MCP), enabling AI-powered GitHub operations directly within your editor.
54

6-
To install navigate to: **Zed** > **Extensions**. Or use the command palette ([macOS](https://github.com/zed-industries/zed/blob/main/assets/keymaps/default-macos.json#L581), [Linux](https://github.com/zed-industries/zed/blob/main/assets/keymaps/default-linux.json#L459)) to search `extensions`.
5+
## 🚀 Quick Start
76

8-
## Authentication
7+
1. **Install Extension**: Search "GitHub MCP Server" in Zed Extensions
8+
2. **Configure Authentication**: Choose your preferred method below
9+
3. **Start Using**: Ask AI about GitHub operations in natural language
910

10-
You have two authentication options:
11+
## ⚙️ Authentication Setup
1112

12-
### Option 1: GitHub CLI (Recommended)
13+
### 🔧 Automatic Setup (Recommended)
1314

14-
Install and authenticate with the [GitHub CLI](https://cli.github.com/):
15+
**Just 2 steps:**
1516

16-
```bash
17-
gh auth login
18-
```
19-
20-
Then configure the extension without any settings:
17+
1. **Authenticate with GitHub**: `gh auth login`
18+
2. **Configure Zed**:
2119

2220
```json
23-
"context_servers": {
24-
"mcp-server-github": {
25-
"source": "extension"
21+
{
22+
"context_servers": {
23+
"mcp-server-github": {
24+
"source": "extension",
25+
"settings": {
26+
"use_wrapper_script": true
27+
}
28+
}
2629
}
27-
},
30+
}
2831
```
2932

30-
### Option 2: Personal Access Token
33+
Done! Extension automatically uses your GitHub CLI credentials.
34+
35+
### 📋 Manual Token Setup
3136

32-
[Create a PAT](https://github.com/settings/tokens) with `repo` permissions and configure it:
37+
If you prefer direct token configuration:
3338

3439
```json
35-
"context_servers": {
36-
"mcp-server-github": {
40+
{
41+
"context_servers": {
42+
"mcp-server-github": {
3743
"source": "extension",
3844
"settings": {
39-
"github_personal_access_token": "<GITHUB_PERSONAL_ACCESS_TOKEN>"
45+
"github_personal_access_token": "your_token_here"
46+
}
4047
}
4148
}
42-
},
49+
}
50+
```
51+
52+
Get token: `gh auth token` or [github.com/settings/tokens](https://github.com/settings/tokens)
53+
54+
## 📖 Usage Examples
55+
56+
Once configured, you can use natural language commands in Zed's AI chat:
57+
58+
### Repository Operations
59+
60+
- "Show me my GitHub repositories"
61+
- "List files in the src directory of my main project"
62+
- "Create a new repository called 'my-awesome-project'"
63+
64+
### File Management
65+
66+
- "Create a README.md with installation instructions"
67+
- "Update the version in package.json to 2.0.0"
68+
- "Show me the contents of the main.rs file"
69+
70+
### Issue & PR Management
71+
72+
- "Create an issue about the login bug I found"
73+
- "Show me all open pull requests waiting for review"
74+
- "List issues labeled 'bug' in my repository"
75+
76+
### Code Search & Analysis
77+
78+
- "Find all functions containing 'authenticate' in this repo"
79+
- "Show me security vulnerabilities in my projects"
80+
- "Search for React components in public repositories"
81+
82+
### CI/CD & Workflows
83+
84+
- "Check the status of my latest GitHub Actions run"
85+
- "Why did my last build fail?"
86+
- "Create a new release for version 1.5.0"
87+
88+
## 🤝 Contributing
89+
90+
1. Fork the repository
91+
2. Create a feature branch: `git checkout -b feature/amazing-feature`
92+
3. Commit your changes: `git commit -m 'Add amazing feature'`
93+
4. Push to the branch: `git push origin feature/amazing-feature`
94+
5. Open a Pull Request
95+
96+
### Development Setup
97+
98+
```bash
99+
git clone https://github.com/LoamStudios/zed-mcp-server-github.git
100+
cd zed-mcp-server-github
101+
cargo build --release
102+
chmod +x wrappers/github-mcp-wrapper.sh # macOS/Linux
103+
./wrappers/github-mcp-wrapper.sh --validate # Test setup
43104
```
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
{
2-
/// Your GitHub Personal Access Token (optional if GitHub CLI is installed and authenticated)
3-
/// If not provided, the extension will attempt to use `gh auth token`
4-
"github_personal_access_token": null
2+
// Option 1: Automatic Authentication (Recommended) ⭐
3+
// Uses GitHub CLI - no hardcoded tokens required!
4+
// Setup: gh auth login
5+
"context_servers": {
6+
"mcp-server-github": {
7+
"source": "extension",
8+
"settings": {
9+
"use_wrapper_script": true
10+
}
11+
}
12+
}
13+
}
14+
// OR
15+
{
16+
// Option 2: Direct Token Configuration
17+
// Get token: gh auth token
18+
// Or create at: https://github.com/settings/tokens
19+
"context_servers": {
20+
"mcp-server-github": {
21+
"source": "extension",
22+
"settings": {
23+
"github_personal_access_token": "ghp_your_token_here"
24+
}
25+
}
26+
}
527
}

configuration/installation_instructions.md

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

docs/configuration.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# GitHub MCP Extension Configuration
2+
3+
## Quick Start (Recommended) ⭐
4+
5+
1. **Install GitHub CLI**: `brew install gh`
6+
2. **Authenticate**: `gh auth login`
7+
3. **Configure Zed**:
8+
9+
```json
10+
{
11+
"context_servers": {
12+
"mcp-server-github": {
13+
"source": "extension",
14+
"settings": {
15+
"use_wrapper_script": true
16+
}
17+
}
18+
}
19+
}
20+
```
21+
22+
That's it! The extension automatically handles authentication using your GitHub CLI credentials.
23+
24+
## Alternative: Direct Token
25+
26+
If you prefer not to use GitHub CLI:
27+
28+
1. **Get token**: `gh auth token` or create at [github.com/settings/tokens](https://github.com/settings/tokens)
29+
2. **Configure Zed**:
30+
31+
```json
32+
{
33+
"context_servers": {
34+
"mcp-server-github": {
35+
"source": "extension",
36+
"settings": {
37+
"github_personal_access_token": "ghp_your_token_here"
38+
}
39+
}
40+
}
41+
}
42+
```
43+
44+
## Benefits of GitHub CLI Approach
45+
46+
**No hardcoded tokens** in settings
47+
**Automatic token refresh**
48+
**Zero dependencies** - uses system shell
49+
**Cross-platform** - works on macOS, Linux, Windows
50+
**Secure** - tokens managed by GitHub CLI
51+
52+
## Authentication Methods
53+
54+
The wrapper tries these in order:
55+
56+
1. **GitHub CLI**: `gh auth token`
57+
2. **Environment variables**: `GITHUB_TOKEN`, `GITHUB_PERSONAL_ACCESS_TOKEN`
58+
3. **Token files**: `~/.config/gh/hosts.yml`, `~/.github_token`
59+
60+
## Troubleshooting
61+
62+
**"No GitHub token found"**
63+
```bash
64+
gh auth login
65+
```
66+
67+
**"Wrapper script not found"**
68+
- Ensure `use_wrapper_script: true` is set
69+
- Extension auto-detects wrapper scripts in `wrappers/` folder
70+
71+
**Need to validate setup?**
72+
```bash
73+
./wrappers/github-mcp-wrapper.sh --validate # macOS/Linux
74+
.\wrappers\github-mcp-wrapper.ps1 -Validate # Windows
75+
```
76+
77+
## Cross-Platform Support
78+
79+
- **macOS/Linux**: Uses Bash (`wrappers/github-mcp-wrapper.sh`)
80+
- **Windows**: Uses PowerShell (`wrappers/github-mcp-wrapper.ps1`)
81+
- **Fallback**: Node.js (`wrappers/github-mcp-wrapper.js`)
82+
83+
Choose the method that works best for you!

0 commit comments

Comments
 (0)