99from mcp_agent .cli .mcp_app .api_client import MCPApp , MCPAppConfiguration
1010from ...utils import (
1111 setup_authenticated_client ,
12- validate_output_format ,
12+ validate_output_format ,
1313 resolve_server ,
1414 handle_server_api_errors ,
1515 clean_server_status ,
1616)
1717from mcp_agent .cli .utils .ux import console
1818
1919
20- @handle_server_api_errors
20+ @handle_server_api_errors
2121def describe_server (
22- id_or_url : str = typer .Argument (..., help = "Server ID or app configuration ID to describe" ),
23- format : Optional [str ] = typer .Option ("text" , "--format" , help = "Output format (text|json|yaml)" ),
22+ id_or_url : str = typer .Argument (
23+ ..., help = "Server ID or app configuration ID to describe"
24+ ),
25+ format : Optional [str ] = typer .Option (
26+ "text" , "--format" , help = "Output format (text|json|yaml)"
27+ ),
2428) -> None :
2529 """Describe a specific MCP Server."""
2630 validate_output_format (format )
@@ -29,13 +33,17 @@ def describe_server(
2933 print_server_description (server , format )
3034
3135
32- def print_server_description (server : Union [MCPApp , MCPAppConfiguration ], output_format : str = "text" ) -> None :
36+ def print_server_description (
37+ server : Union [MCPApp , MCPAppConfiguration ], output_format : str = "text"
38+ ) -> None :
3339 """Print detailed description information for a server."""
34-
40+
3541 valid_formats = ["text" , "json" , "yaml" ]
3642 if output_format not in valid_formats :
37- raise CLIError (f"Invalid format '{ output_format } '. Valid options are: { ', ' .join (valid_formats )} " )
38-
43+ raise CLIError (
44+ f"Invalid format '{ output_format } '. Valid options are: { ', ' .join (valid_formats )} "
45+ )
46+
3947 if output_format == "json" :
4048 _print_server_json (server )
4149 elif output_format == "yaml" :
@@ -73,30 +81,29 @@ def _server_to_dict(server: Union[MCPApp, MCPAppConfiguration]) -> dict:
7381 server_description = server .app .description if server .app else None
7482 created_at = server .createdAt
7583 server_info = server .appServerInfo
76- underlying_app = {
77- "app_id" : server .app .appId ,
78- "name" : server .app .name
79- } if server .app else None
84+ underlying_app = (
85+ {"app_id" : server .app .appId , "name" : server .app .name }
86+ if server .app
87+ else None
88+ )
8089
8190 status_raw = server_info .status if server_info else "APP_SERVER_STATUS_OFFLINE"
8291 server_url = server_info .serverUrl if server_info else None
83-
92+
8493 data = {
8594 "id" : server_id ,
8695 "name" : server_name ,
8796 "type" : server_type ,
8897 "status" : clean_server_status (status_raw ),
8998 "server_url" : server_url ,
9099 "description" : server_description ,
91- "created_at" : created_at .isoformat () if created_at else None
100+ "created_at" : created_at .isoformat () if created_at else None ,
92101 }
93-
102+
94103 if underlying_app :
95104 data ["underlying_app" ] = underlying_app
96-
97- return data
98-
99105
106+ return data
100107
101108
102109def _print_server_text (server : Union [MCPApp , MCPAppConfiguration ]) -> None :
@@ -118,7 +125,7 @@ def _print_server_text(server: Union[MCPApp, MCPAppConfiguration]) -> None:
118125
119126 status_text = "❓ Unknown"
120127 server_url = "N/A"
121-
128+
122129 if server_info :
123130 status_text = _server_status_text (server_info .status )
124131 server_url = server_info .serverUrl
@@ -129,20 +136,24 @@ def _print_server_text(server: Union[MCPApp, MCPAppConfiguration]) -> None:
129136 f"Status: { status_text } " ,
130137 f"Server URL: [cyan]{ server_url } [/cyan]" ,
131138 ]
132-
139+
133140 if server_description :
134141 content_lines .append (f"Description: [cyan]{ server_description } [/cyan]" )
135-
142+
136143 if created_at :
137- content_lines .append (f"Created: [cyan]{ created_at .strftime ('%Y-%m-%d %H:%M:%S' )} [/cyan]" )
144+ content_lines .append (
145+ f"Created: [cyan]{ created_at .strftime ('%Y-%m-%d %H:%M:%S' )} [/cyan]"
146+ )
138147
139148 if isinstance (server , MCPAppConfiguration ) and server .app :
140- content_lines .extend ([
141- "" ,
142- "[bold]Underlying App:[/bold]" ,
143- f" App ID: [cyan]{ server .app .appId } [/cyan]" ,
144- f" App Name: [cyan]{ server .app .name } [/cyan]" ,
145- ])
149+ content_lines .extend (
150+ [
151+ "" ,
152+ "[bold]Underlying App:[/bold]" ,
153+ f" App ID: [cyan]{ server .app .appId } [/cyan]" ,
154+ f" App Name: [cyan]{ server .app .name } [/cyan]" ,
155+ ]
156+ )
146157
147158 console .print (
148159 Panel (
@@ -161,4 +172,4 @@ def _server_status_text(status: str) -> str:
161172 elif status == "APP_SERVER_STATUS_OFFLINE" :
162173 return "[red]🔴 Offline[/red]"
163174 else :
164- return "❓ Unknown"
175+ return "❓ Unknown"
0 commit comments