@@ -279,6 +279,7 @@ use codex_login::default_client::set_default_client_residency_requirement;
279279use codex_login:: login_with_api_key;
280280use codex_login:: request_device_code;
281281use codex_login:: run_login_server;
282+ use codex_mcp:: McpRuntimeEnvironment ;
282283use codex_mcp:: McpServerStatusSnapshot ;
283284use codex_mcp:: McpSnapshotDetail ;
284285use codex_mcp:: collect_mcp_server_status_snapshot_with_detail;
@@ -5724,10 +5725,40 @@ impl CodexMessageProcessor {
57245725 . to_mcp_config ( self . thread_manager . plugins_manager ( ) . as_ref ( ) )
57255726 . await ;
57265727 let auth = self . auth_manager . auth ( ) . await ;
5728+ let runtime_environment = match self . thread_manager . environment_manager ( ) . current ( ) . await {
5729+ Ok ( Some ( environment) ) => {
5730+ // Status listing has no turn cwd. This fallback is used only
5731+ // by executor-backed stdio MCPs whose config omits `cwd`.
5732+ McpRuntimeEnvironment :: new ( environment, config. cwd . to_path_buf ( ) )
5733+ }
5734+ Ok ( None ) => McpRuntimeEnvironment :: new (
5735+ Arc :: new ( codex_exec_server:: Environment :: default ( ) ) ,
5736+ config. cwd . to_path_buf ( ) ,
5737+ ) ,
5738+ Err ( err) => {
5739+ // TODO(aibrahim): Investigate degrading MCP status listing when
5740+ // executor environment creation fails.
5741+ let error = JSONRPCErrorError {
5742+ code : INTERNAL_ERROR_CODE ,
5743+ message : format ! ( "failed to create environment: {err}" ) ,
5744+ data : None ,
5745+ } ;
5746+ self . outgoing . send_error ( request, error) . await ;
5747+ return ;
5748+ }
5749+ } ;
57275750
57285751 tokio:: spawn ( async move {
5729- Self :: list_mcp_server_status_task ( outgoing, request, params, config, mcp_config, auth)
5730- . await ;
5752+ Self :: list_mcp_server_status_task (
5753+ outgoing,
5754+ request,
5755+ params,
5756+ config,
5757+ mcp_config,
5758+ auth,
5759+ runtime_environment,
5760+ )
5761+ . await ;
57315762 } ) ;
57325763 }
57335764
@@ -5738,6 +5769,7 @@ impl CodexMessageProcessor {
57385769 config : Config ,
57395770 mcp_config : codex_mcp:: McpConfig ,
57405771 auth : Option < CodexAuth > ,
5772+ runtime_environment : McpRuntimeEnvironment ,
57415773 ) {
57425774 let detail = match params. detail . unwrap_or ( McpServerStatusDetail :: Full ) {
57435775 McpServerStatusDetail :: Full => McpSnapshotDetail :: Full ,
@@ -5748,6 +5780,7 @@ impl CodexMessageProcessor {
57485780 & mcp_config,
57495781 auth. as_ref ( ) ,
57505782 request_id. request_id . to_string ( ) ,
5783+ runtime_environment,
57515784 detail,
57525785 )
57535786 . await ;
0 commit comments