Skip to main content
Glama

force_terminate

Terminate unresponsive terminal sessions by process ID to free system resources and regain control of your command line interface.

Instructions

Force terminate a running terminal session. This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYes

Implementation Reference

  • MCP handler function for the 'force_terminate' tool. Parses input arguments using the schema and delegates to the tool implementation.
    /** * Handle force_terminate command */ export async function handleForceTerminate(args: unknown): Promise<ServerResult> { const parsed = ForceTerminateArgsSchema.parse(args); return forceTerminate(parsed); }
  • Tool implementation that validates arguments, calls terminalManager.forceTerminate(pid), and formats the response.
    export async function forceTerminate(args: unknown): Promise<ServerResult> { const parsed = ForceTerminateArgsSchema.safeParse(args); if (!parsed.success) { return { content: [{ type: "text", text: `Error: Invalid arguments for force_terminate: ${parsed.error}` }], isError: true, }; } const success = terminalManager.forceTerminate(parsed.data.pid); return { content: [{ type: "text", text: success ? `Successfully initiated termination of session ${parsed.data.pid}` : `No active session found for PID ${parsed.data.pid}` }], }; }
  • Core method in TerminalManager that force-terminates a process by PID: sends SIGINT, then SIGKILL after 1s if still active.
    forceTerminate(pid: number): boolean { const session = this.sessions.get(pid); if (!session) { return false; } try { session.process.kill('SIGINT'); setTimeout(() => { if (this.sessions.has(pid)) { session.process.kill('SIGKILL'); } }, 1000); return true; } catch (error) { // Convert error to string, handling both Error objects and other types const errorMessage = error instanceof Error ? error.message : String(error); capture('server_request_error', {error: errorMessage, message: `Failed to terminate process ${pid}:`}); return false; } }
  • Zod schema defining the input for force_terminate: requires a numeric PID.
    export const ForceTerminateArgsSchema = z.object({ pid: z.number(), });

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