kill_process
Terminate a running process by PID to stop unresponsive applications or manage system resources through the Desktop Commander MCP server.
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 main handler function for the kill_process tool. Parses input arguments using KillProcessArgsSchema, kills the process using Node.js process.kill(), and returns a success message or throws an error.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 input for kill_process: an object with a required 'pid' number field.export const KillProcessArgsSchema = z.object({ pid: z.number(), });
- src/server.ts:96-101 (registration)Registers the 'kill_process' tool in the MCP server's tool list, providing name, description, and input schema derived from KillProcessArgsSchema.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 (registration)Switch case in the tool call handler that parses arguments and delegates execution to the killProcess handler function.case "kill_process": { const parsed = KillProcessArgsSchema.parse(args); return killProcess(parsed); }