Skip to main content
Glama

force_terminate

End a specific terminal session by terminating its process using the process ID (PID). Ideal for managing unresponsive or unwanted processes efficiently.

Instructions

Force terminate a running terminal session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYes

Implementation Reference

  • Main handler function for the 'force_terminate' MCP tool. Parses input arguments using the schema, calls terminalManager.forceTerminate(pid), and returns success/error text 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 for force_terminate: requires a numeric PID.
    export const ForceTerminateArgsSchema = z.object({ pid: z.number(), });
  • src/server.ts:72-77 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema.
    { name: "force_terminate", description: "Force terminate a running terminal session.", inputSchema: zodToJsonSchema(ForceTerminateArgsSchema), },
  • Core implementation in TerminalManager class that attempts graceful (SIGINT) then forceful (SIGKILL) termination of the process by PID.
    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; } }
  • src/server.ts:224-227 (registration)
    Dispatch handler in CallToolRequest switch statement that parses args and invokes the forceTerminate handler.
    case "force_terminate": { const parsed = ForceTerminateArgsSchema.parse(args); return forceTerminate(parsed); }

Other Tools

Related Tools

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/MrGNSS/ClaudeDesktopCommander'

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