@@ -17,6 +17,7 @@ use codex_apply_patch::ApplyPatchAction;
1717use codex_protocol:: ConversationId ;
1818use codex_protocol:: protocol:: ConversationPathResponseEvent ;
1919use codex_protocol:: protocol:: ExitedReviewModeEvent ;
20+ use codex_protocol:: protocol:: McpAuthStatus ;
2021use codex_protocol:: protocol:: ReviewRequest ;
2122use codex_protocol:: protocol:: RolloutItem ;
2223use codex_protocol:: protocol:: SessionSource ;
@@ -372,10 +373,25 @@ impl Session {
372373 ) ;
373374 let default_shell_fut = shell:: default_user_shell ( ) ;
374375 let history_meta_fut = crate :: message_history:: history_metadata ( & config) ;
376+ let auth_statuses_fut = compute_auth_statuses (
377+ config. mcp_servers . iter ( ) ,
378+ config. mcp_oauth_credentials_store_mode ,
379+ ) ;
375380
376381 // Join all independent futures.
377- let ( rollout_recorder, mcp_res, default_shell, ( history_log_id, history_entry_count) ) =
378- tokio:: join!( rollout_fut, mcp_fut, default_shell_fut, history_meta_fut) ;
382+ let (
383+ rollout_recorder,
384+ mcp_res,
385+ default_shell,
386+ ( history_log_id, history_entry_count) ,
387+ auth_statuses,
388+ ) = tokio:: join!(
389+ rollout_fut,
390+ mcp_fut,
391+ default_shell_fut,
392+ history_meta_fut,
393+ auth_statuses_fut
394+ ) ;
379395
380396 let rollout_recorder = rollout_recorder. map_err ( |e| {
381397 error ! ( "failed to initialize rollout recorder: {e:#}" ) ;
@@ -402,11 +418,24 @@ impl Session {
402418 // Surface individual client start-up failures to the user.
403419 if !failed_clients. is_empty ( ) {
404420 for ( server_name, err) in failed_clients {
405- let message = format ! ( "MCP client for `{server_name}` failed to start: {err:#}" ) ;
406- error ! ( "{message}" ) ;
421+ let log_message =
422+ format ! ( "MCP client for `{server_name}` failed to start: {err:#}" ) ;
423+ error ! ( "{log_message}" ) ;
424+ let display_message = if matches ! (
425+ auth_statuses. get( & server_name) ,
426+ Some ( McpAuthStatus :: NotLoggedIn )
427+ ) {
428+ format ! (
429+ "The {server_name} MCP server is not logged in. Run `codex mcp login {server_name}` to log in."
430+ )
431+ } else {
432+ log_message
433+ } ;
407434 post_session_configured_error_events. push ( Event {
408435 id : INITIAL_SUBMIT_ID . to_owned ( ) ,
409- msg : EventMsg :: Error ( ErrorEvent { message } ) ,
436+ msg : EventMsg :: Error ( ErrorEvent {
437+ message : display_message,
438+ } ) ,
410439 } ) ;
411440 }
412441 }
@@ -591,13 +620,15 @@ impl Session {
591620 warn ! ( "Overwriting existing pending approval for sub_id: {event_id}" ) ;
592621 }
593622
623+ let parsed_cmd = parse_command ( & command) ;
594624 let event = Event {
595625 id : event_id,
596626 msg : EventMsg :: ExecApprovalRequest ( ExecApprovalRequestEvent {
597627 call_id,
598628 command,
599629 cwd,
600630 reason,
631+ parsed_cmd,
601632 } ) ,
602633 } ;
603634 self . send_event ( event) . await ;
@@ -853,10 +884,7 @@ impl Session {
853884 call_id,
854885 command : command_for_display. clone ( ) ,
855886 cwd,
856- parsed_cmd : parse_command ( & command_for_display)
857- . into_iter ( )
858- . map ( Into :: into)
859- . collect ( ) ,
887+ parsed_cmd : parse_command ( & command_for_display) ,
860888 } ) ,
861889 } ;
862890 let event = Event {
0 commit comments