Skip to main content
Glama

stop_container

Stop a running Docker container by specifying its ID or name. This tool halts container execution for management or resource conservation.

Instructions

Stop a running Docker container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerYesContainer ID or name

Implementation Reference

  • The handler function implementing the 'stop_container' tool logic: validates input and executes 'docker stop' command.
    private async stopContainer(args: ContainerActionArgs) {
      if (!args.container) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Container parameter is required'
        );
      }
      
      const { stdout } = await execAsync(`docker stop ${args.container}`);
      
      return {
        content: [
          {
            type: 'text',
            text: stdout.trim(),
          },
        ],
      };
    }
  • Type/interface definition for arguments used in stop_container (and remove_container).
    interface ContainerActionArgs {
      container: string;
      force?: boolean;
    }
  • src/index.ts:138-150 (registration)
    Tool registration in list_tools handler: defines name, description, and input schema for 'stop_container'.
      name: 'stop_container',
      description: 'Stop a running Docker container',
      inputSchema: {
        type: 'object',
        properties: {
          container: {
            type: 'string',
            description: 'Container ID or name',
          },
        },
        required: ['container'],
      },
    },
  • Dispatcher in CallToolRequestSchema handler that invokes the stopContainer method for 'stop_container' tool.
    case 'stop_container':
      return await this.stopContainer(request.params.arguments as unknown as ContainerActionArgs);

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

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