Skip to main content
Glama

ssh_docker_status

Check Docker container status in a specified working directory on a remote server via SSH connection.

Instructions

Check Docker container status in working directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesSSH connection ID
workingDirectoryNoWorking directory to check (defaults to current)

Implementation Reference

  • Handler function that checks Docker container status by executing 'docker ps -a' and optionally 'docker-compose ps' on the remote SSH server via the connection.
    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)}` ); } }
  • Zod schema for input validation of the ssh_docker_status tool parameters.
    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:465-475 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    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)
    Dispatch case in the CallToolRequest handler switch statement that routes to the handleDockerStatus function.
    case 'ssh_docker_status': return await this.handleDockerStatus(args);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mahathirmuh/mcp-ssh-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server