@@ -13,6 +13,8 @@ use codex_core::config::load_global_mcp_servers;
1313use  codex_core:: config:: write_global_mcp_servers; 
1414use  codex_core:: config_types:: McpServerConfig ; 
1515use  codex_core:: config_types:: McpServerTransportConfig ; 
16+ use  codex_core:: mcp:: auth:: compute_auth_statuses; 
17+ use  codex_core:: protocol:: McpAuthStatus ; 
1618use  codex_rmcp_client:: delete_oauth_tokens; 
1719use  codex_rmcp_client:: perform_oauth_login; 
1820
@@ -340,11 +342,20 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
340342
341343    let  mut  entries:  Vec < _ >  = config. mcp_servers . iter ( ) . collect ( ) ; 
342344    entries. sort_by ( |( a,  _) ,  ( b,  _) | a. cmp ( b) ) ; 
345+     let  auth_statuses = compute_auth_statuses ( 
346+         config. mcp_servers . iter ( ) , 
347+         config. mcp_oauth_credentials_store_mode , 
348+     ) 
349+     . await ; 
343350
344351    if  list_args. json  { 
345352        let  json_entries:  Vec < _ >  = entries
346353            . into_iter ( ) 
347354            . map ( |( name,  cfg) | { 
355+                 let  auth_status = auth_statuses
356+                     . get ( name. as_str ( ) ) 
357+                     . copied ( ) 
358+                     . unwrap_or ( McpAuthStatus :: Unsupported ) ; 
348359                let  transport = match  & cfg. transport  { 
349360                    McpServerTransportConfig :: Stdio  {  command,  args,  env }  => serde_json:: json!( { 
350361                        "type" :  "stdio" , 
@@ -374,6 +385,7 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
374385                    "tool_timeout_sec" :  cfg
375386                        . tool_timeout_sec
376387                        . map( |timeout| timeout. as_secs_f64( ) ) , 
388+                     "auth_status" :  auth_status, 
377389                } ) 
378390            } ) 
379391            . collect ( ) ; 
@@ -387,8 +399,8 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
387399        return  Ok ( ( ) ) ; 
388400    } 
389401
390-     let  mut  stdio_rows:  Vec < [ String ;  5 ] >  = Vec :: new ( ) ; 
391-     let  mut  http_rows:  Vec < [ String ;  4 ] >  = Vec :: new ( ) ; 
402+     let  mut  stdio_rows:  Vec < [ String ;  6 ] >  = Vec :: new ( ) ; 
403+     let  mut  http_rows:  Vec < [ String ;  5 ] >  = Vec :: new ( ) ; 
392404
393405    for  ( name,  cfg)  in  entries { 
394406        match  & cfg. transport  { 
@@ -416,12 +428,18 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
416428                }  else  { 
417429                    "disabled" . to_string ( ) 
418430                } ; 
431+                 let  auth_status = auth_statuses
432+                     . get ( name. as_str ( ) ) 
433+                     . copied ( ) 
434+                     . unwrap_or ( McpAuthStatus :: Unsupported ) 
435+                     . to_string ( ) ; 
419436                stdio_rows. push ( [ 
420437                    name. clone ( ) , 
421438                    command. clone ( ) , 
422439                    args_display, 
423440                    env_display, 
424441                    status, 
442+                     auth_status, 
425443                ] ) ; 
426444            } 
427445            McpServerTransportConfig :: StreamableHttp  { 
@@ -433,11 +451,17 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
433451                }  else  { 
434452                    "disabled" . to_string ( ) 
435453                } ; 
454+                 let  auth_status = auth_statuses
455+                     . get ( name. as_str ( ) ) 
456+                     . copied ( ) 
457+                     . unwrap_or ( McpAuthStatus :: Unsupported ) 
458+                     . to_string ( ) ; 
436459                http_rows. push ( [ 
437460                    name. clone ( ) , 
438461                    url. clone ( ) , 
439462                    bearer_token_env_var. clone ( ) . unwrap_or ( "-" . to_string ( ) ) , 
440463                    status, 
464+                     auth_status, 
441465                ] ) ; 
442466            } 
443467        } 
@@ -450,6 +474,7 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
450474            "Args" . len ( ) , 
451475            "Env" . len ( ) , 
452476            "Status" . len ( ) , 
477+             "Auth" . len ( ) , 
453478        ] ; 
454479        for  row in  & stdio_rows { 
455480            for  ( i,  cell)  in  row. iter ( ) . enumerate ( )  { 
@@ -458,32 +483,36 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
458483        } 
459484
460485        println ! ( 
461-             "{:<name_w$}  {:<cmd_w$}  {:<args_w$}  {:<env_w$}  {:<status_w$}" , 
462-             "Name" , 
463-             "Command" , 
464-             "Args" , 
465-             "Env" , 
466-             "Status" , 
486+             "{name:<name_w$}  {command:<cmd_w$}  {args:<args_w$}  {env:<env_w$}  {status:<status_w$}  {auth:<auth_w$}" , 
487+             name = "Name" , 
488+             command = "Command" , 
489+             args = "Args" , 
490+             env = "Env" , 
491+             status = "Status" , 
492+             auth = "Auth" , 
467493            name_w = widths[ 0 ] , 
468494            cmd_w = widths[ 1 ] , 
469495            args_w = widths[ 2 ] , 
470496            env_w = widths[ 3 ] , 
471497            status_w = widths[ 4 ] , 
498+             auth_w = widths[ 5 ] , 
472499        ) ; 
473500
474501        for  row in  & stdio_rows { 
475502            println ! ( 
476-                 "{:<name_w$}  {:<cmd_w$}  {:<args_w$}  {:<env_w$}  {:<status_w$}" , 
477-                 row[ 0 ] , 
478-                 row[ 1 ] , 
479-                 row[ 2 ] , 
480-                 row[ 3 ] , 
481-                 row[ 4 ] , 
503+                 "{name:<name_w$}  {command:<cmd_w$}  {args:<args_w$}  {env:<env_w$}  {status:<status_w$}  {auth:<auth_w$}" , 
504+                 name = row[ 0 ] . as_str( ) , 
505+                 command = row[ 1 ] . as_str( ) , 
506+                 args = row[ 2 ] . as_str( ) , 
507+                 env = row[ 3 ] . as_str( ) , 
508+                 status = row[ 4 ] . as_str( ) , 
509+                 auth = row[ 5 ] . as_str( ) , 
482510                name_w = widths[ 0 ] , 
483511                cmd_w = widths[ 1 ] , 
484512                args_w = widths[ 2 ] , 
485513                env_w = widths[ 3 ] , 
486514                status_w = widths[ 4 ] , 
515+                 auth_w = widths[ 5 ] , 
487516            ) ; 
488517        } 
489518    } 
@@ -498,6 +527,7 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
498527            "Url" . len ( ) , 
499528            "Bearer Token Env Var" . len ( ) , 
500529            "Status" . len ( ) , 
530+             "Auth" . len ( ) , 
501531        ] ; 
502532        for  row in  & http_rows { 
503533            for  ( i,  cell)  in  row. iter ( ) . enumerate ( )  { 
@@ -506,28 +536,32 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
506536        } 
507537
508538        println ! ( 
509-             "{:<name_w$}  {:<url_w$}  {:<token_w$}  {:<status_w$}" , 
510-             "Name" , 
511-             "Url" , 
512-             "Bearer Token Env Var" , 
513-             "Status" , 
539+             "{name:<name_w$}  {url:<url_w$}  {token:<token_w$}  {status:<status_w$}  {auth:<auth_w$}" , 
540+             name = "Name" , 
541+             url = "Url" , 
542+             token = "Bearer Token Env Var" , 
543+             status = "Status" , 
544+             auth = "Auth" , 
514545            name_w = widths[ 0 ] , 
515546            url_w = widths[ 1 ] , 
516547            token_w = widths[ 2 ] , 
517548            status_w = widths[ 3 ] , 
549+             auth_w = widths[ 4 ] , 
518550        ) ; 
519551
520552        for  row in  & http_rows { 
521553            println ! ( 
522-                 "{:<name_w$}  {:<url_w$}  {:<token_w$}  {:<status_w$}" , 
523-                 row[ 0 ] , 
524-                 row[ 1 ] , 
525-                 row[ 2 ] , 
526-                 row[ 3 ] , 
554+                 "{name:<name_w$}  {url:<url_w$}  {token:<token_w$}  {status:<status_w$}  {auth:<auth_w$}" , 
555+                 name = row[ 0 ] . as_str( ) , 
556+                 url = row[ 1 ] . as_str( ) , 
557+                 token = row[ 2 ] . as_str( ) , 
558+                 status = row[ 3 ] . as_str( ) , 
559+                 auth = row[ 4 ] . as_str( ) , 
527560                name_w = widths[ 0 ] , 
528561                url_w = widths[ 1 ] , 
529562                token_w = widths[ 2 ] , 
530563                status_w = widths[ 3 ] , 
564+                 auth_w = widths[ 4 ] , 
531565            ) ; 
532566        } 
533567    } 
0 commit comments