Skip to main content
Glama

stop_container

Use this tool to halt a running Docker container by specifying its ID or name, ensuring efficient container management in the Docker MCP Server environment.

Instructions

Stop a running Docker container

Input Schema

NameRequiredDescriptionDefault
containerYesContainer ID or name

Input Schema (JSON Schema)

{ "properties": { "container": { "description": "Container ID or name", "type": "string" } }, "required": [ "container" ], "type": "object" }

Implementation Reference

  • The main handler function for the 'stop_container' tool. It validates the 'container' argument and executes the 'docker stop' command, returning the output as text content.
    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(), }, ], }; }
  • TypeScript interface defining the input arguments for container actions (used by both stop_container and remove_container).
    interface ContainerActionArgs { container: string; force?: boolean; }
  • src/index.ts:137-150 (registration)
    Registration of the 'stop_container' tool in the MCP server's tool list, including name, description, and input schema.
    { name: 'stop_container', description: 'Stop a running Docker container', inputSchema: { type: 'object', properties: { container: { type: 'string', description: 'Container ID or name', }, }, required: ['container'], }, },
  • src/index.ts:195-196 (registration)
    Dispatch case in the main CallToolRequestHandler that routes 'stop_container' calls to the stopContainer method.
    case 'stop_container': return await this.stopContainer(request.params.arguments as unknown as ContainerActionArgs);

Other Tools

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

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