ssh_docker_status
Check Docker container status on remote servers via SSH connection to monitor running services and troubleshoot issues in specified directories.
Instructions
Check Docker container status in working directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connectionId | Yes | SSH connection ID | |
| workingDirectory | No | Working directory to check (defaults to current) |
Implementation Reference
- src/index.ts:1440-1484 (handler)The handler function that implements the core logic of the 'ssh_docker_status' tool. It validates input using DockerStatusSchema, retrieves the SSH connection context, executes 'docker ps -a' and optionally 'docker-compose ps' to check container and compose status, and returns the formatted output.private async handleDockerStatus(args: unknown) { const params = DockerStatusSchema.parse(args); const context = connectionContexts.get(params.connectionId); if (!context) { throw new McpError( ErrorCode.InvalidParams, `Connection ID '${params.connectionId}' not found` ); } try { const workingDir = params.workingDirectory || context.currentWorkingDirectory; // Get Docker container status const psResult = await context.ssh.execCommand('docker ps -a', { cwd: workingDir, }); // Get Docker Compose status if compose file exists let composeStatus = ''; if (workingDir) { const composeResult = await context.ssh.execCommand('docker-compose ps', { cwd: workingDir, }); if (composeResult.code === 0) { composeStatus = `\n\nDocker Compose Status:\n${composeResult.stdout}`; } } return { content: [ { type: 'text', text: `Docker Status (${workingDir || 'current directory'}):\n\nContainer Status:\n${psResult.stdout}${composeStatus}`, }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get Docker status: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:171-174 (schema)Zod schema defining the input parameters for the 'ssh_docker_status' tool: connectionId (required) and optional workingDirectory.const DockerStatusSchema = z.object({ connectionId: z.string().describe('SSH connection ID'), workingDirectory: z.string().optional().describe('Working directory to check (defaults to current)') });
- src/index.ts:464-475 (registration)Tool registration in the ListTools response, defining name, description, and inputSchema for 'ssh_docker_status'.{ name: 'ssh_docker_status', description: 'Check Docker container status in working directory', inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'SSH connection ID' }, workingDirectory: { type: 'string', description: 'Working directory to check (defaults to current)' } }, required: ['connectionId'] }, },
- src/index.ts:519-520 (registration)Registration of the tool handler in the CallToolRequestSchema switch statement, mapping 'ssh_docker_status' to handleDockerStatus method.case 'ssh_docker_status': return await this.handleDockerStatus(args);