2121@click .command ()
2222@click .argument ("server_name" )
2323@click .option ("--force" , is_flag = True , help = "Force reinstall if server is already installed" )
24- def add (server_name , force = False ):
24+ @click .option ("--alias" , help = "Alias for the server" , required = False )
25+ def add (server_name , force = False , alias = None ):
2526 """Add an MCP server to a client configuration.
2627
2728 Examples:
2829 mcpm add time
2930 mcpm add everything --force
31+ mcpm add youtube --alias yt
3032 """
3133 # Get the active client info
3234 client = ClientRegistry .get_active_client ()
@@ -42,10 +44,12 @@ def add(server_name, force=False):
4244 console .print (f"[bold red]Error:[/] Unsupported client '{ client } '." )
4345 return
4446
47+ config_name = alias or server_name
48+
4549 # Check if server already exists in client config
46- existing_server = client_manager .get_server (server_name )
50+ existing_server = client_manager .get_server (config_name )
4751 if existing_server and not force :
48- console .print (f"[yellow]Server '{ server_name } ' is already added to { client } .[/]" )
52+ console .print (f"[yellow]Server '{ config_name } ' is already added to { client } .[/]" )
4953 console .print ("Use '--force' to overwrite the existing configuration." )
5054 return
5155
@@ -74,7 +78,7 @@ def add(server_name, force=False):
7478 client_display_name = client_info .get ("name" , client )
7579
7680 # Confirm addition
77- if not force and not Confirm .ask (f"Add this server to { client_display_name } ?" ):
81+ if not force and not Confirm .ask (f"Add this server to { client_display_name } { ' as ' + alias if alias else '' } ?" ):
7882 console .print ("[yellow]Operation cancelled.[/]" )
7983 return
8084
@@ -310,7 +314,7 @@ def add(server_name, force=False):
310314
311315 # Create server configuration using ServerConfig
312316 server_config = ServerConfig (
313- name = server_name ,
317+ name = config_name ,
314318 display_name = display_name ,
315319 description = description ,
316320 command = mcp_command , # Use the actual MCP server command
0 commit comments