kill_process
Forcefully terminate a running process by its PID with this tool, ensuring precise control over system operations via Claude Desktop Commander MCP. Use cautiously to manage processes effectively.
Instructions
Terminate a running process by PID. Use with caution as this will forcefully terminate the specified process.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes |
Implementation Reference
- src/tools/process.ts:39-54 (handler)The core handler function that implements the kill_process tool logic. It validates input arguments, terminates the specified process using Node.js process.kill(), and returns a formatted success response or throws detailed errors.export async function killProcess(args: unknown) { const parsed = KillProcessArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for kill_process: ${parsed.error}`); } try { process.kill(parsed.data.pid); return { content: [{ type: "text", text: `Successfully terminated process ${parsed.data.pid}` }], }; } catch (error) { throw new Error(`Failed to kill process: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools/schemas.ts:19-21 (schema)Zod schema defining the expected input structure for the kill_process tool, requiring a single 'pid' property of type number.export const KillProcessArgsSchema = z.object({ pid: z.number(), });
- src/server.ts:96-101 (registration)Registers the kill_process tool in the server's ListTools response, specifying its name, description, and input schema for MCP clients.name: "kill_process", description: "Terminate a running process by PID. Use with caution as this will " + "forcefully terminate the specified process.", inputSchema: zodToJsonSchema(KillProcessArgsSchema), },
- src/server.ts:232-235 (handler)Dispatch handler in the server's CallTool request handler that parses arguments and delegates to the killProcess implementation.case "kill_process": { const parsed = KillProcessArgsSchema.parse(args); return killProcess(parsed); }