Skip to main content
Glama
StrawHatAI

Claude Desktop Commander MCP

by StrawHatAI

force_terminate

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

Instructions

Force terminate a running terminal session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYes

Implementation Reference

  • Main handler function for the 'force_terminate' tool. Parses input arguments using the schema, calls the terminal manager to terminate the process, and returns a formatted response.
    export async function forceTerminate(args: unknown) { const parsed = ForceTerminateArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for force_terminate: ${parsed.error}`); } 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}` }], }; }
  • Zod schema defining the input arguments for the force_terminate tool: requires a numeric PID.
    export const ForceTerminateArgsSchema = z.object({ pid: z.number(), });
  • src/server.ts:72-77 (registration)
    Registration of the 'force_terminate' tool in the server's listTools response, specifying name, description, and input schema.
    { name: "force_terminate", description: "Force terminate a running terminal session.", inputSchema: zodToJsonSchema(ForceTerminateArgsSchema), },
  • src/server.ts:224-227 (registration)
    Dispatch handler in the server's callTool request handler that parses arguments and delegates to the forceTerminate function.
    case "force_terminate": { const parsed = ForceTerminateArgsSchema.parse(args); return forceTerminate(parsed); }
  • Core implementation in TerminalManager that force terminates a process by PID using SIGINT followed by SIGKILL if necessary.
    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) { console.error(`Failed to terminate process ${pid}:`, error); return false; } }

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/StrawHatAI/claude-dev-tools'

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