44
55import os
66import json
7- from datetime import datetime
87
98import click
109from rich .console import Console
@@ -94,8 +93,7 @@ def add(server_name, force=False):
9493
9594 # If no installation information is available, create minimal default values
9695 # This allows us to add the server config without full installation details
97- method_key = "default"
98- install_type = "manual"
96+ installation_method = "manual" # Single consolidated concept
9997 install_command = "echo"
10098 install_args = [f"Server { server_name } added to configuration" ]
10199 package_name = None
@@ -106,52 +104,56 @@ def add(server_name, force=False):
106104 selected_method = None # Initialize selected_method to None to avoid UnboundLocalError
107105 if installations :
108106 # Find recommended installation method or default to the first one
109- method_key = "default"
107+ method_id = "default" # ID of the method in the config
110108
111109 # First check for a recommended method
112110 for key , method in installations .items ():
113111 if method .get ("recommended" , False ):
114112 selected_method = method
115- method_key = key
113+ method_id = key
116114 break
117115
118116 # If no recommended method found, use the first one
119117 if not selected_method and installations :
120- method_key = next (iter (installations ))
121- selected_method = installations [method_key ]
118+ method_id = next (iter (installations ))
119+ selected_method = installations [method_id ]
122120
123121 # If multiple methods are available and not forced, offer selection
124122 if len (installations ) > 1 and not force :
125123 console .print ("\n [bold]Available installation methods:[/]" )
126124 methods_list = []
127125
128126 for i , (key , method ) in enumerate (installations .items (), 1 ):
129- install_type = method .get ("type" , "unknown" )
130- description = method .get ("description" , f"{ install_type } installation" )
127+ method_type = method .get ("type" , "unknown" )
128+ description = method .get ("description" , f"{ method_type } installation" )
131129 recommended = " [green](recommended)[/]" if method .get ("recommended" , False ) else ""
132130
133131 console .print (f" { i } . [cyan]{ key } [/]: { description } { recommended } " )
134132 methods_list .append (key )
135133
136134 # Ask user to select a method
137135 try :
138- selection = click .prompt ("\n Select installation method" , type = int , default = methods_list .index (method_key ) + 1 )
136+ selection = click .prompt ("\n Select installation method" , type = int , default = methods_list .index (method_id ) + 1 )
139137 if 1 <= selection <= len (methods_list ):
140- method_key = methods_list [selection - 1 ]
141- selected_method = installations [method_key ]
138+ method_id = methods_list [selection - 1 ]
139+ selected_method = installations [method_id ]
142140 except (ValueError , click .Abort ):
143141 console .print ("[yellow]Using default installation method.[/]" )
144142
145143 # Extract installation details
146144 if selected_method :
147- install_type = selected_method .get ("type" , install_type )
145+ # Use the method's type as the installation method if available, otherwise use the key
146+ installation_method = selected_method .get ("type" )
147+ if not installation_method or installation_method == "unknown" :
148+ installation_method = method_id
149+
148150 install_command = selected_method .get ("command" , install_command )
149151 install_args = selected_method .get ("args" , install_args )
150152 package_name = selected_method .get ("package" , package_name )
151153 env_vars = selected_method .get ("env" , env_vars )
152154 required_args = server_metadata .get ("required_args" , required_args )
153155
154- console .print (f"\n [green]Using { install_type } installation method: [bold]{ method_key } [/][/]" )
156+ console .print (f"\n [green]Using [bold]{ installation_method } [/] installation method [/]" )
155157
156158 # Configure the server
157159 with Progress (
@@ -311,18 +313,13 @@ def add(server_name, force=False):
311313 # Create server configuration using ServerConfig
312314 server_config = ServerConfig (
313315 name = server_name ,
314- path = server_dir ,
315316 display_name = display_name ,
316317 description = description ,
317- version = version ,
318- status = "stopped" ,
319318 command = mcp_command , # Use the actual MCP server command
320319 args = mcp_args , # Use the actual MCP server arguments
321320 env_vars = processed_env ,
322- install_date = datetime .now ().strftime ("%Y-%m-%d" ),
323- package = package_name ,
324- installation_method = method_key ,
325- installation_type = install_type
321+ # Use the simplified installation method
322+ installation = installation_method
326323 )
327324
328325 # Add the server to the client configuration
0 commit comments