docker_registry
Search Docker Hub, authenticate, and manage container images with push, pull, and tagging operations for Docker registry workflows.
Instructions
Search Docker Hub, login/logout, push/pull operations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Registry action to perform | |
| query | No | Search query (required for search) | |
| image | No | Image name (required for push, pull, tag) | |
| tag | No | Image tag | |
| newTag | No | New tag name (required for tag action) | |
| registry | No | Registry URL (optional for login/logout) | |
| username | No | Username for login | |
| password | No | Password for login |
Implementation Reference
- src/index.ts:1675-1728 (handler)Handler function implementing Docker registry operations: search, login, logout, push, pull, tag. Constructs docker commands based on action and parameters, executes via executeDockerCommand, and returns formatted results or errors.async ({ action, query, image, tag, newTag, registry, username, password }) => { try { let command: string; switch (action) { case "search": if (!query) throw new Error("Search query is required"); command = `docker search ${query}`; break; case "login": command = `docker login${registry ? ` ${registry}` : ""}`; if (username && password) { command += ` -u ${username} -p ${password}`; } break; case "logout": command = `docker logout${registry ? ` ${registry}` : ""}`; break; case "push": if (!image) throw new Error("Image name is required for push"); command = `docker push ${image}${tag ? `:${tag}` : ""}`; break; case "pull": if (!image) throw new Error("Image name is required for pull"); command = `docker pull ${image}${tag ? `:${tag}` : ""}`; break; case "tag": if (!image || !newTag) throw new Error("Image name and new tag are required for tag action"); command = `docker tag ${image}${tag ? `:${tag}` : ""} ${newTag}`; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Registry ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error with registry operation: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/index.ts:1660-1673 (schema)Input schema defining parameters for docker_registry tool: action (enum), query, image, tag, newTag, registry, username, password with Zod validation and descriptions."docker_registry", { title: "Docker Registry Operations", description: "Search Docker Hub, login/logout, push/pull operations", inputSchema: { action: z.enum(["search", "login", "logout", "push", "pull", "tag"]).describe("Registry action to perform"), query: z.string().optional().describe("Search query (required for search)"), image: z.string().optional().describe("Image name (required for push, pull, tag)"), tag: z.string().optional().describe("Image tag"), newTag: z.string().optional().describe("New tag name (required for tag action)"), registry: z.string().optional().describe("Registry URL (optional for login/logout)"), username: z.string().optional().describe("Username for login"), password: z.string().optional().describe("Password for login") }
- src/index.ts:1658-1729 (registration)Registration of the 'docker_registry' tool with McpServer using server.registerTool, including title, description, inputSchema, and handler function.// Register Docker registry and search tool server.registerTool( "docker_registry", { title: "Docker Registry Operations", description: "Search Docker Hub, login/logout, push/pull operations", inputSchema: { action: z.enum(["search", "login", "logout", "push", "pull", "tag"]).describe("Registry action to perform"), query: z.string().optional().describe("Search query (required for search)"), image: z.string().optional().describe("Image name (required for push, pull, tag)"), tag: z.string().optional().describe("Image tag"), newTag: z.string().optional().describe("New tag name (required for tag action)"), registry: z.string().optional().describe("Registry URL (optional for login/logout)"), username: z.string().optional().describe("Username for login"), password: z.string().optional().describe("Password for login") } }, async ({ action, query, image, tag, newTag, registry, username, password }) => { try { let command: string; switch (action) { case "search": if (!query) throw new Error("Search query is required"); command = `docker search ${query}`; break; case "login": command = `docker login${registry ? ` ${registry}` : ""}`; if (username && password) { command += ` -u ${username} -p ${password}`; } break; case "logout": command = `docker logout${registry ? ` ${registry}` : ""}`; break; case "push": if (!image) throw new Error("Image name is required for push"); command = `docker push ${image}${tag ? `:${tag}` : ""}`; break; case "pull": if (!image) throw new Error("Image name is required for pull"); command = `docker pull ${image}${tag ? `:${tag}` : ""}`; break; case "tag": if (!image || !newTag) throw new Error("Image name and new tag are required for tag action"); command = `docker tag ${image}${tag ? `:${tag}` : ""} ${newTag}`; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Registry ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error with registry operation: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );