You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add native GitHub App authentication as an alternative to Personal
Access Tokens. The server can now authenticate using App ID, private
key, and installation ID to automatically generate and refresh
installation tokens.
- Add `pkg/github/appauth` package with JWT generation and installation
token management using only the standard library
- Auto-refresh tokens before expiry (5-minute buffer on 1-hour tokens)
- Support private key via env var (GITHUB_APP_PRIVATE_KEY) or file path
(GITHUB_APP_PRIVATE_KEY_PATH)
- Handle literal `\n` in env var PEM keys
- Add comprehensive tests (13 tests covering key parsing, JWT generation,
token caching, refresh, round-trip, and error handling)
Closes#1333
Copy file name to clipboardExpand all lines: README.md
+74Lines changed: 74 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -239,6 +239,80 @@ To keep your GitHub PAT secure and reusable across different MCP hosts:
239
239
240
240
</details>
241
241
242
+
### GitHub App Authentication
243
+
244
+
As an alternative to Personal Access Tokens, the MCP server supports authenticating as a [GitHub App](https://docs.github.com/en/apps) installation. This is useful for organizations that want to grant scoped, short-lived access without relying on individual PATs.
245
+
246
+
The server automatically generates JWTs, fetches installation tokens, and refreshes them before expiry (installation tokens are valid for 1 hour).
247
+
248
+
#### Required Environment Variables
249
+
250
+
| Variable | Description |
251
+
|---|---|
252
+
|`GITHUB_APP_ID`| The GitHub App ID |
253
+
|`GITHUB_APP_INSTALLATION_ID`| The installation ID of the GitHub App |
254
+
|`GITHUB_APP_PRIVATE_KEY`| The PEM-encoded private key (inline, `\n` for newlines) |
255
+
|`GITHUB_APP_PRIVATE_KEY_PATH`| Path to the private key file (alternative to inline) |
256
+
257
+
Either `GITHUB_APP_PRIVATE_KEY` or `GITHUB_APP_PRIVATE_KEY_PATH` must be set, but not both. When all three required variables (`GITHUB_APP_ID`, `GITHUB_APP_INSTALLATION_ID`, and a private key) are set, the server uses GitHub App authentication instead of a PAT. `GITHUB_PERSONAL_ACCESS_TOKEN` is not required in this case.
returnerrors.New("GITHUB_PERSONAL_ACCESS_TOKEN not set (or configure GitHub App auth with GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY/GITHUB_APP_PRIVATE_KEY_PATH, and GITHUB_APP_INSTALLATION_ID)")
39
48
}
40
49
41
50
// If you're wondering why we're not using viper.GetStringSlice("toolsets"),
return0, nil, 0, errors.New("incomplete GitHub App auth config: GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID, and GITHUB_APP_PRIVATE_KEY or GITHUB_APP_PRIVATE_KEY_PATH are all required")
0 commit comments