@@ -13,6 +13,8 @@ use codex_core::config::load_global_mcp_servers;
13
13
use codex_core:: config:: write_global_mcp_servers;
14
14
use codex_core:: config_types:: McpServerConfig ;
15
15
use codex_core:: config_types:: McpServerTransportConfig ;
16
+ use codex_core:: mcp:: auth:: compute_auth_statuses;
17
+ use codex_core:: protocol:: McpAuthStatus ;
16
18
use codex_rmcp_client:: delete_oauth_tokens;
17
19
use codex_rmcp_client:: perform_oauth_login;
18
20
@@ -340,11 +342,20 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
340
342
341
343
let mut entries: Vec < _ > = config. mcp_servers . iter ( ) . collect ( ) ;
342
344
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 ;
343
350
344
351
if list_args. json {
345
352
let json_entries: Vec < _ > = entries
346
353
. into_iter ( )
347
354
. map ( |( name, cfg) | {
355
+ let auth_status = auth_statuses
356
+ . get ( name. as_str ( ) )
357
+ . copied ( )
358
+ . unwrap_or ( McpAuthStatus :: Unsupported ) ;
348
359
let transport = match & cfg. transport {
349
360
McpServerTransportConfig :: Stdio { command, args, env } => serde_json:: json!( {
350
361
"type" : "stdio" ,
@@ -374,6 +385,7 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
374
385
"tool_timeout_sec" : cfg
375
386
. tool_timeout_sec
376
387
. map( |timeout| timeout. as_secs_f64( ) ) ,
388
+ "auth_status" : auth_status,
377
389
} )
378
390
} )
379
391
. collect ( ) ;
@@ -387,8 +399,8 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
387
399
return Ok ( ( ) ) ;
388
400
}
389
401
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 ( ) ;
392
404
393
405
for ( name, cfg) in entries {
394
406
match & cfg. transport {
@@ -416,12 +428,18 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
416
428
} else {
417
429
"disabled" . to_string ( )
418
430
} ;
431
+ let auth_status = auth_statuses
432
+ . get ( name. as_str ( ) )
433
+ . copied ( )
434
+ . unwrap_or ( McpAuthStatus :: Unsupported )
435
+ . to_string ( ) ;
419
436
stdio_rows. push ( [
420
437
name. clone ( ) ,
421
438
command. clone ( ) ,
422
439
args_display,
423
440
env_display,
424
441
status,
442
+ auth_status,
425
443
] ) ;
426
444
}
427
445
McpServerTransportConfig :: StreamableHttp {
@@ -433,11 +451,17 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
433
451
} else {
434
452
"disabled" . to_string ( )
435
453
} ;
454
+ let auth_status = auth_statuses
455
+ . get ( name. as_str ( ) )
456
+ . copied ( )
457
+ . unwrap_or ( McpAuthStatus :: Unsupported )
458
+ . to_string ( ) ;
436
459
http_rows. push ( [
437
460
name. clone ( ) ,
438
461
url. clone ( ) ,
439
462
bearer_token_env_var. clone ( ) . unwrap_or ( "-" . to_string ( ) ) ,
440
463
status,
464
+ auth_status,
441
465
] ) ;
442
466
}
443
467
}
@@ -450,6 +474,7 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
450
474
"Args" . len ( ) ,
451
475
"Env" . len ( ) ,
452
476
"Status" . len ( ) ,
477
+ "Auth" . len ( ) ,
453
478
] ;
454
479
for row in & stdio_rows {
455
480
for ( i, cell) in row. iter ( ) . enumerate ( ) {
@@ -458,32 +483,36 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
458
483
}
459
484
460
485
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" ,
467
493
name_w = widths[ 0 ] ,
468
494
cmd_w = widths[ 1 ] ,
469
495
args_w = widths[ 2 ] ,
470
496
env_w = widths[ 3 ] ,
471
497
status_w = widths[ 4 ] ,
498
+ auth_w = widths[ 5 ] ,
472
499
) ;
473
500
474
501
for row in & stdio_rows {
475
502
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( ) ,
482
510
name_w = widths[ 0 ] ,
483
511
cmd_w = widths[ 1 ] ,
484
512
args_w = widths[ 2 ] ,
485
513
env_w = widths[ 3 ] ,
486
514
status_w = widths[ 4 ] ,
515
+ auth_w = widths[ 5 ] ,
487
516
) ;
488
517
}
489
518
}
@@ -498,6 +527,7 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
498
527
"Url" . len ( ) ,
499
528
"Bearer Token Env Var" . len ( ) ,
500
529
"Status" . len ( ) ,
530
+ "Auth" . len ( ) ,
501
531
] ;
502
532
for row in & http_rows {
503
533
for ( i, cell) in row. iter ( ) . enumerate ( ) {
@@ -506,28 +536,32 @@ async fn run_list(config_overrides: &CliConfigOverrides, list_args: ListArgs) ->
506
536
}
507
537
508
538
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" ,
514
545
name_w = widths[ 0 ] ,
515
546
url_w = widths[ 1 ] ,
516
547
token_w = widths[ 2 ] ,
517
548
status_w = widths[ 3 ] ,
549
+ auth_w = widths[ 4 ] ,
518
550
) ;
519
551
520
552
for row in & http_rows {
521
553
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( ) ,
527
560
name_w = widths[ 0 ] ,
528
561
url_w = widths[ 1 ] ,
529
562
token_w = widths[ 2 ] ,
530
563
status_w = widths[ 3 ] ,
564
+ auth_w = widths[ 4 ] ,
531
565
) ;
532
566
}
533
567
}
0 commit comments