restart_container
Restart a Docker container by providing its ID or name to resolve issues or apply configuration changes.
Instructions
Restart a Docker container.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Container ID or name |
Implementation Reference
- src/docker.ts:85-89 (handler)The handler function that executes the restart_container tool logic. It uses the Docker API to restart a container by ID and returns a confirmation message.
export async function restartContainer(id: string): Promise<string> { const container = docker.getContainer(id); await container.restart(); return `Container ${id} restarted`; } - src/index.ts:90-98 (registration)Registration of the 'restart_container' MCP tool with the server, including the tool name, description, and handler that calls restartContainer.
server.tool( "restart_container", "Restart a Docker container.", { id: z.string().describe("Container ID or name") }, async ({ id }) => { const result = await restartContainer(id); return { content: [{ type: "text", text: result }] }; }, ); - src/index.ts:93-93 (schema)Input schema for restart_container tool using Zod: validates that 'id' is a required string parameter representing the container ID or name.
{ id: z.string().describe("Container ID or name") },