Skip to content

Add MCP server scopes config and use it as fallback for OAuth login#9647

Merged
gpeal merged 2 commits intomainfrom
codex/add-scopes-parameter-to-mcp_server-config
Jan 26, 2026
Merged

Add MCP server scopes config and use it as fallback for OAuth login#9647
gpeal merged 2 commits intomainfrom
codex/add-scopes-parameter-to-mcp_server-config

Conversation

@blevy-oai
Copy link
Contributor

Motivation

  • Allow MCP OAuth flows to request scopes defined in config.toml instead of requiring users to always pass --scopes on the CLI. CLI/remote parameters should still override config values.

Description

  • Add optional scopes: Option<Vec<String>> to McpServerConfig and RawMcpServerConfig, and propagate it through deserialization and the built config types.
  • Serialize scopes into the MCP server TOML via serialize_mcp_server_table in core/src/config/edit.rs and include scopes in the generated config schema (core/config.schema.json).
  • CLI: update codex-rs/cli/src/mcp_cmd.rs run_login to fall back to server.scopes when the --scopes flag is empty, with explicit CLI scopes still taking precedence.
  • App server: update codex-rs/app-server/src/codex_message_processor.rs mcp_server_oauth_login to use params.scopes.or_else(|| server.scopes.clone()) so the RPC path also respects configured scopes.
  • Update many test fixtures to initialize the new scopes field (set to None) so test code builds with the new struct field.

Testing

  • Ran config tooling and formatters: just write-config-schema (succeeded), just fmt (succeeded), and just fix -p codex-core, just fix -p codex-cli, just fix -p codex-app-server (succeeded where applicable).
  • Ran unit tests for the CLI: cargo test -p codex-cli (passed).
  • Ran unit tests for core: cargo test -p codex-core (ran; many tests passed but several failed, including model refresh/403-related tests, shell snapshot/timeouts, and several unified_exec expectations).
  • Ran app-server tests: cargo test -p codex-app-server (ran; many integration-suite tests failed due to mocked/remote HTTP 401/403 responses and wiremock expectations).

If you want, I can split the tests into smaller focused runs or help debug the failing integration tests (they appear to be unrelated to the config change and stem from external HTTP/mocking behaviors encountered during the test runs).


Codex Task

@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@blevy-oai
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jan 22, 2026
@etraut-openai etraut-openai added the oai PRs contributed by OpenAI employees label Jan 22, 2026
@blevy-oai
Copy link
Contributor Author

With a config.toml of

[mcp_servers.mcp-auth-test]
enabled = true
url = "<my url>"
scopes = ["api://.../all", "offline_access"]

I'm able to codex mcp login mcp-auth-test without problems whereas prior to this change codex mcp login mcp-auth-test fails on the redirect flow because no scopes are passed (the --scopes was the only way to pass this info previously which makes the login flow more annoying/ frictionful for users)

@blevy-oai blevy-oai marked this pull request as ready for review January 22, 2026 04:25
@blevy-oai blevy-oai self-assigned this Jan 22, 2026
@blevy-oai blevy-oai requested a review from bolinfest January 26, 2026 19:41
@bolinfest bolinfest requested a review from gpeal January 26, 2026 19:48
@gpeal gpeal merged commit bdc4742 into main Jan 26, 2026
32 checks passed
@gpeal gpeal deleted the codex/add-scopes-parameter-to-mcp_server-config branch January 26, 2026 22:13
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

codex oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants