Execute the apps command.
(self, **kwargs)
| 54 | ] |
| 55 | |
| 56 | async def execute(self, **kwargs) -> CommandResult: |
| 57 | """Execute the apps command.""" |
| 58 | from mcp_cli.context import get_context |
| 59 | |
| 60 | try: |
| 61 | context = get_context() |
| 62 | if not context or not context.tool_manager: |
| 63 | return CommandResult( |
| 64 | success=False, |
| 65 | error="No tool manager available. Please connect to a server first.", |
| 66 | ) |
| 67 | |
| 68 | # Parse subcommand from args or subcommand parameter |
| 69 | subcommand = kwargs.get("subcommand", "list") |
| 70 | args = kwargs.get("args", "") |
| 71 | if args: |
| 72 | subcommand = args.strip().split()[0] if args.strip() else "list" |
| 73 | |
| 74 | if subcommand == "running": |
| 75 | return await self._show_running(context.tool_manager) |
| 76 | elif subcommand == "stop": |
| 77 | return await self._stop_all(context.tool_manager) |
| 78 | else: |
| 79 | return await self._list_app_tools(context.tool_manager) |
| 80 | |
| 81 | except Exception as e: |
| 82 | return CommandResult( |
| 83 | success=False, |
| 84 | error=f"Failed to execute apps command: {e}", |
| 85 | ) |
| 86 | |
| 87 | async def _list_app_tools(self, tool_manager) -> CommandResult: |
| 88 | """List all tools that have MCP Apps interactive UIs.""" |
nothing calls this directly
no test coverage detected