list_services
List all system services on a specified server to identify available services. Returns service names for further inspection of status or management.
Instructions
List all system services (systemd units or init scripts). Returns service names. Use get_service_status to check if a specific service is running.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | No | Server alias (e.g., 'pi1', 'web-server'). Uses default server if not specified. |
Implementation Reference
- src/tools/system.py:95-126 (handler)The async function `list_services` that executes the tool logic. It calls `client.call('init', 'list_actions')` to fetch services, parses each action string to extract service names, and returns a ToolResult with a count and list of services.
async def list_services(client: WebminClient) -> ToolResult: """List all system services. Args: client: Authenticated WebminClient instance. Returns: ToolResult with list of services. """ try: actions = await client.call("init", "list_actions") services = [] for action in actions: if isinstance(action, str): # Format is "service_name timestamp" parts = action.split() name = parts[0] if parts else action services.append({"name": name}) else: services.append(action) return ToolResult.ok({ "count": len(services), "services": services, }) except Exception as e: return ToolResult.fail( code="LIST_SERVICES_ERROR", message=f"Failed to list services: {e}", ) - src/server.py:133-145 (schema)The tool registration/schema definition in the TOOLS list. Defines name 'list_services', its description, and inputSchema (accepts optional 'server' parameter).
Tool( name="list_services", description=( "List all system services (systemd units or init scripts). " "Returns service names. Use get_service_status to check " "if a specific service is running." ), inputSchema={ "type": "object", "properties": {**SERVER_PARAM}, "required": [], }, ), - src/server.py:1363-1364 (registration)The dispatch handler in `call_tool` / `dispatch_tool` that routes the 'list_services' tool name to the `system.list_services(client)` handler function.
if name == "list_services": return await system.list_services(client) - src/models.py:35-67 (helper)The ToolResult model used by list_services to return success/failure responses with data or error details.
class ToolResult(BaseModel): """Generic result wrapper for MCP tool responses.""" success: bool = Field( description="Whether the operation succeeded", ) data: dict[str, Any] | None = Field( default=None, description="Result data on success", ) error: WebminError | None = Field( default=None, description="Error details on failure", ) @classmethod def ok(cls, data: dict[str, Any]) -> "ToolResult": """Create a successful result.""" return cls(success=True, data=data) @classmethod def fail( cls, code: str, message: str, details: dict[str, Any] | None = None, ) -> "ToolResult": """Create a failure result.""" return cls( success=False, error=WebminError(code=code, message=message, details=details), )