Repository navigation
Description
Problem
Custom HTTP MCP servers currently rely on static, long-lived API keys or tokens stored in GitHub Secrets and injected via headers: in workflow frontmatter. This has significant security and operational drawbacks:
- Long-lived secrets — must be stored indefinitely and manually rotated
- No identity context — MCP server receives an opaque token with no repo/actor/workflow information
- Secret sprawl — each custom MCP server requires its own stored secret
The request is to support auth.type: github-oidc for custom HTTP MCP servers so the gateway handles OIDC token acquisition and refresh transparently, eliminating stored secrets entirely.
Source: github/gh-aw#23566
Analysis
The feature has been implemented in PR #2878. The following components are involved:
internal/oidc/provider.go — New package that:
- Acquires JWTs from
ACTIONS_ID_TOKEN_REQUEST_URLwith the configuredaudienceparameter - Caches tokens per audience and proactively refreshes them 60 seconds before expiry (handling the GitHub Actions 5-minute token lifetime)
- Extracts the
expclaim from the JWT without signature verification; falls back to a 5-minute TTL if parsing fails
internal/config/config_stdin.go — Config schema changes:
StdinServerConfiggains anAuth *AuthConfigfield (json:"auth,omitempty")stripExtensionFieldsForValidation()stripsauthbefore upstream schema validation (extension field)convertStdinServerConfig()copies theAuthconfig toServerConfig, defaultingAudienceto the server URL when not specified
internal/launcher/launcher.go — Runtime wiring:
New()readsACTIONS_ID_TOKEN_REQUEST_URL+ACTIONS_ID_TOKEN_REQUEST_TOKENfrom env and initialisesoidc.ProviderGetOrLaunch()passes the provider and audience tomcp.NewHTTPConnection()for servers withauth.type: github-oidc- Emits a clear error log if a server requires OIDC but the env vars are absent
internal/config/config_core.go — AuthConfig struct definition (type + audience fields).
Proposed Solution
The core implementation is done. Remaining follow-up items to consider:
-
Integration test coverage — Add an integration test that configures an HTTP MCP server with
auth.type: github-oidcand a mock OIDC endpoint, verifying that requests carry a freshAuthorization: Bearer <token>header and that tokens are refreshed before expiry. -
TOML config support — Verify or add support for the
authblock in the TOML configuration format (config.toml), not just the JSON stdin format. Checkinternal/config/config_core.goandLoadFromFile()paths. -
Schema update — Confirm that the
authobject is injected into the upstream MCP Gateway JSON schema (or documented as a gateway extension) so tooling and editors surface it correctly. -
Documentation — Update
README.mdandAGENTS.mdwith theauth.type: github-oidcconfiguration option, the requiredpermissions: { id-token: write }workflow permission, and an example configuration snippet. -
Error UX — The current error message when
ACTIONS_ID_TOKEN_REQUEST_URLis absent is logged but the gateway continues. Consider whether a startup failure is more appropriate whenauth.type: github-oidcis configured but the env vars are missing.
Testing
# Example workflow snippet to verify end-to-end
permissions:
id-token: write
mcp-servers:
my-server:
url: "(myserver.example.com/redacted)
auth:
type: github-oidc
audience: "(myserver.example.com/redacted)"
allowed: ["*"]- Confirm gateway requests to
my-serverincludeAuthorization: Bearer <jwt>with a token whoseaudclaim matches the configured audience. - Confirm the gateway fetches a fresh token when the cached one is within 60 seconds of expiry.
- Confirm a clear error is surfaced (not a silent failure) when
ACTIONS_ID_TOKEN_REQUEST_URLis absent.
Generated by Gateway Issue Dispatcher · ◷
Activity