Skip to content

Commit 0316066

Browse files
Unify verbose logging configuration flags
1 parent 3580266 commit 0316066

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

src/mcp_agent/cli/cloud/commands/configure/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040

4141
def configure_app(
42+
ctx: typer.Context,
4243
app_server_url: str = typer.Option(
4344
None,
4445
"--id",
@@ -213,7 +214,7 @@ def configure_app(
213214
print_success("User secrets processed successfully")
214215

215216
except Exception as e:
216-
if settings.VERBOSE:
217+
if ctx.obj.get("verbose", False):
217218
import traceback
218219

219220
typer.echo(traceback.format_exc())

src/mcp_agent/cli/cloud/commands/deploy/main.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ def deploy_config(
209209
retriable=False,
210210
)
211211

212-
if settings.VERBOSE:
212+
if ctx.obj.get("verbose", False):
213213
print_info(f"Using API at {effective_api_url}")
214214

215215
mcp_app_client = MCPAppClient(
216216
api_url=effective_api_url, api_key=effective_api_key
217217
)
218218

219-
if settings.VERBOSE:
219+
if ctx.obj.get("verbose", False):
220220
print_info(f"Checking for existing app ID for '{app_name}'...")
221221

222222
try:
@@ -232,7 +232,7 @@ def deploy_config(
232232
)
233233
app_id = app.appId
234234
print_success(f"Created new app '{app_name}'")
235-
if settings.VERBOSE:
235+
if ctx.obj.get("verbose", False):
236236
print_info(f"New app id: `{app_id}`")
237237
else:
238238
short_id = f"{app_id[:8]}…"
@@ -243,7 +243,7 @@ def deploy_config(
243243
default=True,
244244
)
245245
if use_existing:
246-
if settings.VERBOSE:
246+
if ctx.obj.get("verbose", False):
247247
print_info(f"Will deploy an update to app ID: `{app_id}`")
248248
else:
249249
print_error(
@@ -261,7 +261,7 @@ def deploy_config(
261261
update_payload["unauthenticated_access"] = unauthenticated_access
262262

263263
if update_payload:
264-
if settings.VERBOSE:
264+
if ctx.obj.get("verbose", False):
265265
print_info("Updating app settings before deployment...")
266266
run_async(
267267
mcp_app_client.update_app(
@@ -280,7 +280,7 @@ def deploy_config(
280280
# If a deployed secrets file already exists, determine if it should be used or overwritten
281281
if deployed_secrets_file:
282282
if secrets_file:
283-
if settings.VERBOSE:
283+
if ctx.obj.get("verbose", False):
284284
print_info(
285285
f"Both '{MCP_SECRETS_FILENAME}' and '{MCP_DEPLOYED_SECRETS_FILENAME}' found in {config_dir}."
286286
)
@@ -320,7 +320,7 @@ def deploy_config(
320320
)
321321

322322
print_success("Secrets file processed successfully")
323-
if settings.VERBOSE:
323+
if ctx.obj.get("verbose", False):
324324
print_info(
325325
f"Transformed secrets file written to {secrets_transformed_path}"
326326
)
@@ -367,6 +367,7 @@ def deploy_config(
367367
mcp_app_client=mcp_app_client,
368368
retry_count=retry_count,
369369
ignore=ignore_path,
370+
verbose=ctx.obj.get("verbose", False),
370371
)
371372
)
372373

@@ -389,7 +390,7 @@ def deploy_config(
389390
return app_id
390391

391392
except Exception as e:
392-
if settings.VERBOSE:
393+
if ctx.obj.get("verbose", False):
393394
import traceback
394395

395396
typer.echo(traceback.format_exc())
@@ -403,6 +404,7 @@ async def _deploy_with_retry(
403404
mcp_app_client: MCPAppClient,
404405
retry_count: int,
405406
ignore: Optional[Path],
407+
verbose: bool = False,
406408
):
407409
"""Execute the deployment operations with retry logic.
408410
@@ -423,6 +425,7 @@ async def _deploy_with_retry(
423425
api_key=api_key,
424426
project_dir=project_dir,
425427
ignore_file=ignore,
428+
verbose=verbose,
426429
)
427430
except Exception as e:
428431
raise CLIError(f"Bundling failed: {str(e)}") from e
@@ -482,7 +485,7 @@ async def _perform_api_deployment():
482485
raise
483486

484487
if retry_count > 1:
485-
if settings.VERBOSE:
488+
if verbose:
486489
print_info(f"Deployment API configured with up to {retry_count} attempts")
487490

488491
try:

src/mcp_agent/cli/cloud/commands/deploy/wrangler_wrapper.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ def _handle_wrangler_error(e: subprocess.CalledProcessError) -> None:
112112

113113

114114
def wrangler_deploy(
115-
app_id: str, api_key: str, project_dir: Path, ignore_file: Path | None = None
115+
app_id: str,
116+
api_key: str,
117+
project_dir: Path,
118+
ignore_file: Path | None = None,
119+
verbose: bool = False,
116120
) -> None:
117121
"""Bundle the MCP Agent using Wrangler.
118122
@@ -184,7 +188,7 @@ def wrangler_deploy(
184188
else:
185189
print_info(f"Using ignore patterns from {ignore_file}")
186190
else:
187-
if settings.VERBOSE:
191+
if verbose:
188192
print_info("No ignore file provided; applying default excludes only")
189193

190194
# Copy the entire project to temp directory, excluding unwanted directories and the live secrets file
@@ -295,7 +299,7 @@ def ignore_patterns(path_str, names):
295299
},
296300
)
297301
meta_vars.update({"MCP_DEPLOY_WORKSPACE_HASH": bundle_hash})
298-
if settings.VERBOSE:
302+
if verbose:
299303
print_info(
300304
f"Deploying from non-git workspace (hash {bundle_hash[:12]}…)"
301305
)

src/mcp_agent/cli/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import typer
1616
from rich.console import Console
1717

18+
from mcp_agent.cli.config import settings
1819
from mcp_agent.cli.utils.ux import print_error
1920
from mcp_agent.cli.utils.version_check import maybe_warn_newer_version
2021

@@ -122,8 +123,10 @@ def main(
122123
) -> None:
123124
"""mcp-agent command line interface."""
124125
# Persist global options on context for subcommands
126+
unified_verbose = verbose or settings.VERBOSE
127+
125128
ctx.obj = {
126-
"verbose": verbose,
129+
"verbose": unified_verbose,
127130
"quiet": quiet,
128131
"color": color,
129132
"format": format.lower(),

0 commit comments

Comments
 (0)