kill_process
Terminate a running process by its PID using the MCP server. Forcefully ends the specified process, enabling efficient process management on your computer.
Instructions
Terminate a running process by PID.
Use with caution as this will forcefully terminate the specified process.
This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes |
Implementation Reference
- src/handlers/process-handlers.ts:19-25 (handler)MCP handler function for kill_process tool that parses arguments and delegates to core killProcess function/** * Handle kill_process command */ export async function handleKillProcess(args: unknown): Promise<ServerResult> { const parsed = KillProcessArgsSchema.parse(args); return killProcess(parsed); }
- src/tools/schemas.ts:40-42 (schema)Zod schema definition for kill_process input arguments (pid: number)export const KillProcessArgsSchema = z.object({ pid: z.number(), });
- src/server.ts:918-932 (registration)Tool registration in list_tools handler: defines name, description, input schema referencename: "kill_process", description: ` Terminate a running process by PID. Use with caution as this will forcefully terminate the specified process. ${CMD_PREFIX_DESCRIPTION}`, inputSchema: zodToJsonSchema(KillProcessArgsSchema), annotations: { title: "Kill Process", readOnlyHint: false, destructiveHint: true, openWorldHint: false, }, },
- src/server.ts:1229-1231 (registration)Dispatch to handleKillProcess in call_tool request handler switch statementcase "kill_process": result = await handlers.handleKillProcess(args); break;
- src/tools/process.ts:42-62 (helper)Core implementation: parses args, calls Node.js process.kill(pid), handles errors and returns ServerResultexport async function killProcess(args: unknown): Promise<ServerResult> { const parsed = KillProcessArgsSchema.safeParse(args); if (!parsed.success) { return { content: [{ type: "text", text: `Error: Invalid arguments for kill_process: ${parsed.error}` }], isError: true, }; } try { process.kill(parsed.data.pid); return { content: [{ type: "text", text: `Successfully terminated process ${parsed.data.pid}` }], }; } catch (error) { return { content: [{ type: "text", text: `Error: Failed to kill process: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }