66from rich .console import Console
77from rich .markup import escape
88
9+ from mcpm .clients .client_config import ClientConfigManager
910from mcpm .clients .client_registry import ClientRegistry
11+ from mcpm .utils .display import print_server_config
1012
1113console = Console ()
14+ client_config_manager = ClientConfigManager ()
15+
16+
17+ def print_server_config (server_name , server_info , is_stashed = False ):
18+ """Print detailed information about a server configuration.
19+
20+ Args:
21+ server_name: Name of the server
22+ server_info: Server configuration information
23+ is_stashed: Whether the server is stashed (affects display style)
24+ """
25+ # Server name and command
26+ if is_stashed :
27+ console .print (f"[bold yellow]{ server_name } [/] [dim](stashed)[/]" )
28+ else :
29+ console .print (f"[bold cyan]{ server_name } [/]" )
30+
31+ command = server_info .get ("command" , "N/A" )
32+ console .print (f" Command: [green]{ command } [/]" )
33+
34+ # Display arguments
35+ args = server_info .get ("args" , [])
36+ if args :
37+ console .print (" Arguments:" )
38+ for i , arg in enumerate (args ):
39+ console .print (f" { i } : [yellow]{ escape (arg )} [/]" )
40+
41+ # Display environment variables
42+ env_vars = server_info .get ("env" , {})
43+ if env_vars :
44+ console .print (" Environment Variables:" )
45+ for key , value in env_vars .items ():
46+ console .print (f' [bold blue]{ key } [/] = [green]"{ value } "[/]' )
47+ else :
48+ console .print (" Environment Variables: [italic]None[/]" )
49+
50+ # Add a separator line between servers
51+ console .print (" " + "-" * 50 )
1252
1353
1454@click .command (name = "list" )
@@ -35,37 +75,26 @@ def list():
3575 # Get all servers from active client config
3676 servers = client_manager .get_servers ()
3777
38- if not servers :
78+ # Get stashed servers
79+ stashed_servers = client_config_manager .get_stashed_servers (client )
80+
81+ if not servers and not stashed_servers :
3982 console .print (f"[yellow]No MCP servers found in { client_name } .[/]" )
4083 console .print ("Use 'mcpm add <server>' to add a server." )
4184 return
4285
4386 # Count the configured servers
4487 server_count = len (servers )
45- console . print ( f"[bold]Configured servers:[/] { server_count } \n " )
88+ stashed_count = len ( stashed_servers )
4689
47- # Display detailed information for each server
48- for server_name , server_info in servers .items ():
49- # Server name and command
50- console .print (f"[bold cyan]{ server_name } [/]" )
51- command = server_info .get ("command" , "N/A" )
52- console .print (f" Command: [green]{ command } [/]" )
53-
54- # Display arguments
55- args = server_info .get ("args" , [])
56- if args :
57- console .print (" Arguments:" )
58- for i , arg in enumerate (args ):
59- console .print (f" { i } : [yellow]{ escape (arg )} [/]" )
60-
61- # Display environment variables
62- env_vars = server_info .get ("env" , {})
63- if env_vars :
64- console .print (" Environment Variables:" )
65- for key , value in env_vars .items ():
66- console .print (f' [bold blue]{ key } [/] = [green]"{ value } "[/]' )
67- else :
68- console .print (" Environment Variables: [italic]None[/]" )
69-
70- # Add a separator line between servers
71- console .print (" " + "-" * 50 )
90+ # Print active servers
91+ if servers :
92+ console .print ("\n [bold]Active Servers:[/]" )
93+ for server_name , server_info in servers .items ():
94+ print_server_config (server_name , server_info )
95+
96+ # Print stashed servers
97+ if stashed_servers :
98+ console .print ("\n [bold]Stashed Servers:[/]" )
99+ for server_name , server_info in stashed_servers .items ():
100+ print_server_config (server_name , server_info , is_stashed = True )
0 commit comments