Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/mcp_agent/cli/cloud/commands/servers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
from .list.main import list_servers
from .describe.main import describe_server
from .delete.main import delete_server
from .workflows.main import list_workflows_for_server

__all__ = [
"list_servers",
"describe_server",
"describe_server",
"delete_server",
"list_workflows_for_server",
]
]
26 changes: 15 additions & 11 deletions src/mcp_agent/cli/cloud/commands/servers/delete/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import typer
from rich.panel import Panel

Expand All @@ -17,21 +16,25 @@

@handle_server_api_errors
def delete_server(
id_or_url: str = typer.Argument(..., help="Server ID or app configuration ID to delete"),
force: bool = typer.Option(False, "--force", "-f", help="Force deletion without confirmation prompt"),
id_or_url: str = typer.Argument(
..., help="Server ID or app configuration ID to delete"
),
force: bool = typer.Option(
False, "--force", "-f", help="Force deletion without confirmation prompt"
),
) -> None:
"""Delete a specific MCP Server."""
client = setup_authenticated_client()
server = resolve_server(client, id_or_url)

# Determine server type and delete function
if isinstance(server, MCPApp):
server_type = "Deployed Server"
delete_function = client.delete_app
else:
server_type = "Configured Server"
server_type = "Configured Server"
delete_function = client.delete_app_configuration

server_name = get_server_name(server)
server_id = get_server_id(server)

Expand All @@ -47,8 +50,10 @@ def delete_server(
expand=False,
)
)

confirm = typer.confirm(f"\nAre you sure you want to delete this {server_type.lower()}?")

confirm = typer.confirm(
f"\nAre you sure you want to delete this {server_type.lower()}?"
)
if not confirm:
print_info("Deletion cancelled.")
return
Expand All @@ -57,14 +62,14 @@ def delete_server(
can_delete = run_async(client.can_delete_app(server_id))
else:
can_delete = run_async(client.can_delete_app_configuration(server_id))

if not can_delete:
raise CLIError(
f"You do not have permission to delete this {server_type.lower()}. "
f"You can only delete servers that you created."
)
deleted_id = run_async(delete_function(server_id))

console.print(
Panel(
f"[green]✅ Successfully deleted {server_type.lower()}[/green]\n\n"
Expand All @@ -75,4 +80,3 @@ def delete_server(
expand=False,
)
)

69 changes: 40 additions & 29 deletions src/mcp_agent/cli/cloud/commands/servers/describe/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
from mcp_agent.cli.mcp_app.api_client import MCPApp, MCPAppConfiguration
from ...utils import (
setup_authenticated_client,
validate_output_format,
validate_output_format,
resolve_server,
handle_server_api_errors,
clean_server_status,
)
from mcp_agent.cli.utils.ux import console


@handle_server_api_errors
@handle_server_api_errors
def describe_server(
id_or_url: str = typer.Argument(..., help="Server ID or app configuration ID to describe"),
format: Optional[str] = typer.Option("text", "--format", help="Output format (text|json|yaml)"),
id_or_url: str = typer.Argument(
..., help="Server ID or app configuration ID to describe"
),
format: Optional[str] = typer.Option(
"text", "--format", help="Output format (text|json|yaml)"
),
) -> None:
"""Describe a specific MCP Server."""
validate_output_format(format)
Expand All @@ -29,13 +33,17 @@ def describe_server(
print_server_description(server, format)


def print_server_description(server: Union[MCPApp, MCPAppConfiguration], output_format: str = "text") -> None:
def print_server_description(
server: Union[MCPApp, MCPAppConfiguration], output_format: str = "text"
) -> None:
"""Print detailed description information for a server."""

valid_formats = ["text", "json", "yaml"]
if output_format not in valid_formats:
raise CLIError(f"Invalid format '{output_format}'. Valid options are: {', '.join(valid_formats)}")

raise CLIError(
f"Invalid format '{output_format}'. Valid options are: {', '.join(valid_formats)}"
)

if output_format == "json":
_print_server_json(server)
elif output_format == "yaml":
Expand Down Expand Up @@ -73,30 +81,29 @@ def _server_to_dict(server: Union[MCPApp, MCPAppConfiguration]) -> dict:
server_description = server.app.description if server.app else None
created_at = server.createdAt
server_info = server.appServerInfo
underlying_app = {
"app_id": server.app.appId,
"name": server.app.name
} if server.app else None
underlying_app = (
{"app_id": server.app.appId, "name": server.app.name}
if server.app
else None
)

status_raw = server_info.status if server_info else "APP_SERVER_STATUS_OFFLINE"
server_url = server_info.serverUrl if server_info else None

data = {
"id": server_id,
"name": server_name,
"type": server_type,
"status": clean_server_status(status_raw),
"server_url": server_url,
"description": server_description,
"created_at": created_at.isoformat() if created_at else None
"created_at": created_at.isoformat() if created_at else None,
}

if underlying_app:
data["underlying_app"] = underlying_app

return data


return data


def _print_server_text(server: Union[MCPApp, MCPAppConfiguration]) -> None:
Expand All @@ -118,7 +125,7 @@ def _print_server_text(server: Union[MCPApp, MCPAppConfiguration]) -> None:

status_text = "❓ Unknown"
server_url = "N/A"

if server_info:
status_text = _server_status_text(server_info.status)
server_url = server_info.serverUrl
Expand All @@ -129,20 +136,24 @@ def _print_server_text(server: Union[MCPApp, MCPAppConfiguration]) -> None:
f"Status: {status_text}",
f"Server URL: [cyan]{server_url}[/cyan]",
]

if server_description:
content_lines.append(f"Description: [cyan]{server_description}[/cyan]")

if created_at:
content_lines.append(f"Created: [cyan]{created_at.strftime('%Y-%m-%d %H:%M:%S')}[/cyan]")
content_lines.append(
f"Created: [cyan]{created_at.strftime('%Y-%m-%d %H:%M:%S')}[/cyan]"
)

if isinstance(server, MCPAppConfiguration) and server.app:
content_lines.extend([
"",
"[bold]Underlying App:[/bold]",
f" App ID: [cyan]{server.app.appId}[/cyan]",
f" App Name: [cyan]{server.app.name}[/cyan]",
])
content_lines.extend(
[
"",
"[bold]Underlying App:[/bold]",
f" App ID: [cyan]{server.app.appId}[/cyan]",
f" App Name: [cyan]{server.app.name}[/cyan]",
]
)

console.print(
Panel(
Expand All @@ -161,4 +172,4 @@ def _server_status_text(status: str) -> str:
elif status == "APP_SERVER_STATUS_OFFLINE":
return "[red]🔴 Offline[/red]"
else:
return "❓ Unknown"
return "❓ Unknown"
Loading
Loading