Lightweight coding agent that runs in your terminal
Rust
Prefer resource-specific scopes during MCP OAuth discovery (#54653)
Alex Zamoshchinb26b0a7a777b
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lockindex bafa7a7460..edcfc5590e 100644--- a/MODULE.bazel.lock+++ b/MODULE.bazel.lock@@ -1391,8 +1391,8 @@"git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4_process_security_environment_spec": "{\"dependencies\":[{\"name\":\"flatbuffers\",\"req\":\"25\"}],\"features\":{},\"strip_prefix\":\"core/generated/process_security_environment_specification\"}","git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4_sandbox_spec": "{\"dependencies\":[{\"name\":\"flatbuffers\",\"req\":\"25\"}],\"features\":{},\"strip_prefix\":\"core/generated/base_container_specification\"}","git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4_wxc_common": "{\"dependencies\":[{\"name\":\"base64\",\"req\":\"0.22\"},{\"name\":\"cidr\",\"req\":\"0.3.2\"},{\"name\":\"getrandom\",\"req\":\"0.2\"},{\"default_features\":true,\"features\":[],\"name\":\"mxc_config_contract\",\"optional\":false},{\"default_features\":true,\"features\":[],\"name\":\"mxc_schema_support\",\"optional\":true},{\"default_features\":true,\"features\":[],\"name\":\"mxc_telemetry\",\"optional\":false},{\"default_features\":true,\"features\":[],\"name\":\"nanvix_common\",\"optional\":true},{\"name\":\"schemars\",\"optional\":true,\"req\":\"0.8\"},{\"name\":\"semver\",\"req\":\"1\"},{\"default_features\":true,\"features\":[\"derive\"],\"name\":\"serde\",\"optional\":false,\"req\":\"1\"},{\"features\":[\"raw_value\"],\"name\":\"serde_json\",\"req\":\"1\"},{\"name\":\"serde_path_to_error\",\"req\":\"0.1\"},{\"name\":\"thiserror\",\"req\":\"2\"},{\"name\":\"unicode-general-category\",\"req\":\"1\"},{\"name\":\"url\",\"req\":\"2\"},{\"default_features\":true,\"features\":[\"v4\"],\"name\":\"uuid\",\"optional\":true,\"req\":\"1\"},{\"name\":\"widestring\",\"req\":\"1\",\"target\":\"cfg(target_os = \\\"windows\\\")\"},{\"default_features\":true,\"features\":[\"Win32_Foundation\",\"Win32_Globalization\",\"Win32_NetworkManagement_WindowsFirewall\",\"Win32_Networking_WinSock\",\"Win32_Security\",\"Win32_Security_Authorization\",\"Win32_Security_Credentials\",\"Win32_Security_Isolation\",\"Win32_Storage_FileSystem\",\"Win32_System_Com\",\"Win32_System_Console\",\"Win32_System_Diagnostics_Debug\",\"Win32_System_Diagnostics_Etw\",\"Win32_System_Diagnostics_ToolHelp\",\"Win32_System_Environment\",\"Win32_System_IO\",\"Win32_System_JobObjects\",\"Win32_System_LibraryLoader\",\"Win32_System_Memory\",\"Win32_System_Ole\",\"Win32_System_Pipes\",\"Win32_System_ProcessStatus\",\"Win32_System_Registry\",\"Win32_System_SystemInformation\",\"Win32_System_SystemServices\",\"Win32_System_Threading\",\"Win32_System_Time\",\"Win32_System_Variant\",\"Win32_System_WindowsProgramming\",\"Win32_UI_Shell\"],\"name\":\"windows\",\"optional\":false,\"req\":\"0.62\",\"target\":\"cfg(target_os = \\\"windows\\\")\"},{\"name\":\"windows-core\",\"req\":\"0.62\",\"target\":\"cfg(target_os = \\\"windows\\\")\"},{\"name\":\"winreg\",\"req\":\"0.55\",\"target\":\"cfg(target_os = \\\"windows\\\")\"},{\"name\":\"libc\",\"req\":\"0.2\",\"target\":\"cfg(unix)\"}],\"features\":{\"microvm\":[\"dep:nanvix_common\",\"dep:uuid\"],\"schema-gen\":[\"dep:mxc_schema_support\",\"dep:schemars\"]},\"strip_prefix\":\"core/wxc_common\"}",- "git+https://github.com/modelcontextprotocol/rust-sdk?rev=4048ac40e958fb1a7d614617a2ae8d26666ee2fa#4048ac40e958fb1a7d614617a2ae8d26666ee2fa_rmcp": "{\"dependencies\":[{\"default_features\":true,\"features\":[],\"name\":\"async-trait\",\"optional\":true,\"req\":\"0.1.89\"},{\"default_features\":true,\"features\":[],\"name\":\"base64\",\"optional\":true,\"req\":\"0.23\"},{\"default_features\":true,\"features\":[],\"name\":\"bytes\",\"optional\":true,\"req\":\"1\"},{\"name\":\"futures\",\"req\":\"0.3\"},{\"default_features\":true,\"features\":[],\"name\":\"hmac\",\"optional\":true,\"req\":\"0.13\"},{\"default_features\":true,\"features\":[],\"name\":\"http\",\"optional\":true,\"req\":\"1\"},{\"default_features\":true,\"features\":[],\"name\":\"http-body\",\"optional\":true,\"req\":\"1\"},{\"default_features\":true,\"features\":[],\"name\":\"http-body-util\",\"optional\":true,\"req\":\"0.1\"},{\"default_features\":true,\"features\":[\"client\",\"http1\"],\"name\":\"hyper\",\"optional\":true,\"req\":\"1\"},{\"default_features\":true,\"features\":[\"tokio\"],\"name\":\"hyper-util\",\"optional\":true,\"req\":\"0.1\"},{\"default_features\":true,\"features\":[\"serde\"],\"name\":\"indexmap\",\"optional\":false,\"req\":\"2\"},{\"default_features\":true,\"features\":[\"aws_lc_rs\"],\"name\":\"jsonwebtoken\",\"optional\":true,\"req\":\"11\"},{\"default_features\":false,\"features\":[],\"name\":\"oauth2\",\"optional\":true,\"req\":\"5.0\"},{\"default_features\":true,\"features\":[],\"name\":\"pastey\",\"optional\":true,\"req\":\"0.2.0\"},{\"name\":\"pin-project-lite\",\"req\":\"0.2\"},{\"default_features\":true,\"features\":[\"tokio1\"],\"name\":\"process-wrap\",\"optional\":true,\"req\":\"10.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rand\",\"optional\":true,\"req\":\"0.10\"},{\"default_features\":false,\"features\":[\"json\",\"stream\"],\"name\":\"reqwest\",\"optional\":true,\"req\":\"0.13.2\"},{\"default_features\":true,\"features\":[],\"name\":\"rmcp-macros\",\"optional\":true,\"req\":\"3.5.1\"},{\"default_features\":true,\"features\":[\"chrono04\"],\"name\":\"schemars\",\"optional\":true,\"req\":\"1.0\"},{\"default_features\":true,\"features\":[\"derive\",\"rc\"],\"name\":\"serde\",\"optional\":false,\"req\":\"1.0\"},{\"name\":\"serde_json\",\"req\":\"1.0\"},{\"default_features\":true,\"features\":[],\"name\":\"sha2\",\"optional\":true,\"req\":\"0.11\"},{\"default_features\":true,\"features\":[],\"name\":\"sse-stream\",\"optional\":true,\"req\":\"0.2.4\"},{\"name\":\"thiserror\",\"req\":\"2\"},{\"default_features\":true,\"features\":[\"sync\",\"macros\",\"rt\",\"time\"],\"name\":\"tokio\",\"optional\":false,\"req\":\"1\"},{\"default_features\":true,\"features\":[],\"name\":\"tokio-stream\",\"optional\":true,\"req\":\"0.1\"},{\"default_features\":true,\"features\":[],\"name\":\"tokio-util\",\"optional\":false,\"req\":\"0.7\"},{\"default_features\":true,\"features\":[],\"name\":\"tower-service\",\"optional\":true,\"req\":\"0.3\"},{\"default_features\":true,\"features\":[],\"name\":\"tracing\",\"optional\":false,\"req\":\"0.1\"},{\"default_features\":true,\"features\":[],\"name\":\"url\",\"optional\":true,\"req\":\"2.4\"},{\"default_features\":true,\"features\":[\"v4\"],\"name\":\"uuid\",\"optional\":true,\"req\":\"1\"},{\"default_features\":true,\"features\":[],\"name\":\"which\",\"optional\":true,\"req\":\"8\"},{\"default_features\":true,\"features\":[],\"name\":\"zeroize\",\"optional\":true,\"req\":\"1\"},{\"default_features\":false,\"features\":[\"serde\",\"clock\",\"std\",\"oldtime\"],\"name\":\"chrono\",\"optional\":false,\"req\":\"0.4.38\",\"target\":\"cfg(all(target_family = \\\"wasm\\\", target_os = \\\"unknown\\\"))\"},{\"default_features\":false,\"features\":[\"serde\",\"now\"],\"name\":\"chrono\",\"optional\":false,\"req\":\"0.4.38\",\"target\":\"cfg(not(all(target_family = \\\"wasm\\\", target_os = \\\"unknown\\\")))\"}],\"features\":{\"__reqwest\":[\"dep:reqwest\"],\"auth\":[\"dep:async-trait\",\"dep:oauth2\",\"__reqwest\",\"dep:url\"],\"auth-client-credentials-jwt\":[\"auth\",\"dep:jsonwebtoken\",\"uuid\"],\"auth-enterprise-managed\":[\"auth\",\"base64\"],\"client\":[\"dep:tokio-stream\"],\"client-side-sse\":[\"dep:sse-stream\",\"dep:http\",\"dep:bytes\",\"base64\"],\"default\":[\"base64\",\"macros\",\"server\"],\"elicitation\":[\"dep:url\"],\"local\":[\"rmcp-macros?/local\"],\"macros\":[\"dep:rmcp-macros\",\"dep:pastey\"],\"request-state\":[\"dep:hmac\",\"dep:sha2\",\"dep:zeroize\",\"base64\"],\"reqwest\":[\"__reqwest\",\"reqwest?/rustls\"],\"reqwest-native-tls\":[\"__reqwest\",\"reqwest?/native-tls\"],\"reqwest-tls-no-provider\":[\"__reqwest\",\"reqwest?/rustls-no-provider\"],\"schemars\":[\"dep:schemars\"],\"server\":[\"transport-async-rw\",\"schemars\",\"dep:pastey\",\"uuid\"],\"server-side-http\":[\"uuid\",\"dep:rand\",\"dep:tokio-stream\",\"dep:http\",\"dep:http-body\",\"dep:http-body-util\",\"dep:bytes\",\"dep:sse-stream\",\"tower\",\"base64\"],\"tower\":[\"dep:tower-service\"],\"transport-async-rw\":[\"tokio/io-util\",\"tokio-util/codec\"],\"transport-child-process\":[\"transport-async-rw\",\"tokio/process\",\"dep:process-wrap\"],\"transport-io\":[\"transport-async-rw\",\"tokio/io-std\"],\"transport-streamable-http-client\":[\"client-side-sse\",\"transport-worker\"],\"transport-streamable-http-client-reqwest\":[\"transport-streamable-http-client\",\"__reqwest\"],\"transport-streamable-http-client-unix-socket\":[\"transport-streamable-http-client\",\"dep:hyper\",\"dep:hyper-util\",\"dep:http-body-util\",\"dep:http\",\"dep:bytes\",\"tokio/net\"],\"transport-streamable-http-server\":[\"transport-streamable-http-server-session\",\"server-side-http\",\"transport-worker\"],\"transport-streamable-http-server-session\":[\"transport-async-rw\",\"dep:async-trait\",\"dep:tokio-stream\"],\"transport-worker\":[\"dep:tokio-stream\"],\"which-command\":[\"transport-child-process\",\"dep:which\"]},\"strip_prefix\":\"./crates/rmcp\"}",- "git+https://github.com/modelcontextprotocol/rust-sdk?rev=4048ac40e958fb1a7d614617a2ae8d26666ee2fa#4048ac40e958fb1a7d614617a2ae8d26666ee2fa_rmcp-macros": "{\"dependencies\":[{\"default_features\":true,\"features\":[],\"name\":\"darling\",\"optional\":false,\"req\":\"0.24\"},{\"name\":\"proc-macro2\",\"req\":\"1\"},{\"name\":\"quote\",\"req\":\"1\"},{\"name\":\"serde_json\",\"req\":\"1.0\"},{\"default_features\":true,\"features\":[\"full\"],\"name\":\"syn\",\"optional\":false,\"req\":\"3\"}],\"features\":{\"local\":[]},\"strip_prefix\":\"./crates/rmcp-macros\"}",+ "git+https://github.com/modelcontextprotocol/rust-sdk?rev=98a54789b80110ad210495c4ad845c89e1980471#98a54789b80110ad210495c4ad845c89e1980471_rmcp": "{\"dependencies\":[{\"default_features\":true,\"features\":[],\"name\":\"async-trait\",\"optional\":true,\"req\":\"0.1.89\"},{\"default_features\":true,\"features\":[],\"name\":\"base64\",\"optional\":true,\"req\":\"0.23\"},{\"default_features\":true,\"features\":[],\"name\":\"bytes\",\"optional\":true,\"req\":\"1\"},{\"name\":\"futures\",\"req\":\"0.3\"},{\"default_features\":true,\"features\":[],\"name\":\"hmac\",\"optional\":true,\"req\":\"0.13\"},{\"default_features\":true,\"features\":[],\"name\":\"http\",\"optional\":true,\"req\":\"1\"},{\"default_features\":true,\"features\":[],\"name\":\"http-body\",\"optional\":true,\"req\":\"1\"},{\"default_features\":true,\"features\":[],\"name\":\"http-body-util\",\"optional\":true,\"req\":\"0.1\"},{\"default_features\":true,\"features\":[\"client\",\"http1\"],\"name\":\"hyper\",\"optional\":true,\"req\":\"1\"},{\"default_features\":true,\"features\":[\"tokio\"],\"name\":\"hyper-util\",\"optional\":true,\"req\":\"0.1\"},{\"default_features\":true,\"features\":[\"serde\"],\"name\":\"indexmap\",\"optional\":false,\"req\":\"2\"},{\"default_features\":true,\"features\":[\"aws_lc_rs\"],\"name\":\"jsonwebtoken\",\"optional\":true,\"req\":\"11\"},{\"default_features\":false,\"features\":[],\"name\":\"oauth2\",\"optional\":true,\"req\":\"5.0\"},{\"default_features\":true,\"features\":[],\"name\":\"pastey\",\"optional\":true,\"req\":\"0.2.0\"},{\"name\":\"pin-project-lite\",\"req\":\"0.2\"},{\"default_features\":true,\"features\":[\"tokio1\"],\"name\":\"process-wrap\",\"optional\":true,\"req\":\"10.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rand\",\"optional\":true,\"req\":\"0.10\"},{\"default_features\":false,\"features\":[\"json\",\"stream\"],\"name\":\"reqwest\",\"optional\":true,\"req\":\"0.13.2\"},{\"default_features\":true,\"features\":[],\"name\":\"rmcp-macros\",\"optional\":true,\"req\":\"3.5.1\"},{\"default_features\":true,\"features\":[\"chrono04\"],\"name\":\"schemars\",\"optional\":true,\"req\":\"1.0\"},{\"default_features\":true,\"features\":[\"derive\",\"rc\"],\"name\":\"serde\",\"optional\":false,\"req\":\"1.0\"},{\"name\":\"serde_json\",\"req\":\"1.0\"},{\"default_features\":true,\"features\":[],\"name\":\"sha2\",\"optional\":true,\"req\":\"0.11\"},{\"default_features\":true,\"features\":[],\"name\":\"sse-stream\",\"optional\":true,\"req\":\"0.2.4\"},{\"name\":\"thiserror\",\"req\":\"2\"},{\"default_features\":true,\"features\":[\"sync\",\"macros\",\"rt\",\"time\"],\"name\":\"tokio\",\"optional\":false,\"req\":\"1\"},{\"default_features\":true,\"features\":[],\"name\":\"tokio-stream\",\"optional\":true,\"req\":\"0.1\"},{\"default_features\":true,\"features\":[],\"name\":\"tokio-util\",\"optional\":false,\"req\":\"0.7\"},{\"default_features\":true,\"features\":[],\"name\":\"tower-service\",\"optional\":true,\"req\":\"0.3\"},{\"default_features\":true,\"features\":[],\"name\":\"tracing\",\"optional\":false,\"req\":\"0.1\"},{\"default_features\":true,\"features\":[],\"name\":\"url\",\"optional\":true,\"req\":\"2.4\"},{\"default_features\":true,\"features\":[\"v4\"],\"name\":\"uuid\",\"optional\":true,\"req\":\"1\"},{\"default_features\":true,\"features\":[],\"name\":\"which\",\"optional\":true,\"req\":\"8\"},{\"default_features\":true,\"features\":[],\"name\":\"zeroize\",\"optional\":true,\"req\":\"1\"},{\"default_features\":false,\"features\":[\"serde\",\"clock\",\"std\",\"oldtime\"],\"name\":\"chrono\",\"optional\":false,\"req\":\"0.4.38\",\"target\":\"cfg(all(target_family = \\\"wasm\\\", target_os = \\\"unknown\\\"))\"},{\"default_features\":false,\"features\":[\"serde\",\"now\"],\"name\":\"chrono\",\"optional\":false,\"req\":\"0.4.38\",\"target\":\"cfg(not(all(target_family = \\\"wasm\\\", target_os = \\\"unknown\\\")))\"},{\"name\":\"libc\",\"req\":\"0.2\",\"target\":\"cfg(target_os = \\\"linux\\\")\"}],\"features\":{\"__reqwest\":[\"dep:reqwest\"],\"auth\":[\"dep:async-trait\",\"dep:oauth2\",\"__reqwest\",\"dep:url\"],\"auth-client-credentials-jwt\":[\"auth\",\"dep:jsonwebtoken\",\"uuid\"],\"auth-enterprise-managed\":[\"auth\",\"base64\"],\"client\":[\"dep:tokio-stream\"],\"client-side-sse\":[\"dep:sse-stream\",\"dep:http\",\"dep:bytes\",\"base64\"],\"default\":[\"base64\",\"macros\",\"server\"],\"elicitation\":[\"dep:url\"],\"local\":[\"rmcp-macros?/local\"],\"macros\":[\"dep:rmcp-macros\",\"dep:pastey\"],\"request-state\":[\"dep:hmac\",\"dep:sha2\",\"dep:zeroize\",\"base64\"],\"reqwest\":[\"__reqwest\",\"reqwest?/rustls\"],\"reqwest-native-tls\":[\"__reqwest\",\"reqwest?/native-tls\"],\"reqwest-tls-no-provider\":[\"__reqwest\",\"reqwest?/rustls-no-provider\"],\"schemars\":[\"dep:schemars\"],\"server\":[\"transport-async-rw\",\"schemars\",\"dep:pastey\",\"uuid\"],\"server-side-http\":[\"uuid\",\"dep:rand\",\"dep:tokio-stream\",\"dep:http\",\"dep:http-body\",\"dep:http-body-util\",\"dep:bytes\",\"dep:sse-stream\",\"tower\",\"base64\"],\"tower\":[\"dep:tower-service\"],\"transport-async-rw\":[\"tokio/io-util\",\"tokio-util/codec\"],\"transport-child-process\":[\"transport-async-rw\",\"tokio/process\",\"dep:process-wrap\"],\"transport-io\":[\"transport-async-rw\",\"tokio/io-std\",\"tokio/net\"],\"transport-streamable-http-client\":[\"client-side-sse\",\"transport-worker\"],\"transport-streamable-http-client-reqwest\":[\"transport-streamable-http-client\",\"__reqwest\"],\"transport-streamable-http-client-unix-socket\":[\"transport-streamable-http-client\",\"dep:hyper\",\"dep:hyper-util\",\"dep:http-body-util\",\"dep:http\",\"dep:bytes\",\"tokio/net\"],\"transport-streamable-http-server\":[\"transport-streamable-http-server-session\",\"server-side-http\",\"transport-worker\"],\"transport-streamable-http-server-session\":[\"transport-async-rw\",\"dep:async-trait\",\"dep:tokio-stream\"],\"transport-worker\":[\"dep:tokio-stream\"],\"which-command\":[\"transport-child-process\",\"dep:which\"]},\"strip_prefix\":\"./crates/rmcp\"}",+ "git+https://github.com/modelcontextprotocol/rust-sdk?rev=98a54789b80110ad210495c4ad845c89e1980471#98a54789b80110ad210495c4ad845c89e1980471_rmcp-macros": "{\"dependencies\":[{\"default_features\":true,\"features\":[],\"name\":\"darling\",\"optional\":false,\"req\":\"0.24\"},{\"name\":\"proc-macro2\",\"req\":\"1\"},{\"name\":\"quote\",\"req\":\"1\"},{\"name\":\"serde_json\",\"req\":\"1.0\"},{\"default_features\":true,\"features\":[\"full\"],\"name\":\"syn\",\"optional\":false,\"req\":\"3\"}],\"features\":{\"local\":[]},\"strip_prefix\":\"./crates/rmcp-macros\"}","git+https://github.com/openai-oss-forks/crossterm?rev=ed1cdab335221515706178d68495bba2aed1924f#ed1cdab335221515706178d68495bba2aed1924f_crossterm": "{\"dependencies\":[{\"default_features\":true,\"features\":[],\"name\":\"base64\",\"optional\":true,\"req\":\"0.23\"},{\"default_features\":true,\"features\":[],\"name\":\"bitflags\",\"optional\":false,\"req\":\"2.9\"},{\"default_features\":true,\"features\":[\"is_variant\"],\"name\":\"derive_more\",\"optional\":true,\"req\":\"2.0.0\"},{\"default_features\":true,\"features\":[],\"name\":\"document-features\",\"optional\":true,\"req\":\"0.2.11\"},{\"default_features\":false,\"features\":[],\"name\":\"futures-core\",\"optional\":true,\"req\":\"0.3.31\"},{\"name\":\"parking_lot\",\"req\":\"0.12.1\"},{\"default_features\":true,\"features\":[\"derive\"],\"name\":\"serde\",\"optional\":true,\"req\":\"1.0.103\"},{\"default_features\":true,\"features\":[],\"name\":\"filedescriptor\",\"optional\":true,\"req\":\"0.8\",\"target\":\"cfg(unix)\"},{\"default_features\":false,\"features\":[],\"name\":\"libc\",\"optional\":true,\"req\":\"0.2.168\",\"target\":\"cfg(unix)\"},{\"default_features\":true,\"features\":[\"os-poll\"],\"name\":\"mio\",\"optional\":true,\"req\":\"1.0.1\",\"target\":\"cfg(unix)\"},{\"default_features\":false,\"features\":[\"std\",\"stdio\",\"termios\"],\"name\":\"rustix\",\"optional\":false,\"req\":\"1\",\"target\":\"cfg(unix)\"},{\"default_features\":true,\"features\":[],\"name\":\"signal-hook\",\"optional\":true,\"req\":\"0.3.17\",\"target\":\"cfg(unix)\"},{\"default_features\":true,\"features\":[\"support-v1_0\"],\"name\":\"signal-hook-mio\",\"optional\":true,\"req\":\"0.2.4\",\"target\":\"cfg(unix)\"},{\"default_features\":true,\"features\":[],\"name\":\"crossterm_winapi\",\"optional\":true,\"req\":\"0.9.1\",\"target\":\"cfg(windows)\"},{\"default_features\":true,\"features\":[\"winuser\",\"winerror\"],\"name\":\"winapi\",\"optional\":true,\"req\":\"0.3.9\",\"target\":\"cfg(windows)\"}],\"features\":{\"bracketed-paste\":[],\"default\":[\"bracketed-paste\",\"derive-more\",\"events\",\"windows\"],\"derive-more\":[\"dep:derive_more\"],\"document-features\":[\"dep:document-features\"],\"event-stream\":[\"dep:futures-core\",\"events\"],\"events\":[\"dep:mio\",\"dep:signal-hook\",\"dep:signal-hook-mio\"],\"osc52\":[\"dep:base64\"],\"serde\":[\"dep:serde\",\"bitflags/serde\"],\"use-dev-tty\":[\"filedescriptor\",\"rustix/process\"],\"windows\":[\"dep:winapi\",\"dep:crossterm_winapi\"]},\"strip_prefix\":\"\"}","git+https://github.com/openai-oss-forks/tokio-tungstenite?rev=0e5b2d73aa18dd9f0a50ee9ff199d5aef7594186#0e5b2d73aa18dd9f0a50ee9ff199d5aef7594186_tokio-tungstenite": "{\"dependencies\":[{\"default_features\":false,\"features\":[\"sink\",\"std\"],\"name\":\"futures-util\",\"optional\":false,\"req\":\"0.3.28\"},{\"name\":\"log\",\"req\":\"0.4.17\"},{\"default_features\":true,\"features\":[],\"name\":\"native-tls-crate\",\"optional\":true,\"package\":\"native-tls\",\"req\":\"0.2.11\"},{\"default_features\":false,\"features\":[],\"name\":\"rustls\",\"optional\":true,\"req\":\"0.23.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rustls-native-certs\",\"optional\":true,\"req\":\"0.8.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rustls-pki-types\",\"optional\":true,\"req\":\"1.0\"},{\"default_features\":false,\"features\":[\"io-util\"],\"name\":\"tokio\",\"optional\":false,\"req\":\"1.0.0\"},{\"default_features\":true,\"features\":[],\"name\":\"tokio-native-tls\",\"optional\":true,\"req\":\"0.3.1\"},{\"default_features\":false,\"features\":[],\"name\":\"tokio-rustls\",\"optional\":true,\"req\":\"0.26.0\"},{\"default_features\":false,\"features\":[],\"name\":\"tungstenite\",\"optional\":false},{\"default_features\":true,\"features\":[],\"name\":\"webpki-roots\",\"optional\":true,\"req\":\"0.26.0\"}],\"features\":{\"__rustls-tls\":[\"rustls\",\"rustls-pki-types\",\"tokio-rustls\",\"stream\",\"tungstenite/__rustls-tls\",\"handshake\"],\"connect\":[\"stream\",\"tokio/net\",\"tokio/time\",\"handshake\"],\"default\":[\"connect\",\"handshake\"],\"handshake\":[\"tungstenite/handshake\"],\"native-tls\":[\"native-tls-crate\",\"tokio-native-tls\",\"stream\",\"tungstenite/native-tls\",\"handshake\"],\"native-tls-vendored\":[\"native-tls\",\"native-tls-crate/vendored\",\"tungstenite/native-tls-vendored\"],\"proxy\":[\"tungstenite/proxy\",\"tokio/net\",\"handshake\"],\"rustls-tls-native-roots\":[\"__rustls-tls\",\"rustls-native-certs\"],\"rustls-tls-webpki-roots\":[\"__rustls-tls\",\"webpki-roots\"],\"stream\":[],\"url\":[\"tungstenite/url\"]},\"strip_prefix\":\"\"}","git+https://github.com/openai-oss-forks/tungstenite-rs?rev=4fffad30fe373adbdcffab9545e9e9bf4f2fc19f#4fffad30fe373adbdcffab9545e9e9bf4f2fc19f_tungstenite": "{\"dependencies\":[{\"name\":\"bytes\",\"req\":\"1.9.0\"},{\"default_features\":true,\"features\":[],\"name\":\"data-encoding\",\"optional\":true,\"req\":\"2\"},{\"default_features\":false,\"features\":[\"zlib-rs\"],\"name\":\"flate2\",\"optional\":true,\"req\":\"1.1.0\"},{\"default_features\":true,\"features\":[],\"name\":\"headers\",\"optional\":true,\"req\":\"0.4.0\"},{\"default_features\":true,\"features\":[],\"name\":\"http\",\"optional\":true,\"req\":\"1.0\"},{\"default_features\":true,\"features\":[],\"name\":\"httparse\",\"optional\":true,\"req\":\"1.3.4\"},{\"name\":\"log\",\"req\":\"0.4.8\"},{\"default_features\":true,\"features\":[],\"name\":\"native-tls-crate\",\"optional\":true,\"package\":\"native-tls\",\"req\":\"0.2.3\"},{\"name\":\"rand\",\"req\":\"0.9.0\"},{\"default_features\":false,\"features\":[\"std\"],\"name\":\"rustls\",\"optional\":true,\"req\":\"0.23.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rustls-native-certs\",\"optional\":true,\"req\":\"0.8.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rustls-pki-types\",\"optional\":true,\"req\":\"1.0\"},{\"default_features\":true,\"features\":[],\"name\":\"sha1\",\"optional\":true,\"req\":\"0.10\"},{\"name\":\"thiserror\",\"req\":\"2.0.7\"},{\"default_features\":true,\"features\":[],\"name\":\"url\",\"optional\":true,\"req\":\"2.1.0\"},{\"name\":\"utf-8\",\"req\":\"0.7.5\"},{\"default_features\":true,\"features\":[],\"name\":\"webpki-roots\",\"optional\":true,\"req\":\"0.26\"}],\"features\":{\"__rustls-tls\":[\"rustls\",\"rustls-pki-types\"],\"default\":[\"handshake\"],\"deflate\":[\"headers\",\"flate2\"],\"handshake\":[\"data-encoding\",\"headers\",\"httparse\",\"sha1\"],\"headers\":[\"http\",\"dep:headers\"],\"native-tls\":[\"native-tls-crate\"],\"native-tls-vendored\":[\"native-tls\",\"native-tls-crate/vendored\"],\"proxy\":[\"handshake\"],\"rustls-tls-native-roots\":[\"__rustls-tls\",\"rustls-native-certs\"],\"rustls-tls-webpki-roots\":[\"__rustls-tls\",\"webpki-roots\"],\"url\":[\"dep:url\"]},\"strip_prefix\":\"\"}",diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lockindex 7272adf2fa..5abf8ef5e0 100644--- a/codex-rs/Cargo.lock+++ b/codex-rs/Cargo.lock@@ -12947,7 +12947,7 @@ dependencies = [[[package]]name = "rmcp"version = "3.5.1"-source = "git+https://github.com/modelcontextprotocol/rust-sdk?rev=4048ac40e958fb1a7d614617a2ae8d26666ee2fa#4048ac40e958fb1a7d614617a2ae8d26666ee2fa"+source = "git+https://github.com/modelcontextprotocol/rust-sdk?rev=98a54789b80110ad210495c4ad845c89e1980471#98a54789b80110ad210495c4ad845c89e1980471"dependencies = ["async-trait","base64 0.23.0",@@ -12958,6 +12958,7 @@ dependencies = ["http-body 1.0.1","http-body-util","indexmap 2.14.0",+ "libc","oauth2","pastey","pin-project-lite",@@ -12982,7 +12983,7 @@ dependencies = [[[package]]name = "rmcp-macros"version = "3.5.1"-source = "git+https://github.com/modelcontextprotocol/rust-sdk?rev=4048ac40e958fb1a7d614617a2ae8d26666ee2fa#4048ac40e958fb1a7d614617a2ae8d26666ee2fa"+source = "git+https://github.com/modelcontextprotocol/rust-sdk?rev=98a54789b80110ad210495c4ad845c89e1980471#98a54789b80110ad210495c4ad845c89e1980471"dependencies = ["darling 0.24.0","proc-macro2",diff --git a/codex-rs/Cargo.toml b/codex-rs/Cargo.tomlindex 974b7cf097..978b90f36e 100644--- a/codex-rs/Cargo.toml+++ b/codex-rs/Cargo.toml@@ -448,7 +448,7 @@ regex-automata = { version = "0.4.13", default-features = false, features = ["stregex-lite = "0.1.8"regex-syntax = "0.8.8"reqwest = { version = "0.12", features = ["cookies"] }-rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", rev = "4048ac40e958fb1a7d614617a2ae8d26666ee2fa", version = "=3.5.1", default-features = false }+rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", rev = "98a54789b80110ad210495c4ad845c89e1980471", version = "=3.5.1", default-features = false }runfiles = { git = "https://github.com/dzbarsky/rules_rust", rev = "b56cbaa8465e74127f1ea216f813cd377295ad81" }rustix = { version = "1.1.4", features = ["net"] }rustls = { version = "0.23.46", default-features = false, features = [diff --git a/codex-rs/cli/tests/mcp_login.rs b/codex-rs/cli/tests/mcp_login.rsindex 4684e134ed..85ef53686b 100644--- a/codex-rs/cli/tests/mcp_login.rs+++ b/codex-rs/cli/tests/mcp_login.rs@@ -39,17 +39,26 @@ struct Fixture {impl Fixture {async fn new(client_secret: Option<&'static str>) -> Result<Self> {+ Self::with_scopes(client_secret, &["mcp.read"]).await+ }++ async fn with_scopes(client_secret: Option<&'static str>, scopes: &[&str]) -> Result<Self> {let server = MockServer::start().await;let home = TempDir::new()?;let issuer = format!("{}/mcp", server.uri());let saved_client_secret = client_secret.map(|secret| format!("client_secret = \"{secret}\"\n")).unwrap_or_default();+ let saved_scopes = if scopes.is_empty() {+ String::new()+ } else {+ format!("scopes = {scopes:?}\n")+ };std::fs::write(home.path().join("config.toml"),format!("mcp_oauth_credentials_store = \"file\"\n\- [mcp_servers.manual]\nurl = \"{issuer}\"\nscopes = [\"mcp.read\"]\n\+ [mcp_servers.manual]\nurl = \"{issuer}\"\n{saved_scopes}\[mcp_servers.manual.oauth]\nclient_id = \"registered-client\"\n\{saved_client_secret}"),@@ -100,6 +109,30 @@ impl Fixture {.await;}+ async fn mount_resource_metadata(&self, scopes: &[&str], challenge_scope: Option<&str>) {+ let mut challenge = format!(+ "Bearer resource_metadata=\"{}/resource-metadata\"",+ self.server.uri()+ );+ if let Some(scope) = challenge_scope {+ challenge.push_str(&format!(", scope=\"{scope}\""));+ }+ Mock::given(method("GET"))+ .and(path("/mcp"))+ .respond_with(ResponseTemplate::new(401).insert_header("www-authenticate", challenge))+ .mount(&self.server)+ .await;+ Mock::given(method("GET"))+ .and(path("/resource-metadata"))+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({+ "resource": self.issuer,+ "authorization_servers": [self.issuer],+ "scopes_supported": scopes,+ })))+ .mount(&self.server)+ .await;+ }+async fn start(&self) -> Result<Login> {let mut child = Command::new(codex_utils_cargo_bin::cargo_bin("codex")?).kill_on_drop(true)@@ -199,6 +232,32 @@ async fn no_browser_exchanges_pasted_callback_and_saves_credentials() -> Result<.await}+#[tokio::test]+async fn no_browser_prefers_challenge_scopes_for_preregistered_client() -> Result<()> {+ let fixture = Fixture::with_scopes(/*client_secret*/ None, &[]).await?;+ fixture+ .mount_resource_metadata(&["mcp.read", "mcp.write"], Some("mcp.read"))+ .await;+ // The authorization server advertises neither scopes nor dynamic registration.+ Mock::given(method("GET"))+ .and(path("/.well-known/oauth-authorization-server/mcp"))+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({+ "issuer": fixture.issuer,+ "authorization_endpoint": format!("{}/authorize", fixture.server.uri()),+ "token_endpoint": format!("{}/token", fixture.server.uri()),+ "response_types_supported": ["code"],+ "code_challenge_methods_supported": ["S256"],+ })))+ .with_priority(/*priority*/ 1)+ .mount(&fixture.server)+ .await;++ assert_no_browser_exchanges_pasted_callback_and_saves_credentials(+ fixture, /*client_secret*/ None,+ )+ .await+}+#[tokio::test]async fn no_browser_exchanges_pasted_callback_with_client_secret() -> Result<()> {let fixture = Fixture::new(Some("headless-client-secret")).await?;@@ -262,6 +321,9 @@ async fn add_persists_client_secret_for_subsequent_login_without_disclosure() ->// Reset removes the priority override without relying on wiremock's scoped indices.fixture.server.reset().await;fixture.mount_oauth(Some(CLIENT_SECRET)).await;+ fixture+ .mount_resource_metadata(&["mcp.read"], /*challenge_scope*/ None)+ .await;assert_no_browser_exchanges_pasted_callback_and_saves_credentials(fixture, Some(CLIENT_SECRET)).await@@ -274,6 +336,7 @@ async fn assert_no_browser_exchanges_pasted_callback_and_saves_credentials(let mut login = fixture.start().await?;let authorization_url = login.authorization_url.to_string();let params: BTreeMap<_, _> = login.authorization_url.query_pairs().into_owned().collect();+ assert_eq!(params.get("scope").map(String::as_str), Some("mcp.read"));let callback = login.callback(&fixture.issuer)?;login.child@@ -438,10 +501,10 @@ async fn no_browser_accepts_http_callback_while_terminal_input_remains_open() ->#[tokio::test]async fn no_browser_retries_rejected_discovered_scopes_with_pasteback() -> Result<()> {- let fixture = Fixture::new(/*client_secret*/ None).await?;- let config_path = fixture.home.path().join("config.toml");- let config = std::fs::read_to_string(&config_path)?;- std::fs::write(config_path, config.replace("scopes = [\"mcp.read\"]\n", ""))?;+ let fixture = Fixture::with_scopes(/*client_secret*/ None, &[]).await?;+ fixture+ .mount_resource_metadata(&["mcp.read"], /*challenge_scope*/ None)+ .await;let mut login = fixture.start().await?;assert!(logindiff --git a/codex-rs/rmcp-client/src/auth_status.rs b/codex-rs/rmcp-client/src/auth_status.rsindex 9caea78dcd..db2916d9a8 100644--- a/codex-rs/rmcp-client/src/auth_status.rs+++ b/codex-rs/rmcp-client/src/auth_status.rs@@ -246,7 +246,7 @@ async fn discover_streamable_http_oauth_with_headers_and_http_client(let mut authorization_manager =AuthorizationManager::new_with_oauth_http_client(url, Arc::new(oauth_http_client)).await?;authorization_manager.set_allow_missing_issuer(true);- discover_streamable_http_oauth_with_manager(&authorization_manager).await+ discover_streamable_http_oauth_with_manager(&mut authorization_manager).await}fn has_configured_headers(@@ -262,16 +262,21 @@ fn has_configured_headers(}async fn discover_streamable_http_oauth_with_manager(- authorization_manager: &AuthorizationManager,+ authorization_manager: &mut AuthorizationManager,) -> Result<Option<StreamableHttpOAuthDiscovery>> {match authorization_manager.resolve_metadata().boxed().await {Ok(resolution) if !resolution.source.is_discovered() => Ok(None),Ok(resolution) => {let metadata = resolution.metadata;+ let callback_mode =+ callback_mode(&metadata).unwrap_or(McpOAuthCallbackMode::CallbackSpecific);+ authorization_manager.set_metadata(metadata);Ok(Some(StreamableHttpOAuthDiscovery {- callback_mode: callback_mode(&metadata)- .unwrap_or(McpOAuthCallbackMode::CallbackSpecific),- scopes_supported: normalize_scopes(metadata.scopes_supported),+ callback_mode,+ // Prefer the initial challenge's scopes, falling back to resource metadata.+ scopes_supported: normalize_scopes(+ authorization_manager.select_initial_scopes(&[]).await,+ ),}))}Err(AuthError::NoAuthorizationSupport) => Ok(None),@@ -279,9 +284,7 @@ async fn discover_streamable_http_oauth_with_manager(}}-fn normalize_scopes(scopes_supported: Option<Vec<String>>) -> Option<Vec<String>> {- let scopes_supported = scopes_supported?;-+fn normalize_scopes(scopes_supported: Vec<String>) -> Option<Vec<String>> {let mut normalized = Vec::new();for scope in scopes_supported {let scope = scope.trim();@@ -677,7 +680,7 @@ mod tests {}#[tokio::test]- async fn discover_streamable_http_oauth_returns_normalized_scopes() {+ async fn discover_streamable_http_oauth_does_not_use_authorization_server_scopes() {let server = spawn_oauth_discovery_server(serde_json::json!({"authorization_endpoint": "https://example.com/authorize","token_endpoint": "https://example.com/token",@@ -701,7 +704,7 @@ mod tests {assert_eq!(discovery,StreamableHttpOAuthDiscovery {- scopes_supported: Some(vec!["profile".to_string(), "email".to_string()]),+ scopes_supported: None,callback_mode: McpOAuthCallbackMode::IssuerBound,});@@ -834,85 +837,68 @@ mod tests {let authorization_server = spawn_oauth_discovery_server(serde_json::json!({"authorization_endpoint": "https://example.com/authorize","token_endpoint": "https://example.com/token",- "scopes_supported": ["read", " write ", "read"],+ "scopes_supported": ["unrelated:admin", "offline_access"],})).await;- let listener = tokio::net::TcpListener::bind("127.0.0.1:0")- .await- .expect("listener should bind");- let address = listener.local_addr().expect("listener should have address");- let resource_metadata_url = format!("http://{address}/oauth-resource");- let challenge = format!("Bearer resource_metadata=\"{resource_metadata_url}\"");- let authorization_server_url = authorization_server.url.clone();- let app = Router::new()- .route(- "/mcp",- get(move || {- let challenge = challenge.clone();- async move { (StatusCode::UNAUTHORIZED, [(WWW_AUTHENTICATE, challenge)]) }- }),+ for (challenge_scope, expected_scopes) in [+ ("", vec!["read", "write", "offline_access"]),+ (", scope=\"read\"", vec!["read", "offline_access"]),+ ] {+ let listener = tokio::net::TcpListener::bind("127.0.0.1:0")+ .await+ .expect("listener should bind");+ let address = listener.local_addr().expect("listener should have address");+ let resource_metadata_url = format!("http://{address}/oauth-resource");+ let challenge =+ format!("Bearer resource_metadata=\"{resource_metadata_url}\"{challenge_scope}");+ let authorization_server_url = authorization_server.url.clone();+ let app = Router::new()+ .route(+ "/mcp",+ get(move || {+ let challenge = challenge.clone();+ async move { (StatusCode::UNAUTHORIZED, [(WWW_AUTHENTICATE, challenge)]) }+ }),+ )+ .route(+ "/oauth-resource",+ get(move || {+ let authorization_server_url = authorization_server_url.clone();+ async move {+ Json(serde_json::json!({+ "resource": format!("http://{address}/mcp"),+ "authorization_servers": [authorization_server_url],+ "scopes_supported": ["read", " write ", "read", "", " "],+ }))+ }+ }),+ );+ let handle = tokio::spawn(async move {+ axum::serve(listener, app).await.expect("server should run");+ });+ let resource_server = TestServer {+ url: format!("http://{address}/mcp"),+ handle,+ };++ let discovery = discover_streamable_http_oauth(+ &resource_server.url,+ /*http_headers*/ None,+ /*env_http_headers*/ None,+ test_http_client().await,+ OAuthDiscoveryTimeout::LOCAL,+ StreamableHttpRedirectMode::Legacy,)- .route(- "/oauth-resource",- get(move || {- let authorization_server_url = authorization_server_url.clone();- async move {- Json(serde_json::json!({- "resource": format!("http://{address}/mcp"),- "authorization_servers": [authorization_server_url],- }))- }- }),- );- let handle = tokio::spawn(async move {- axum::serve(listener, app).await.expect("server should run");- });- let resource_server = TestServer {- url: format!("http://{address}/mcp"),- handle,- };-- let discovery = discover_streamable_http_oauth(- &resource_server.url,- /*http_headers*/ None,- /*env_http_headers*/ None,- test_http_client().await,- OAuthDiscoveryTimeout::LOCAL,- StreamableHttpRedirectMode::Legacy,- )- .await- .expect("discovery should succeed")- .expect("oauth support should be detected");-- assert_eq!(- discovery.scopes_supported,- Some(vec!["read".to_string(), "write".to_string()])- );- }-- #[tokio::test]- async fn discover_streamable_http_oauth_ignores_empty_scopes() {- let server = spawn_oauth_discovery_server(serde_json::json!({- "authorization_endpoint": "https://example.com/authorize",- "token_endpoint": "https://example.com/token",- "scopes_supported": ["", " "],- }))- .await;-- let discovery = discover_streamable_http_oauth(- &server.url,- /*http_headers*/ None,- /*env_http_headers*/ None,- test_http_client().await,- OAuthDiscoveryTimeout::LOCAL,- StreamableHttpRedirectMode::Legacy,- )- .await- .expect("discovery should succeed")- .expect("oauth support should be detected");+ .await+ .expect("discovery should succeed")+ .expect("oauth support should be detected");- assert_eq!(discovery.scopes_supported, None);+ assert_eq!(+ discovery.scopes_supported,+ Some(expected_scopes.into_iter().map(str::to_string).collect())+ );+ }}#[tokio::test]diff --git a/codex-rs/rmcp-client/tests/mcp_2026_oauth_discovery.rs b/codex-rs/rmcp-client/tests/mcp_2026_oauth_discovery.rsindex 2419821d97..24aa7aec2b 100644--- a/codex-rs/rmcp-client/tests/mcp_2026_oauth_discovery.rs+++ b/codex-rs/rmcp-client/tests/mcp_2026_oauth_discovery.rs@@ -193,6 +193,7 @@ async fn assert_legacy_oauth_without_starting_an_mcp_session(.respond_with(ResponseTemplate::new(200).set_body_json(json!({"resource": resource_url,"authorization_servers": [authorization_server.uri()],+ "scopes_supported": ["mcp:read"],}))).expect(2).mount(&resource_server)@@ -201,7 +202,6 @@ async fn assert_legacy_oauth_without_starting_an_mcp_session(let mut metadata = json!({"authorization_endpoint": format!("{}/authorize", authorization_server.uri()),"token_endpoint": format!("{}/token", authorization_server.uri()),- "scopes_supported": ["mcp:read"],"code_challenge_methods_supported": ["S256"],});match metadata_issuer {