Gemini CLI
Gemini CLI supports remote Streamable HTTP MCP servers and automatic OAuth discovery. With JamRelay, DCR is the recommended OAuth path.
Recommended setup — OAuth discovery + DCR
Server:
dotenv
MCP_OAUTH_OWNER_SECRET=<STRONG_OWNER_SECRET>
MCP_OAUTH_DCR_ENABLED=trueAdd JamRelay:
bash
gemini mcp add --transport http jamrelay https://mcp.example.com/mcpThen authenticate:
text
/mcp auth jamrelayGemini CLI can:
- receive JamRelay's
401challenge; - discover protected-resource and authorization-server metadata;
- register itself dynamically;
- open the browser for owner approval;
- use a localhost callback on a random port;
- exchange the PKCE authorization code;
- store and refresh its tokens.
JamRelay accepts loopback callbacks registered by native clients and returns the RFC 9207 iss parameter that Gemini CLI requires.
Bearer fallback
For debugging, Gemini CLI can also send a static Bearer header:
dotenv
MCP_AUTH_MODE=bearer
MCP_API_KEY=<STRONG_RANDOM_VALUE>bash
gemini mcp add --transport http --header "Authorization: Bearer YOUR_MCP_API_KEY" jamrelay https://mcp.example.com/mcpOAuth is preferable for normal remote use because it gives the client expiring access tokens and rotating refresh tokens rather than one long-lived shared key.
Verify
text
What is currently playing on Spotify?