docker_pull
Pull Docker images from registries to your development environment. Download specific images or all tagged versions for container deployment.
Instructions
Pull an image or repository from a registry
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes | Image name and tag (e.g., "nginx:latest") | |
| allTags | No | Download all tagged images | |
| cwd | No | Working directory |
Implementation Reference
- src/tools/docker.ts:291-294 (handler)The main handler function that executes the 'docker pull' command by constructing the docker pull CLI command and calling the shared executeDockerCommand helper.export async function dockerPull(args: z.infer<typeof dockerPullSchema>): Promise<ToolResponse> { const allTagsFlag = args.allTags ? '-a' : ''; return executeDockerCommand(`docker pull ${allTagsFlag} ${args.image}`.trim(), args.cwd); }
- src/tools/docker.ts:154-158 (schema)Zod schema defining the input validation for the docker_pull tool, used in the dispatch handler.export const dockerPullSchema = z.object({ image: z.string().describe('Image name and tag (e.g., "nginx:latest")'), allTags: z.boolean().optional().default(false).describe('Download all tagged images'), cwd: z.string().optional().describe('Working directory') });
- src/index.ts:479-482 (registration)Dispatch/registration logic in the main MCP server handler that matches tool name 'docker_pull', validates args with schema, and invokes the handler function.if (name === 'docker_pull') { const validated = dockerPullSchema.parse(args); return await dockerPull(validated); }
- src/tools/docker.ts:509-521 (registration)Tool metadata registration in the dockerTools array, including JSON schema for MCP tool listing, exported and used in index.ts listTools handler.{ name: 'docker_pull', description: 'Pull an image or repository from a registry', inputSchema: { type: 'object', properties: { image: { type: 'string', description: 'Image name and tag (e.g., "nginx:latest")' }, allTags: { type: 'boolean', default: false, description: 'Download all tagged images' }, cwd: { type: 'string', description: 'Working directory' } }, required: ['image'] } },
- src/tools/docker.ts:21-62 (helper)Shared helper function that executes docker CLI commands via child_process.exec, handles output/error formatting in MCP ToolResponse format, used by dockerPull.async function executeDockerCommand(command: string, cwd?: string): Promise<ToolResponse> { try { const { stdout, stderr } = await execAsync(command, { cwd: cwd || process.cwd(), shell: '/bin/bash', maxBuffer: 10 * 1024 * 1024, // 10MB buffer for logs timeout: 60000 // 60 second timeout for builds }); return { content: [ { type: "text" as const, text: JSON.stringify({ success: true, command: command, stdout: stdout.trim(), stderr: stderr.trim(), cwd: cwd || process.cwd() }, null, 2) } ] }; } catch (error: any) { return { content: [ { type: "text" as const, text: JSON.stringify({ success: false, command: command, stdout: error.stdout?.trim() || '', stderr: error.stderr?.trim() || error.message, exitCode: error.code || 1, cwd: cwd || process.cwd() }, null, 2) } ], isError: true }; } }