2828
2929def tail_logs (
3030 app_identifier : str = typer .Argument (
31- help = "Server ID, URL, or app configuration ID to retrieve logs for"
31+ help = "App ID or app configuration ID to retrieve logs for"
3232 ),
3333 since : Optional [str ] = typer .Option (
3434 None ,
@@ -83,7 +83,7 @@ def tail_logs(
8383 mcp-agent cloud logger tail app_abc123 --limit 50
8484
8585 # Stream logs continuously
86- mcp-agent cloud logger tail https://app.mcpac.dev/abc123 --follow
86+ mcp-agent cloud logger tail app_abc123 --follow
8787
8888 # Show logs from the last hour with error filtering
8989 mcp-agent cloud logger tail app_abc123 --since 1h --grep "ERROR|WARN"
@@ -94,49 +94,48 @@ def tail_logs(
9494
9595 credentials = load_credentials ()
9696 if not credentials :
97- console . print ( "[red]Error: Not authenticated. Run 'mcp-agent login' first.[/red] " )
97+ print_error ( " Not authenticated. Run 'mcp-agent login' first." )
9898 raise typer .Exit (4 )
9999
100100 # Validate conflicting options
101101 if follow and since :
102- console . print ( "[red]Error: --since cannot be used with --follow (streaming mode)[/red] " )
102+ print_error ( " --since cannot be used with --follow (streaming mode)" )
103103 raise typer .Exit (6 )
104104
105105 if follow and limit != DEFAULT_LOG_LIMIT :
106- console . print ( "[red]Error: --limit cannot be used with --follow (streaming mode)[/red] " )
106+ print_error ( " --limit cannot be used with --follow (streaming mode)" )
107107 raise typer .Exit (6 )
108108
109109 if follow and order_by :
110- console . print ( "[red]Error: --order-by cannot be used with --follow (streaming mode)[/red] " )
110+ print_error ( " --order-by cannot be used with --follow (streaming mode)" )
111111 raise typer .Exit (6 )
112112
113113 if follow and (asc or desc ):
114- console . print ( "[red]Error: --asc/--desc cannot be used with --follow (streaming mode)[/red] " )
114+ print_error ( " --asc/--desc cannot be used with --follow (streaming mode)" )
115115 raise typer .Exit (6 )
116116
117117 # Validate order_by values
118118 if order_by and order_by not in ["timestamp" , "severity" ]:
119- console . print ( "[red]Error: --order-by must be 'timestamp' or 'severity'[/red] " )
119+ print_error ( " --order-by must be 'timestamp' or 'severity'" )
120120 raise typer .Exit (6 )
121121
122122 # Validate that both --asc and --desc are not used together
123123 if asc and desc :
124- console . print ( "[red]Error: Cannot use both --asc and --desc together[/red] " )
124+ print_error ( " Cannot use both --asc and --desc together" )
125125 raise typer .Exit (6 )
126126
127127 # Validate format values
128128 if format and format not in ["text" , "json" , "yaml" ]:
129- console . print ( "[red]Error: --format must be 'text', 'json', or 'yaml'[/red] " )
129+ print_error ( " --format must be 'text', 'json', or 'yaml'" )
130130 raise typer .Exit (6 )
131131
132- app_id , config_id , server_url = parse_app_identifier (app_identifier )
132+ app_id , config_id = parse_app_identifier (app_identifier )
133133
134134 try :
135135 if follow :
136136 asyncio .run (_stream_logs (
137137 app_id = app_id ,
138138 config_id = config_id ,
139- server_url = server_url ,
140139 credentials = credentials ,
141140 grep_pattern = grep ,
142141 app_identifier = app_identifier ,
@@ -146,7 +145,6 @@ def tail_logs(
146145 asyncio .run (_fetch_logs (
147146 app_id = app_id ,
148147 config_id = config_id ,
149- server_url = server_url ,
150148 credentials = credentials ,
151149 since = since ,
152150 grep_pattern = grep ,
@@ -161,14 +159,12 @@ def tail_logs(
161159 console .print ("\n [yellow]Interrupted by user[/yellow]" )
162160 sys .exit (0 )
163161 except Exception as e :
164- console .print (f"[red]Error: { e } [/red]" )
165- raise typer .Exit (5 )
162+ raise CLIError (str (e ))
166163
167164
168165async def _fetch_logs (
169166 app_id : Optional [str ],
170167 config_id : Optional [str ],
171- server_url : Optional [str ],
172168 credentials : UserCredentials ,
173169 since : Optional [str ],
174170 grep_pattern : Optional [str ],
@@ -241,17 +237,15 @@ async def _fetch_logs(
241237
242238async def _stream_logs (
243239 app_id : Optional [str ],
244- config_id : Optional [str ],
245- server_url : Optional [str ],
240+ config_id : Optional [str ],
246241 credentials : UserCredentials ,
247242 grep_pattern : Optional [str ],
248243 app_identifier : str ,
249244 format : str ,
250245) -> None :
251246 """Stream logs continuously via SSE."""
252247
253- if not server_url :
254- server_url = await resolve_server_url (app_id , config_id , credentials )
248+ server_url = await resolve_server_url (app_id , config_id , credentials )
255249
256250 parsed = urlparse (server_url )
257251 stream_url = f"{ parsed .scheme } ://{ parsed .netloc } /logs"
0 commit comments