3131 print_error ,
3232 print_info ,
3333 print_success ,
34+ LOG_VERBOSE ,
35+ print_verbose ,
3436)
3537from mcp_agent .cli .utils .git_utils import (
3638 get_git_metadata ,
@@ -130,6 +132,12 @@ def deploy_config(
130132 file_okay = True ,
131133 resolve_path = True ,
132134 ),
135+ verbose : bool = typer .Option (
136+ False ,
137+ "--verbose" ,
138+ "-v" ,
139+ help = "Enable verbose output for this command" ,
140+ ),
133141) -> str :
134142 """Deploy an mcp-agent using the specified configuration.
135143
@@ -152,6 +160,9 @@ def deploy_config(
152160 Returns:
153161 Newly-deployed MCP App ID
154162 """
163+ if verbose :
164+ LOG_VERBOSE .set (True )
165+
155166 try :
156167 if config_dir is None :
157168 resolved_config_dir = working_dir
@@ -209,15 +220,13 @@ def deploy_config(
209220 retriable = False ,
210221 )
211222
212- if ctx .obj .get ("verbose" , False ):
213- print_info (f"Using API at { effective_api_url } " )
223+ print_verbose (f"Using API at { effective_api_url } " )
214224
215225 mcp_app_client = MCPAppClient (
216226 api_url = effective_api_url , api_key = effective_api_key
217227 )
218228
219- if ctx .obj .get ("verbose" , False ):
220- print_info (f"Checking for existing app ID for '{ app_name } '..." )
229+ print_verbose (f"Checking for existing app ID for '{ app_name } '..." )
221230
222231 try :
223232 app_id = run_async (mcp_app_client .get_app_id_by_name (app_name ))
@@ -232,8 +241,7 @@ def deploy_config(
232241 )
233242 app_id = app .appId
234243 print_success (f"Created new app '{ app_name } '" )
235- if ctx .obj .get ("verbose" , False ):
236- print_info (f"New app id: `{ app_id } `" )
244+ print_verbose (f"New app id: `{ app_id } `" )
237245 else :
238246 short_id = f"{ app_id [:8 ]} …"
239247 print_success (f"Found existing app '{ app_name } ' (ID: `{ short_id } `)" )
@@ -243,8 +251,7 @@ def deploy_config(
243251 default = True ,
244252 )
245253 if use_existing :
246- if ctx .obj .get ("verbose" , False ):
247- print_info (f"Will deploy an update to app ID: `{ app_id } `" )
254+ print_verbose (f"Will deploy an update to app ID: `{ app_id } `" )
248255 else :
249256 print_error (
250257 "Cancelling deployment. Please choose a different app name."
@@ -261,8 +268,7 @@ def deploy_config(
261268 update_payload ["unauthenticated_access" ] = unauthenticated_access
262269
263270 if update_payload :
264- if ctx .obj .get ("verbose" , False ):
265- print_info ("Updating app settings before deployment..." )
271+ print_verbose ("Updating app settings before deployment..." )
266272 run_async (
267273 mcp_app_client .update_app (
268274 app_id = app_id ,
@@ -280,10 +286,9 @@ def deploy_config(
280286 # If a deployed secrets file already exists, determine if it should be used or overwritten
281287 if deployed_secrets_file :
282288 if secrets_file :
283- if ctx .obj .get ("verbose" , False ):
284- print_info (
285- f"Both '{ MCP_SECRETS_FILENAME } ' and '{ MCP_DEPLOYED_SECRETS_FILENAME } ' found in { config_dir } ."
286- )
289+ print_verbose (
290+ f"Both '{ MCP_SECRETS_FILENAME } ' and '{ MCP_DEPLOYED_SECRETS_FILENAME } ' found in { config_dir } ."
291+ )
287292 if non_interactive :
288293 print_info (
289294 "Running in non-interactive mode — reusing previously deployed secrets."
@@ -320,10 +325,9 @@ def deploy_config(
320325 )
321326
322327 print_success ("Secrets file processed successfully" )
323- if ctx .obj .get ("verbose" , False ):
324- print_info (
325- f"Transformed secrets file written to { secrets_transformed_path } "
326- )
328+ print_verbose (
329+ f"Transformed secrets file written to { secrets_transformed_path } "
330+ )
327331
328332 else :
329333 print_info ("Skipping secrets processing..." )
@@ -367,7 +371,6 @@ def deploy_config(
367371 mcp_app_client = mcp_app_client ,
368372 retry_count = retry_count ,
369373 ignore = ignore_path ,
370- verbose = ctx .obj .get ("verbose" , False ),
371374 )
372375 )
373376
@@ -390,7 +393,7 @@ def deploy_config(
390393 return app_id
391394
392395 except Exception as e :
393- if ctx . obj . get ("verbose" , False ):
396+ if LOG_VERBOSE . get ():
394397 import traceback
395398
396399 typer .echo (traceback .format_exc ())
@@ -404,7 +407,6 @@ async def _deploy_with_retry(
404407 mcp_app_client : MCPAppClient ,
405408 retry_count : int ,
406409 ignore : Optional [Path ],
407- verbose : bool = False ,
408410):
409411 """Execute the deployment operations with retry logic.
410412
@@ -425,7 +427,6 @@ async def _deploy_with_retry(
425427 api_key = api_key ,
426428 project_dir = project_dir ,
427429 ignore_file = ignore ,
428- verbose = verbose ,
429430 )
430431 except Exception as e :
431432 raise CLIError (f"Bundling failed: { str (e )} " ) from e
@@ -485,8 +486,7 @@ async def _perform_api_deployment():
485486 raise
486487
487488 if retry_count > 1 :
488- if verbose :
489- print_info (f"Deployment API configured with up to { retry_count } attempts" )
489+ print_verbose (f"Deployment API configured with up to { retry_count } attempts" )
490490
491491 try :
492492 return await retry_async_with_exponential_backoff (
0 commit comments