55import click
66from rich .console import Console
77from rich .prompt import Confirm
8+ from rich .markup import escape
89
9- from mcpm .clients .claude_desktop import ClaudeDesktopManager
10- from mcpm .clients .windsurf import WindsurfManager
11- from mcpm .utils .config import ConfigManager
10+ from mcpm .utils .client_manager import get_active_client_info
1211
1312console = Console ()
14- config_manager = ConfigManager ()
15- claude_manager = ClaudeDesktopManager ()
16- windsurf_manager = WindsurfManager ()
1713
1814@click .command ()
1915@click .argument ("server_name" )
@@ -25,18 +21,12 @@ def remove(server_name, force):
2521 mcpm remove filesystem
2622 mcpm remove filesystem --force
2723 """
28- # Get the active client and its corresponding manager
29- active_client = config_manager . get_active_client ()
24+ # Get the active client manager and related information
25+ client_manager , client_name , _ = get_active_client_info ()
3026
31- # Select appropriate client manager based on active client
32- if active_client == "claude-desktop" :
33- client_manager = claude_manager
34- client_name = "Claude Desktop"
35- elif active_client == "windsurf" :
36- client_manager = windsurf_manager
37- client_name = "Windsurf"
38- else :
39- console .print (f"[bold red]Error:[/] Unsupported active client: { active_client } " )
27+ # Check if client is supported
28+ if client_manager is None :
29+ console .print ("[bold red]Error:[/] Unsupported active client" )
4030 console .print ("Please switch to a supported client using 'mcpm client <client-name>'" )
4131 return
4232
@@ -46,9 +36,38 @@ def remove(server_name, force):
4636 console .print (f"[bold red]Error:[/] Server '{ server_name } ' not found in { client_name } ." )
4737 return
4838
39+ # Display server information before removal
40+ console .print (f"\n [bold cyan]Server information for:[/] { server_name } " )
41+
42+ # Server command
43+ command = getattr (server_info , "command" , "N/A" )
44+ console .print (f" Command: [green]{ command } [/]" )
45+
46+ # Display arguments
47+ args = getattr (server_info , "args" , [])
48+ if args :
49+ console .print (" Arguments:" )
50+ for i , arg in enumerate (args ):
51+ console .print (f" { i } : [yellow]{ escape (arg )} [/]" )
52+
53+ # Get package name (usually the second argument)
54+ if len (args ) > 1 :
55+ console .print (f" Package: [magenta]{ args [1 ]} [/]" )
56+
57+ # Display environment variables
58+ env_vars = getattr (server_info , "env" , {})
59+ if env_vars and len (env_vars ) > 0 :
60+ console .print (" Environment Variables:" )
61+ for key , value in env_vars .items ():
62+ console .print (f" [bold blue]{ key } [/] = [green]\" { value } \" [/]" )
63+ else :
64+ console .print (" Environment Variables: [italic]None[/]" )
65+
66+ console .print (" " + "-" * 50 )
67+
4968 # Get confirmation if --force is not used
5069 if not force :
51- console .print (f"[bold yellow]Are you sure you want to remove:[/] { server_name } " )
70+ console .print (f"\n [bold yellow]Are you sure you want to remove:[/] { server_name } " )
5271 console .print ("[italic]To bypass this confirmation, use --force[/]" )
5372 # Use Rich's Confirm for a better user experience
5473 confirmed = Confirm .ask ("Proceed with removal?" )
0 commit comments