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
| Name | Required | Description | Default |
|---|---|---|---|
| container | Yes | Container ID or name |
Input Schema (JSON Schema)
{
"properties": {
"container": {
"description": "Container ID or name",
"type": "string"
}
},
"required": [
"container"
],
"type": "object"
}
Implementation Reference
- src/index.ts:312-330 (handler)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(), }, ], }; }
- src/index.ts:31-34 (schema)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);