diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 6da3d8e..d075009 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -7,7 +7,7 @@ services: image: torero-local container_name: torero ports: - - "22:22" + - "2222:22" - "8001:8001" - "8080:8080" volumes: diff --git a/docker-compose.yml b/docker-compose.yml index 3b9ae47..0d68141 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: image: ghcr.io/torerodev/torero-container:latest container_name: torero ports: - - "22:22" + - "2222:22" - "8001:8001" - "8080:8080" volumes: diff --git a/opt/torero-mcp/torero_mcp/executor.py b/opt/torero-mcp/torero_mcp/executor.py index 9b07b9b..6726ab9 100644 --- a/opt/torero-mcp/torero_mcp/executor.py +++ b/opt/torero-mcp/torero_mcp/executor.py @@ -155,8 +155,15 @@ async def get_services(self) -> List[Dict[str, Any]]: raw_output = await self.execute_command(["get", "services", "--raw"]) # handle different response formats - if isinstance(raw_output, dict) and "items" in raw_output: - return raw_output["items"] + if isinstance(raw_output, dict): + if "items" in raw_output: + return raw_output["items"] + elif "services" in raw_output: + return raw_output["services"] + else: + + # if dict has no known key, raise error + raise ToreroExecutorError(f"unexpected json structure: dict with keys {list(raw_output.keys())}") elif isinstance(raw_output, list): return raw_output else: @@ -186,10 +193,15 @@ async def get_decorators(self) -> List[Dict[str, Any]]: """get all decorators.""" raw_output = await self.execute_command(["get", "decorators", "--raw"]) - if isinstance(raw_output, dict) and "decorators" in raw_output: - return raw_output["decorators"] - elif isinstance(raw_output, dict) and "items" in raw_output: - return raw_output["items"] + if isinstance(raw_output, dict): + if "decorators" in raw_output: + return raw_output["decorators"] + elif "items" in raw_output: + return raw_output["items"] + else: + + # if dict has no known key, raise error + raise ToreroExecutorError(f"unexpected json structure: dict with keys {list(raw_output.keys())}") elif isinstance(raw_output, list): return raw_output else: @@ -220,8 +232,18 @@ async def get_secrets(self) -> List[Dict[str, Any]]: """get all secrets.""" raw_output = await self.execute_command(["get", "secrets", "--raw"]) - if isinstance(raw_output, dict) and "items" in raw_output: - return raw_output["items"] + if isinstance(raw_output, dict): + if "items" in raw_output: + return raw_output["items"] + elif "secrets" in raw_output: + return raw_output["secrets"] + elif "names" in raw_output: + # Handle case where only names are returned + return raw_output["names"] + else: + + # if dict has no known key, raise error + raise ToreroExecutorError(f"unexpected json structure: dict with keys {list(raw_output.keys())}") elif isinstance(raw_output, list): return raw_output else: @@ -236,8 +258,15 @@ async def get_registries(self) -> List[Dict[str, Any]]: """get all registries.""" raw_output = await self.execute_command(["get", "registries", "--raw"]) - if isinstance(raw_output, dict) and "items" in raw_output: - return raw_output["items"] + if isinstance(raw_output, dict): + if "items" in raw_output: + return raw_output["items"] + elif "registries" in raw_output: + return raw_output["registries"] + else: + + # if dict has no known key, raise error + raise ToreroExecutorError(f"unexpected json structure: dict with keys {list(raw_output.keys())}") elif isinstance(raw_output, list): return raw_output else: