Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

docker_restart

Restart Docker containers by name or ID to apply configuration changes, resolve issues, or update running services. Specify timeout and working directory for controlled container restarts.

Instructions

Restart one or more containers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containersYesContainer name(s) or ID(s)
timeoutNoSeconds to wait before killing container
cwdNoWorking directory

Implementation Reference

  • The core handler function that constructs and executes the 'docker restart' command using the shared executeDockerCommand helper, handling single or multiple containers with optional timeout.
    export async function dockerRestart(args: z.infer<typeof dockerRestartSchema>): Promise<ToolResponse> {
      const containers = Array.isArray(args.containers) ? args.containers.join(' ') : args.containers;
      const timeoutFlag = args.timeout ? `-t ${args.timeout}` : '';
      return executeDockerCommand(`docker restart ${timeoutFlag} ${containers}`.trim(), args.cwd);
    }
  • Zod schema defining the input parameters for validation in the docker_restart tool handler.
    export const dockerRestartSchema = z.object({
      containers: z.union([z.string(), z.array(z.string())]).describe('Container name(s) or ID(s)'),
      timeout: z.number().optional().describe('Seconds to wait before killing container'),
      cwd: z.string().optional().describe('Working directory')
    });
  • src/index.ts:463-466 (registration)
    MCP server dispatch logic that handles 'docker_restart' tool calls by validating args with dockerRestartSchema and invoking the dockerRestart handler.
    if (name === 'docker_restart') {
      const validated = dockerRestartSchema.parse(args);
      return await dockerRestart(validated);
    }
  • Tool registration object in dockerTools array providing MCP-compatible name, description, and JSON inputSchema; included in server's listTools response.
    {
      name: 'docker_restart',
      description: 'Restart one or more containers',
      inputSchema: {
        type: 'object',
        properties: {
          containers: {
            oneOf: [
              { type: 'string' },
              { type: 'array', items: { type: 'string' } }
            ],
            description: 'Container name(s) or ID(s)'
          },
          timeout: { type: 'number', description: 'Seconds to wait before killing container' },
          cwd: { type: 'string', description: 'Working directory' }
        },
        required: ['containers']
      }
    },
  • Shared helper function that executes Docker commands via child_process.execAsync, formats success/error responses in ToolResponse format, and handles timeouts/buffers.
    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
        };
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'restart' implies a mutation operation, the description doesn't disclose important behavioral aspects: whether this requires specific permissions, what happens to running processes, whether data is preserved, or what the expected response looks like. For a mutation tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core purpose without any wasted words. It's appropriately sized for a straightforward tool and gets directly to the point with no unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens during restart, what the tool returns, error conditions, or important behavioral context. Given the complexity of container operations and the lack of structured metadata, the description should provide more operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing good documentation for all parameters. The description adds no parameter-specific information beyond what's already in the schema. With complete schema coverage, the baseline score of 3 is appropriate - the schema does the heavy lifting, and the description doesn't add value in this dimension.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('restart') and target ('one or more containers'), providing a specific verb+resource combination. It distinguishes itself from sibling tools like docker_start and docker_stop by focusing on restarting rather than starting or stopping containers. However, it doesn't explicitly differentiate from all possible alternatives in the Docker ecosystem.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when restarting is appropriate versus starting/stopping separately, nor does it address prerequisites like container state or permissions. With multiple Docker sibling tools available, this lack of contextual guidance is a significant gap.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ConnorBoetig-dev/mcp2'

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