|
| 1 | +# MCP GitHub Actions |
| 2 | + |
| 3 | +A Deno-based MCP (Model Context Protocol) service that helps you securely reference GitHub Actions by providing: |
| 4 | + |
| 5 | +- Latest version lookup for any GitHub Action |
| 6 | +- Commit SHA retrieval for specific version tags |
| 7 | +- Immutability status checking for releases |
| 8 | +- Ready-to-use SHA-pinned references |
| 9 | + |
| 10 | +## Why Use This? |
| 11 | + |
| 12 | +GitHub Actions referenced by tag (e.g., `actions/checkout@v4`) can be vulnerable to supply chain attacks if the tag is moved to point to malicious code. This MCP service helps you: |
| 13 | + |
| 14 | +1. **Find the commit SHA** for any action version |
| 15 | +2. **Check if a release is immutable** (protected from modification) |
| 16 | +3. **Get secure references** in the format `owner/repo@sha # version` |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +### Prerequisites |
| 21 | + |
| 22 | +- [Deno](https://deno.land/) 2.x or later |
| 23 | + |
| 24 | +### Setup with Claude Desktop |
| 25 | + |
| 26 | +Add to your Claude Desktop configuration (`claude_desktop_config.json`): |
| 27 | + |
| 28 | +```json |
| 29 | +{ |
| 30 | + "mcpServers": { |
| 31 | + "github-actions": { |
| 32 | + "command": "deno", |
| 33 | + "args": [ |
| 34 | + "run", |
| 35 | + "--allow-net", |
| 36 | + "--allow-env", |
| 37 | + "/path/to/mcp-github-actions/main.ts" |
| 38 | + ], |
| 39 | + "env": { |
| 40 | + "GITHUB_TOKEN": "your-github-token-optional" |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +### Setup with Claude Code CLI |
| 48 | + |
| 49 | +```bash |
| 50 | +claude mcp add github-actions -- deno run --allow-net --allow-env /path/to/mcp-github-actions/main.ts |
| 51 | +``` |
| 52 | + |
| 53 | +### Setup with Docker |
| 54 | + |
| 55 | +The service is available as a Docker image using stdio transport. |
| 56 | + |
| 57 | +**Pull the image:** |
| 58 | + |
| 59 | +```bash |
| 60 | +docker pull ghcr.io/tripletex/mcp-github-action:latest |
| 61 | +``` |
| 62 | + |
| 63 | +**Run directly:** |
| 64 | + |
| 65 | +```bash |
| 66 | +docker run --rm -i -e GITHUB_TOKEN ghcr.io/tripletex/mcp-github-action:latest |
| 67 | +``` |
| 68 | + |
| 69 | +**Claude Desktop configuration:** |
| 70 | + |
| 71 | +```json |
| 72 | +{ |
| 73 | + "mcpServers": { |
| 74 | + "github-actions": { |
| 75 | + "command": "docker", |
| 76 | + "args": [ |
| 77 | + "run", |
| 78 | + "--rm", |
| 79 | + "-i", |
| 80 | + "-e", "GITHUB_TOKEN", |
| 81 | + "ghcr.io/tripletex/mcp-github-action:latest" |
| 82 | + ], |
| 83 | + "env": { |
| 84 | + "GITHUB_TOKEN": "your-github-token-optional" |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +**MCP Gateway configuration:** |
| 92 | + |
| 93 | +```yaml |
| 94 | +mcp_services: |
| 95 | + - name: "github-actions" |
| 96 | + alias: "github-actions" |
| 97 | + type: "stdio" |
| 98 | + command: |
| 99 | + - docker |
| 100 | + - run |
| 101 | + - --rm |
| 102 | + - -i |
| 103 | + - -e |
| 104 | + - GITHUB_TOKEN |
| 105 | + - ghcr.io/tripletex/mcp-github-action:latest |
| 106 | + timeout: 30 |
| 107 | +``` |
| 108 | +
|
| 109 | +## Usage |
| 110 | +
|
| 111 | +Once configured, ask Claude to look up GitHub Actions: |
| 112 | +
|
| 113 | +**Example prompts:** |
| 114 | +
|
| 115 | +- "Look up the latest version of actions/checkout" |
| 116 | +- "Get the secure reference for actions/setup-node@v4" |
| 117 | +- "Check if actions/cache@v4.2.0 is immutable" |
| 118 | +- "List all versions of actions/upload-artifact" |
| 119 | +
|
| 120 | +## Tool: `lookup_action` |
| 121 | + |
| 122 | +### Parameters |
| 123 | + |
| 124 | +| Parameter | Type | Required | Description | |
| 125 | +|-----------|------|----------|-------------| |
| 126 | +| `action` | string | Yes | Action reference (e.g., `actions/checkout` or `actions/checkout@v4`) | |
| 127 | +| `include_all_versions` | boolean | No | List all available versions (default: false) | |
| 128 | + |
| 129 | +### Example Output |
| 130 | + |
| 131 | +``` |
| 132 | +Action: actions/checkout |
| 133 | + |
| 134 | +Latest Version: v4.2.2 |
| 135 | + Commit SHA: 11bd71901bbe5b1630ceea73d27597364c9af683 |
| 136 | + Immutable: Yes |
| 137 | + Published: 2024-10-23T14:05:06Z |
| 138 | + |
| 139 | +Recommended Usage (SHA-pinned): |
| 140 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 141 | + |
| 142 | +Security Notes: |
| 143 | + - This release is immutable - the tag and assets are protected from modification. |
| 144 | + - SHA-pinned references prevent supply chain attacks by ensuring you always use the exact same code. |
| 145 | +``` |
| 146 | +
|
| 147 | +## Authentication |
| 148 | +
|
| 149 | +### Without Token (Default) |
| 150 | +
|
| 151 | +- Works for public repositories only |
| 152 | +- Rate limit: 60 requests/hour |
| 153 | +
|
| 154 | +### With Token (Recommended) |
| 155 | +
|
| 156 | +Set the `GITHUB_TOKEN` environment variable: |
| 157 | +
|
| 158 | +- Works for **private repositories** |
| 159 | +- Rate limit: 5,000 requests/hour |
| 160 | +- Required for organization private actions |
| 161 | +
|
| 162 | +### Multi-Organization Support |
| 163 | +
|
| 164 | +For accessing private repositories across multiple organizations, configure org-specific tokens: |
| 165 | +
|
| 166 | +```bash |
| 167 | +# Org-specific tokens (format: GITHUB_TOKEN_<ORG_NAME>) |
| 168 | +# Hyphens in org names become underscores, all uppercase |
| 169 | +GITHUB_TOKEN_MY_ORG=ghp_xxx... # For My-Org |
| 170 | +GITHUB_TOKEN_OTHER_ORG=ghp_yyy... # For Other-Org |
| 171 | +GITHUB_TOKEN=ghp_zzz... # Fallback for public repos |
| 172 | +``` |
| 173 | + |
| 174 | +**Token resolution order:** |
| 175 | +1. Org-specific token (`GITHUB_TOKEN_<ORG>`) |
| 176 | +2. Fallback token (`GITHUB_TOKEN`) |
| 177 | +3. Unauthenticated (public repos only) |
| 178 | + |
| 179 | +**Supported token types and required permissions:** |
| 180 | + |
| 181 | +| Token Type | Required Permissions | Notes | |
| 182 | +|------------|---------------------|-------| |
| 183 | +| Fine-grained PAT | `Contents: Read` + `Metadata: Read` | Recommended - scoped to specific repos/orgs | |
| 184 | +| Classic PAT | `repo` scope | Broader access - use only if fine-grained isn't suitable | |
| 185 | +| GitHub App | `Contents: Read` | Recommended for organizations | |
| 186 | + |
| 187 | +> **Note:** For private repositories, the token must have read access to repository contents. Without proper permissions, you'll receive a 404 error when looking up private actions. |
| 188 | +
|
| 189 | +**Example Claude Desktop config with multi-org:** |
| 190 | + |
| 191 | +```json |
| 192 | +{ |
| 193 | + "mcpServers": { |
| 194 | + "github-actions": { |
| 195 | + "command": "deno", |
| 196 | + "args": [ |
| 197 | + "run", |
| 198 | + "--allow-net", |
| 199 | + "--allow-env", |
| 200 | + "/path/to/mcp-github-actions/main.ts" |
| 201 | + ], |
| 202 | + "env": { |
| 203 | + "GITHUB_TOKEN_MY_ORG": "ghs_xxx...", |
| 204 | + "GITHUB_TOKEN_OTHER_ORG": "ghs_yyy...", |
| 205 | + "GITHUB_TOKEN": "ghp_zzz..." |
| 206 | + } |
| 207 | + } |
| 208 | + } |
| 209 | +} |
| 210 | +``` |
| 211 | + |
| 212 | +## Development |
| 213 | + |
| 214 | +```bash |
| 215 | +# Run the server |
| 216 | +deno task start |
| 217 | + |
| 218 | +# Run with watch mode (auto-reload) |
| 219 | +deno task dev |
| 220 | + |
| 221 | +# Type check |
| 222 | +deno task check |
| 223 | + |
| 224 | +# Lint |
| 225 | +deno task lint |
| 226 | + |
| 227 | +# Format |
| 228 | +deno task fmt |
| 229 | + |
| 230 | +# Compile to binary |
| 231 | +deno task compile |
| 232 | +``` |
| 233 | + |
| 234 | +## Security Best Practices |
| 235 | + |
| 236 | +1. **Always use SHA-pinned references** in production workflows |
| 237 | +2. **Check immutability status** - immutable releases cannot be modified |
| 238 | +3. **Add version comments** for maintainability: `@sha # v4.2.0` |
| 239 | +4. **Use Dependabot/Renovate** to keep SHA references updated |
| 240 | + |
| 241 | +## References |
| 242 | + |
| 243 | +- [GitHub Immutable Releases](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases) |
| 244 | +- [Pinning GitHub Actions for Security](https://www.stepsecurity.io/blog/pinning-github-actions-for-enhanced-security-a-complete-guide) |
| 245 | +- [Model Context Protocol](https://modelcontextprotocol.io/) |
| 246 | + |
| 247 | +## License |
| 248 | + |
| 249 | +MIT |
0 commit comments