21
21
@click .command ()
22
22
@click .argument ("server_name" )
23
23
@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 ):
25
26
"""Add an MCP server to a client configuration.
26
27
27
28
Examples:
28
29
mcpm add time
29
30
mcpm add everything --force
31
+ mcpm add youtube --alias yt
30
32
"""
31
33
# Get the active client info
32
34
client = ClientRegistry .get_active_client ()
@@ -42,10 +44,12 @@ def add(server_name, force=False):
42
44
console .print (f"[bold red]Error:[/] Unsupported client '{ client } '." )
43
45
return
44
46
47
+ config_name = alias or server_name
48
+
45
49
# 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 )
47
51
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 } .[/]" )
49
53
console .print ("Use '--force' to overwrite the existing configuration." )
50
54
return
51
55
@@ -74,7 +78,7 @@ def add(server_name, force=False):
74
78
client_display_name = client_info .get ("name" , client )
75
79
76
80
# 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 '' } ?" ):
78
82
console .print ("[yellow]Operation cancelled.[/]" )
79
83
return
80
84
@@ -310,7 +314,7 @@ def add(server_name, force=False):
310
314
311
315
# Create server configuration using ServerConfig
312
316
server_config = ServerConfig (
313
- name = server_name ,
317
+ name = config_name ,
314
318
display_name = display_name ,
315
319
description = description ,
316
320
command = mcp_command , # Use the actual MCP server command
0 commit comments