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
| Name | Required | Description | Default |
|---|---|---|---|
| container | Yes | Container ID or name |
Implementation Reference
- src/index.ts:312-330 (handler)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(), }, ], }; }
- src/index.ts:31-35 (schema)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'], }, },
- src/index.ts:195-196 (handler)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);