|
1 | 1 | # Install GitHub MCP Server in Cursor |
2 | 2 |
|
3 | 3 | ## Prerequisites |
| 4 | +1. Cursor IDE installed (latest version) |
| 5 | +2. [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) with appropriate scopes |
| 6 | +3. For local installation: [Docker](https://www.docker.com/) installed and running |
4 | 7 |
|
5 | | -1. Cursor IDE installed |
6 | | -2. [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) |
7 | | -3. [Docker](https://www.docker.com/) installed and running |
| 8 | +## Remote Server Setup (Recommended) |
8 | 9 |
|
9 | | -## Installation Steps |
| 10 | +The remote GitHub MCP server is hosted by GitHub at `https://api.githubcopilot.com/mcp/` and supports both HTTP and SSE protocols. Cursor currently supports remote servers with PAT authentication. |
| 11 | + |
| 12 | +### SSE Configuration |
| 13 | +As of Cursor v0.48.0, Cursor supports SSE servers directly: |
| 14 | + |
| 15 | +```json |
| 16 | +{ |
| 17 | + "mcpServers": { |
| 18 | + "github": { |
| 19 | + "url": "https://api.githubcopilot.com/mcp/", |
| 20 | + "headers": { |
| 21 | + "Authorization": "Bearer YOUR_GITHUB_PAT" |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +**Note**: If your Cursor version doesn't support direct SSE, you may need to use a proxy tool like `mcp-remote`. |
10 | 29 |
|
11 | | -1. Go to `Cursor Settings` → `Tools & Integrations` → Click `Add Custom MCP` or `New MCP Server` |
12 | | -2. Use the following `mcp.json` structure: |
| 30 | +## Local Server Setup |
13 | 31 |
|
| 32 | +### Option 1: Docker (Recommended) |
14 | 33 | ```json |
15 | 34 | { |
16 | 35 | "mcpServers": { |
|
25 | 44 | "ghcr.io/github/github-mcp-server" |
26 | 45 | ], |
27 | 46 | "env": { |
28 | | - "GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_pat" |
| 47 | + "GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT" |
29 | 48 | } |
30 | 49 | } |
31 | 50 | } |
32 | 51 | } |
33 | 52 | ``` |
34 | 53 |
|
35 | | -3. Replace `your_github_pat` with your actual GitHub PAT |
36 | | -4. Restart Cursor for changes to apply |
| 54 | +### Option 2: NPX |
| 55 | +```json |
| 56 | +{ |
| 57 | + "mcpServers": { |
| 58 | + "github": { |
| 59 | + "command": "npx", |
| 60 | + "args": ["-y", "@modelcontextprotocol/server-github"], |
| 61 | + "env": { |
| 62 | + "GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT" |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
37 | 68 |
|
38 | | -## Important Security Notes |
| 69 | +**Note**: The npm package has a deprecation notice but remains functional. |
39 | 70 |
|
40 | | -⚠️ **Environment Variable Limitations**: Environment-variable interpolation (using a `$GITHUB_PAT` variable) is not supported in Cursor. |
| 71 | +## Installation Steps |
41 | 72 |
|
42 | | -### Security Best Practices |
| 73 | +### Via Cursor Settings UI |
| 74 | +1. Open Cursor |
| 75 | +2. Navigate to **Settings** → **Tools & Integrations** → **MCP** |
| 76 | +3. Click **"+ Add new global MCP server"** |
| 77 | +4. This opens `~/.cursor/mcp.json` in the editor |
| 78 | +5. Add your chosen configuration from above |
| 79 | +6. Save the file |
| 80 | +7. Restart Cursor |
| 81 | + |
| 82 | +### Manual Configuration |
| 83 | +1. Create or edit the configuration file: |
| 84 | + - **Global (all projects)**: `~/.cursor/mcp.json` |
| 85 | + - **Project-specific**: `.cursor/mcp.json` in project root |
| 86 | +2. Add your chosen configuration |
| 87 | +3. Save the file |
| 88 | +4. Restart Cursor completely |
| 89 | + |
| 90 | +## Security Best Practices |
| 91 | + |
| 92 | +### Configuration Note |
| 93 | +Cursor's current MCP implementation requires tokens to be specified directly in the configuration file. We recommend taking extra security precautions: |
| 94 | + |
| 95 | +### File Protection |
| 96 | +```bash |
| 97 | +# Secure the configuration file |
| 98 | +chmod 600 ~/.cursor/mcp.json |
| 99 | + |
| 100 | +# For project-specific config |
| 101 | +chmod 600 .cursor/mcp.json |
| 102 | + |
| 103 | +# Verify permissions |
| 104 | +ls -la ~/.cursor/mcp.json |
| 105 | +``` |
43 | 106 |
|
44 | | -- **File Permissions**: Lock down file permissions for the configuration file: |
45 | | - ```bash |
46 | | - chmod 600 ~/.codeium/windsurf/mcp.json |
47 | | - ``` |
48 | | -- **Version Control**: Avoid committing configuration files with tokens to version control |
49 | | -- **Token Scope**: Limit PAT scopes to necessary repositories and tools only |
50 | | -- **Token Rotation**: Regularly rotate your GitHub Personal Access Tokens |
| 107 | +### Token Security |
| 108 | +- Create PATs with minimum required scopes: |
| 109 | + - `repo` - For repository operations |
| 110 | + - `read:packages` - For Docker image pull (local setup) |
| 111 | + - Additional scopes based on tools you need |
| 112 | +- Use separate PATs for different projects |
| 113 | +- Regularly rotate tokens |
| 114 | +- Never commit configuration files to version control |
51 | 115 |
|
52 | | -## Configuration File Location |
| 116 | +## Configuration Details |
53 | 117 |
|
54 | | -The MCP configuration is typically stored at: |
55 | | -- `~/.codeium/windsurf/mcp.json` |
| 118 | +- **File paths**: |
| 119 | + - Global: `~/.cursor/mcp.json` |
| 120 | + - Project: `.cursor/mcp.json` |
| 121 | +- **Scope**: Both global and project-specific configurations supported |
| 122 | +- **Format**: Must be valid JSON (use a linter to verify) |
56 | 123 |
|
57 | | -## Troubleshooting |
| 124 | +## Verification |
58 | 125 |
|
59 | | -- Ensure Docker is running and accessible |
60 | | -- Verify your GitHub PAT is valid and has required permissions |
61 | | -- Check that the JSON configuration is valid |
62 | | -- Restart Cursor after making configuration changes |
63 | | -- Review Cursor logs for any MCP server startup errors |
64 | | -- Ensure the GitHub MCP Server Docker image is accessible (`ghcr.io/github/github-mcp-server`) |
| 126 | +After installation: |
| 127 | +1. Restart Cursor completely |
| 128 | +2. Open Settings → Tools & Integrations → MCP |
| 129 | +3. Look for green dot next to your server name |
| 130 | +4. In chat/composer, check "Available Tools" |
| 131 | +5. Test with: "List my GitHub repositories" |
65 | 132 |
|
66 | | -## Alternative Setup |
| 133 | +## Troubleshooting |
67 | 134 |
|
68 | | -If you prefer to manually edit the configuration file, you can directly edit the `mcp.json` file at the location mentioned above with the same JSON structure. |
| 135 | +### Remote Server Issues |
| 136 | +- **SSE not working**: Ensure you're using Cursor v0.48.0 or later |
| 137 | +- **Authentication failures**: Verify PAT has correct scopes |
| 138 | +- **Connection errors**: Check firewall/proxy settings |
| 139 | + |
| 140 | +### Local Server Issues |
| 141 | +- **Docker errors**: Ensure Docker Desktop is running |
| 142 | +- **Image pull failures**: Try `docker logout ghcr.io` then retry |
| 143 | +- **NPX failures**: Clear npm cache with `npm cache clean --force` |
| 144 | + |
| 145 | +### General Issues |
| 146 | +- **MCP not loading**: Restart Cursor completely after configuration |
| 147 | +- **Invalid JSON**: Validate with [jsonlint.com](https://jsonlint.com) |
| 148 | +- **Tools not appearing**: Check server shows green dot in MCP settings |
| 149 | +- **Check logs**: Look for MCP-related errors in Cursor logs |
| 150 | + |
| 151 | +## Important Notes |
| 152 | + |
| 153 | +- **Official repository**: [github/github-mcp-server](https://github.com/github/github-mcp-server) |
| 154 | +- **Remote server URL**: `https://api.githubcopilot.com/mcp/` |
| 155 | +- **Docker image**: `ghcr.io/github/github-mcp-server` |
| 156 | +- **npm package**: `@modelcontextprotocol/server-github` (deprecated but functional) |
| 157 | +- **Cursor specifics**: Supports both project and global configurations, uses `mcpServers` key |
0 commit comments