1- """Deploy command for MCP Agent Cloud CLI.
1+ """Deploy command for mcp-agent cloud CLI.
22
33This module provides the deploy_config function which processes configuration files
44with secret tags and transforms them into deployment-ready configurations with secret handles.
99from typing import Optional
1010
1111import typer
12- from rich .panel import Panel
1312from rich .progress import Progress , SpinnerColumn , TextColumn
1413
1514from mcp_agent .cli .auth import load_api_key_credentials
3029)
3130from mcp_agent .cli .utils .retry import retry_async_with_exponential_backoff , RetryError
3231from mcp_agent .cli .utils .ux import (
33- console ,
3432 print_deployment_header ,
3533 print_error ,
3634 print_info ,
@@ -130,7 +128,7 @@ def deploy_config(
130128 resolve_path = True ,
131129 ),
132130) -> str :
133- """Deploy an MCP agent using the specified configuration.
131+ """Deploy an mcp- agent using the specified configuration.
134132
135133 An MCP App is deployed from bundling the code at the specified config directory.
136134 This directory must contain an 'mcp_agent.config.yaml' at its root. The process will look for an existing
@@ -176,18 +174,15 @@ def deploy_config(
176174 if app_name is None :
177175 if default_app_name :
178176 print_info (
179- f"No app name provided. Using '{ default_app_name } ' from configuration. "
177+ f"Using app name from config.yaml: '{ default_app_name } '"
180178 )
181179 app_name = default_app_name
182180 else :
183181 app_name = "default"
184- print_info ("No app name provided. Using 'default' as app name. " )
182+ print_info ("Using app name: 'default'" )
185183
186184 if app_description is None :
187185 if default_app_description :
188- print_info (
189- "No app description provided. Using description from configuration."
190- )
191186 app_description = default_app_description
192187
193188 provided_key = api_key
@@ -203,40 +198,50 @@ def deploy_config(
203198 )
204199 if not effective_api_key :
205200 raise CLIError (
206- "Must be logged in to deploy. Run 'mcp-agent login', set MCP_API_KEY environment variable or specify --api-key option." ,
201+ "You need to be logged in to deploy.\n \n "
202+ "To continue, do one of the following:\n "
203+ " • Run: mcp-agent login\n "
204+ " • Or set the MCP_API_KEY environment variable\n "
205+ " • Or use the --api-key flag with your key" ,
207206 retriable = False ,
208207 )
209- print_info (f"Using API at { effective_api_url } " )
208+
209+ if settings .VERBOSE :
210+ print_info (f"Using API at { effective_api_url } " )
210211
211212 mcp_app_client = MCPAppClient (
212213 api_url = effective_api_url , api_key = effective_api_key
213214 )
214215
215- print_info (f"Checking for existing app ID for '{ app_name } '..." )
216+ if settings .VERBOSE :
217+ print_info (f"Checking for existing app ID for '{ app_name } '..." )
218+
216219 try :
217220 app_id = run_async (mcp_app_client .get_app_id_by_name (app_name ))
218221 if not app_id :
219- print_info (
220- f"No existing app found with name '{ app_name } '. Creating a new app..."
221- )
222+ print_info (f"App '{ app_name } ' not found — creating a new one..." )
222223 app = run_async (
223224 mcp_app_client .create_app (
224225 name = app_name , description = app_description
225226 )
226227 )
227228 app_id = app .appId
228- print_success (f"Created new app with ID: { app_id } " )
229+ print_success (f"Created new app '{ app_name } '" )
230+ if settings .VERBOSE :
231+ print_info (f"New app id: `{ app_id } `" )
229232 else :
233+ short_id = f"{ app_id [:8 ]} …"
230234 print_success (
231- f"Found existing app with ID: { app_id } for name ' { app_name } ' "
235+ f"Found existing app ' { app_name } ' ( ID: ` { short_id } `) "
232236 )
233237 if not non_interactive :
234238 use_existing = typer .confirm (
235- f"Do you want deploy an update to the existing app ID: { app_id } ?" ,
239+ f"Deploy an update to ' { app_name } ' ( ID: ` { short_id } `) ?" ,
236240 default = True ,
237241 )
238242 if use_existing :
239- print_info (f"Will deploy an update to app ID: { app_id } " )
243+ if settings .VERBOSE :
244+ print_info (f"Will deploy an update to app ID: `{ app_id } `" )
240245 else :
241246 print_error (
242247 "Cancelling deployment. Please choose a different app name."
@@ -257,25 +262,21 @@ def deploy_config(
257262 # If a deployed secrets file already exists, determine if it should be used or overwritten
258263 if deployed_secrets_file :
259264 if secrets_file :
260- print_info (
261- f"Both '{ MCP_SECRETS_FILENAME } ' and '{ MCP_DEPLOYED_SECRETS_FILENAME } ' found in { config_dir } ."
262- )
265+ if settings .VERBOSE :
266+ print_info (
267+ f"Both '{ MCP_SECRETS_FILENAME } ' and '{ MCP_DEPLOYED_SECRETS_FILENAME } ' found in { config_dir } ."
268+ )
263269 if non_interactive :
264270 print_info (
265- "-- non-interactive specified, using existing deployed secrets file without changes ."
271+ "Running in non-interactive mode — reusing previously deployed secrets."
266272 )
267273 else :
268274 reuse = typer .confirm (
269- f"Do you want to reuse the previously deployed secrets in '{ MCP_DEPLOYED_SECRETS_FILENAME } '?" ,
275+ f"Re-use the deployed secrets from '{ MCP_DEPLOYED_SECRETS_FILENAME } '?" ,
270276 default = True ,
271277 )
272278 if not reuse :
273- print_info (
274- f"Will update existing '{ MCP_DEPLOYED_SECRETS_FILENAME } ' by re-processing '{ MCP_SECRETS_FILENAME } '."
275- )
276- deployed_secrets_file = None # Will trigger re-processing
277- else :
278- print_info (f"Using existing '{ MCP_DEPLOYED_SECRETS_FILENAME } '." )
279+ deployed_secrets_file = None # Will trigger re-processing)
279280 else :
280281 print_info (
281282 f"Found '{ MCP_DEPLOYED_SECRETS_FILENAME } ' in { config_dir } , but no '{ MCP_SECRETS_FILENAME } ' to re-process. Using existing deployed secrets file."
@@ -287,7 +288,7 @@ def deploy_config(
287288
288289 secrets_transformed_path = None
289290 if secrets_file and not deployed_secrets_file :
290- print_info ("Processing secrets file..." )
291+ # print_info("Processing secrets file...")
291292 secrets_transformed_path = config_dir / MCP_DEPLOYED_SECRETS_FILENAME
292293
293294 run_async (
@@ -301,21 +302,14 @@ def deploy_config(
301302 )
302303
303304 print_success ("Secrets file processed successfully" )
304- print_info (
305- f"Transformed secrets file written to { secrets_transformed_path } "
306- )
305+ if settings .VERBOSE :
306+ print_info (
307+ f"Transformed secrets file written to { secrets_transformed_path } "
308+ )
307309
308310 else :
309311 print_info ("Skipping secrets processing..." )
310312
311- console .print (
312- Panel (
313- "Ready to deploy MCP Agent with processed configuration" ,
314- title = "Deployment Ready" ,
315- border_style = "green" ,
316- )
317- )
318-
319313 # Optionally create a local git tag as a breadcrumb of this deployment
320314 if git_tag :
321315 git_meta = get_git_metadata (config_dir )
@@ -325,7 +319,7 @@ def deploy_config(
325319 ts = datetime .now (timezone .utc ).strftime ("%Y%m%d-%H%M%S" )
326320 tag_name = f"mcp-deploy/{ safe_name } /{ ts } -{ git_meta .short_sha } "
327321 msg = (
328- f"MCP Agent deploy for app '{ app_name } ' (id { app_id } )\n "
322+ f"mcp-agent deploy for app '{ app_name } ' (ID: ` { app_id } ` )\n "
329323 f"Commit: { git_meta .commit_sha } \n "
330324 f"Branch: { git_meta .branch or '' } \n "
331325 f"Dirty: { git_meta .dirty } "
@@ -358,7 +352,7 @@ def deploy_config(
358352 )
359353 )
360354
361- print_info (f"App ID: { app_id } " )
355+ print_info (f"App Name ' { app_name } ' " )
362356 if app .appServerInfo :
363357 status = (
364358 "ONLINE"
@@ -463,7 +457,8 @@ async def _perform_api_deployment():
463457 raise
464458
465459 if retry_count > 1 :
466- print_info (f"Deployment API configured with up to { retry_count } attempts" )
460+ if settings .VERBOSE :
461+ print_info (f"Deployment API configured with up to { retry_count } attempts" )
467462
468463 try :
469464 return await retry_async_with_exponential_backoff (
0 commit comments