kill_process
Terminate running processes by PID to manage system resources and resolve unresponsive applications. Use with caution for forceful termination.
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 validates input using KillProcessArgsSchema, kills the process using Node.js process.kill(pid), 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 arguments for the kill_process tool: requires a 'pid' number.export const KillProcessArgsSchema = z.object({ pid: z.number(), });
- src/server.ts:96-101 (registration)Tool registration in the ListTools response, defining name, description, and input schema.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)Dispatch logic in the CallTool handler switch statement, which parses args and calls the killProcess handler.case "kill_process": { const parsed = KillProcessArgsSchema.parse(args); return killProcess(parsed); }
- src/server.ts:28-28 (registration)Import statement bringing in the killProcess handler function.import { listProcesses, killProcess } from './tools/process.js';