Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYesContainer ID or name

Implementation Reference

  • 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 }] };
      },
    );
  • 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") },

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/ofershap/mcp-server-docker'

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