Add per-login MCP OAuth client registration selection (#38052)

## What changed

- Add `--oauth-client-registration` with `auto` and `dcr` choices to `codex mcp add` and `codex mcp login`.
- Add the equivalent optional `clientRegistration` field to `mcpServer/oauth/login` and the generated protocol schemas.
- Keep automatic dynamic client registration as the default, prefer a configured OAuth client ID when present, and apply the selection only to the current login without persisting it in MCP configuration.

## Testing

- Cover dynamic registration and configured-client OAuth flows through the app server.
- Verify the CLI does not persist the per-login registration choice.

GitOrigin-RevId: 653a4a1054ff43c2c5d52ae863b6a96d21692a53
This commit is contained in:
stevenlee-oai authored and copyberry committed 2026-08-11 18:35:03 +00:00
1 parent 965b9f263a
commit 6dc3ac8721
22 files changed
+407 -65

No files matched your search

@@ -118,9 +118,14 @@ impl McpRequestProcessor {
let McpServerOauthLoginParams {
name,
thread_id,
client_registration,
scopes,
timeout_secs,
} = params;
let client_registration = match client_registration.unwrap_or_default() {
McpServerOauthClientRegistration::Auto => McpOAuthClientRegistration::Auto,
McpServerOauthClientRegistration::Dcr => McpOAuthClientRegistration::Dcr,
};
let auth = self.auth_manager.auth().await;
let (mcp_config, runtime_context) = match thread_id.as_deref() {
@@ -201,6 +206,7 @@ impl McpRequestProcessor {
env_http_headers,
&resolved_scopes.scopes,
server.oauth_client_id(),
client_registration,
server.oauth_resource.as_deref(),
timeout_secs,
mcp_config.mcp_oauth_callback_port,