Skip to main content
Glama

kill_process

Terminate a running process by PID to manage system resources and resolve unresponsive applications. Use with caution as this forcefully ends the specified process.

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
NameRequiredDescriptionDefault
pidYes

Implementation Reference

  • Handler function that receives the tool call for kill_process, parses the arguments using the schema, and delegates to the killProcess helper function.
    /**
     * Handle kill_process command
     */
    export async function handleKillProcess(args: unknown): Promise<ServerResult> {
        const parsed = KillProcessArgsSchema.parse(args);
        return killProcess(parsed);
    }
  • Core implementation function that validates arguments (with safeParse fallback), calls Node.js process.kill(pid), and returns success or error response.
    export 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,
        };
      }
    }
  • Zod schema defining the input arguments for kill_process tool: requires a numeric PID.
    export const KillProcessArgsSchema = z.object({
      pid: z.number(),
    });
  • src/server.ts:958-973 (registration)
    MCP tool registration object defining the name 'kill_process', description, input schema reference, and annotations for the ListTools response.
    {
        name: "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,
        },
    },
  • Dispatch case in the CallToolRequest handler switch statement that routes 'kill_process' calls to the handleKillProcess function.
    case "kill_process":
        result = await handlers.handleKillProcess(args);
        break;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wonderwhy-er/ClaudeComputerCommander'

If you have feedback or need assistance with the MCP directory API, please join our Discord server