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
{{ message }}
Repository navigation
[BUG] MCP OAuth Dynamic Client Registration: client_id is not persisted and strict RFC 9207 iss check breaks authorization #29620
When authenticating with an MCP server using OAuth 2.0 / 2.1 via /mcp auth <server>, Dynamic Client Registration (RFC 7591) and the callback handling encounter two interrelated issues:
Dynamic Client Registration credentials are not persisted across sessions:
When connecting to an MCP server without a pre-configured clientId, Gemini CLI successfully performs Dynamic Client Registration against the server's registration_endpoint using an ephemeral loopback redirect URI (e.g. http://localhost:<random-port>/oauth/callback). However, the resulting client_id and registration details are kept in memory only (config.clientId = clientRegistration.client_id) and are never saved to configuration (settings.json) or persistent token/client storage.
Consequently, every subsequent /mcp auth invocation or reconnection triggers a brand new DCR call, registering duplicate client records on the authorization server.
Unconditional RFC 9207 iss check causes dynamic registration to fail:
During the authorization callback, Gemini CLI strictly rejects responses without an iss parameter:
✕ Failed to authenticate with MCP server '<server>': Missing "iss" parameter in authorization response per RFC 9207
In packages/core/src/utils/oauth-flow.ts, startCallbackServer validates expectedIssuer which is populated from discovery metadata. Gemini CLI unconditionally rejects missing iss even when the Authorization Server metadata does not advertise authorization_response_iss_parameter_supported: true. Per RFC 9207 §2.4 and MCP Specification (2026-07-28), clients should proceed when authorization_response_iss_parameter_supported is absent or false.
What did you expect to happen?
When Dynamic Client Registration succeeds, the registered client information (client_id, client_secret if applicable, registration URI) should be cached or persisted so the client is reused rather than re-registering on every authentication attempt.
The RFC 9207 iss parameter check should respect authorization_response_iss_parameter_supported: true in the authorization server metadata. If absent or false, the client should not abort with Missing "iss" parameter in authorization response per RFC 9207.
Steps to Reproduce
Configure an MCP server in ~/.gemini/settings.json that uses dynamic discovery with an RFC 7591 registration endpoint:
What happened?
When authenticating with an MCP server using OAuth 2.0 / 2.1 via
/mcp auth <server>, Dynamic Client Registration (RFC 7591) and the callback handling encounter two interrelated issues:Dynamic Client Registration credentials are not persisted across sessions:
When connecting to an MCP server without a pre-configured
clientId, Gemini CLI successfully performs Dynamic Client Registration against the server'sregistration_endpointusing an ephemeral loopback redirect URI (e.g.http://localhost:<random-port>/oauth/callback). However, the resultingclient_idand registration details are kept in memory only (config.clientId = clientRegistration.client_id) and are never saved to configuration (settings.json) or persistent token/client storage.Consequently, every subsequent
/mcp authinvocation or reconnection triggers a brand new DCR call, registering duplicate client records on the authorization server.Unconditional RFC 9207
isscheck causes dynamic registration to fail:During the authorization callback, Gemini CLI strictly rejects responses without an
issparameter:In
packages/core/src/utils/oauth-flow.ts,startCallbackServervalidatesexpectedIssuerwhich is populated from discovery metadata. Gemini CLI unconditionally rejects missingisseven when the Authorization Server metadata does not advertiseauthorization_response_iss_parameter_supported: true. Per RFC 9207 §2.4 and MCP Specification (2026-07-28), clients should proceed whenauthorization_response_iss_parameter_supportedis absent or false.What did you expect to happen?
client_id,client_secretif applicable, registration URI) should be cached or persisted so the client is reused rather than re-registering on every authentication attempt.issparameter check should respectauthorization_response_iss_parameter_supported: truein the authorization server metadata. If absent or false, the client should not abort withMissing "iss" parameter in authorization response per RFC 9207.Steps to Reproduce
~/.gemini/settings.jsonthat uses dynamic discovery with an RFC 7591 registration endpoint:/mcp auth my-server.iss, it fails withMissing "iss" parameter in authorization response per RFC 9207./mcp auth my-servercreates another new client via DCR rather than reusing the previous registration.Client Information
Client Information
@google/gemini-cli@0.62.0Additional Context