2424from mcp_agent .cli .exceptions import CLIError
2525from mcp_agent .cli .mcp_app .api_client import (
2626 MCPAppClient ,
27- is_valid_app_id_format ,
28- is_valid_server_url_format ,
2927)
3028from mcp_agent .cli .mcp_app .mock_client import MockMCPAppClient
3129from mcp_agent .cli .secrets .mock_client import MockSecretsClient
4139
4240
4341def configure_app (
44- app_id_or_url : str = typer .Option (
42+ app_server_url : str = typer .Option (
4543 None ,
4644 "--id" ,
4745 "-i" ,
48- help = "ID or server URL of the app to configure." ,
46+ help = "Server URL of the app to configure." ,
4947 ),
5048 secrets_file : Optional [Path ] = typer .Option (
5149 None ,
@@ -90,7 +88,7 @@ def configure_app(
9088 """Configure an MCP app with the required params (e.g. user secrets).
9189
9290 Args:
93- app_id_or_url: ID or server URL of the MCP App to configure
91+ app_server_url: Server URL of the MCP App to configure
9492 secrets_file: Path to an existing secrets file containing processed user secrets to use for configuring the app
9593 secrets_output_file: Path to write processed secrets to, if secrets are prompted. Defaults to mcp-agent.configured.secrets.yaml
9694 dry_run: Don't actually store secrets, just validate
@@ -101,8 +99,8 @@ def configure_app(
10199 Configured app ID.
102100 """
103101 # Check what params the app requires (doubles as an access check)
104- if not app_id_or_url :
105- raise CLIError ("You must provide an app ID or server URL to configure." )
102+ if not app_server_url :
103+ raise CLIError ("You must provide a server URL to configure." )
106104
107105 effective_api_key = api_key or settings .API_KEY or load_api_key_credentials ()
108106 if not effective_api_key :
@@ -122,30 +120,6 @@ def configure_app(
122120 api_url = api_url or DEFAULT_API_BASE_URL , api_key = effective_api_key
123121 )
124122
125- app_id = app_server_url = None
126- if is_valid_app_id_format (app_id_or_url ):
127- app_id = app_id_or_url
128- elif is_valid_server_url_format (app_id_or_url ):
129- app_server_url = app_id_or_url
130-
131- try :
132- app = client .get_app (app_id = app_id , server_url = app_server_url )
133- app = run_async (client .get_app (app_id = app_id , server_url = app_server_url ))
134-
135- if not app :
136- raise CLIError (f"App with ID or URL '{ app_id_or_url } ' not found." )
137-
138- app_id = app .appId
139-
140- except UnauthenticatedError as e :
141- raise CLIError (
142- "Invalid API key. Run 'mcp-agent login' or set MCP_API_KEY environment variable with new API key."
143- ) from e
144- except Exception as e :
145- raise CLIError (
146- f"Error retrieving app to configure with ID or URL { app_id_or_url } " ,
147- ) from e
148-
149123 # Cannot provide both secrets_file and secrets_output_file; either must be yaml files
150124 if secrets_file and secrets_output_file :
151125 raise CLIError (
@@ -162,20 +136,28 @@ def configure_app(
162136
163137 required_params = []
164138 try :
165- required_params = run_async (client .list_config_params (app_id = app_id ))
139+ required_params = run_async (
140+ client .list_config_params (app_server_url = app_server_url )
141+ )
142+ except UnauthenticatedError as e :
143+ raise CLIError (
144+ "Invalid API key. Run 'mcp-agent login' or set MCP_API_KEY environment variable with new API key."
145+ ) from e
166146 except Exception as e :
167- raise CLIError (f"Failed to retrieve required secrets for app { app_id } : { e } " )
147+ raise CLIError (
148+ f"Failed to retrieve required secrets for app { app_server_url } : { e } "
149+ ) from e
168150
169151 requires_secrets = len (required_params ) > 0
170152 configured_secrets = {}
171153
172154 if params :
173155 if requires_secrets :
174156 print_info (
175- f"App { app_id } requires the following ({ len (required_params )} ) user secrets: { ', ' .join (required_params )} "
157+ f"App { app_server_url } requires the following ({ len (required_params )} ) user secrets: { ', ' .join (required_params )} "
176158 )
177159 else :
178- print_info (f"App { app_id } does not require any user secrets." )
160+ print_info (f"App { app_server_url } does not require any user secrets." )
179161 raise typer .Exit (0 )
180162
181163 if requires_secrets :
@@ -187,7 +169,7 @@ def configure_app(
187169 print_configuration_header (secrets_file , secrets_output_file , dry_run )
188170
189171 print_info (
190- f"App { app_id } requires the following ({ len (required_params )} ) user secrets: { ', ' .join (required_params )} "
172+ f"App { app_server_url } requires the following ({ len (required_params )} ) user secrets: { ', ' .join (required_params )} "
191173 )
192174
193175 try :
@@ -238,10 +220,10 @@ def configure_app(
238220 raise CLIError (f"{ str (e )} " ) from e
239221
240222 else :
241- print_info (f"App { app_id } does not require any parameters." )
223+ print_info (f"App { app_server_url } does not require any parameters." )
242224 if secrets_file :
243225 raise CLIError (
244- f"App { app_id } does not require any parameters, but a secrets file was provided: { secrets_file } "
226+ f"App { app_server_url } does not require any parameters, but a secrets file was provided: { secrets_file } "
245227 )
246228
247229 if dry_run :
@@ -257,7 +239,9 @@ def configure_app(
257239
258240 try :
259241 config = run_async (
260- client .configure_app (app_id = app_id , config_params = configured_secrets )
242+ client .configure_app (
243+ app_server_url = app_server_url , config_params = configured_secrets
244+ )
261245 )
262246 progress .update (task , description = "✅ MCP App configured successfully!" )
263247 console .print (
@@ -273,4 +257,4 @@ def configure_app(
273257
274258 except Exception as e :
275259 progress .update (task , description = "❌ MCP App configuration failed" )
276- raise CLIError (f"Failed to configure app { app_id } : { str (e )} " ) from e
260+ raise CLIError (f"Failed to configure app { app_server_url } : { str (e )} " ) from e
0 commit comments