Skip to main content
Glama

force_terminate

Terminate any active terminal session by specifying its process ID using this MCP server command. Ideal for stopping unresponsive or unwanted processes directly from the Claude Desktop Commander 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 tool handler: parses arguments using schema and delegates to forceTerminate tool function
    /** * Handle force_terminate command */ export async function handleForceTerminate(args: unknown): Promise<ServerResult> { const parsed = ForceTerminateArgsSchema.parse(args); return forceTerminate(parsed); }
  • Core tool function: validates args, calls terminalManager.forceTerminate(pid), returns success message
    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}` }], }; }
  • TerminalManager method: sends SIGINT to process, falls back to SIGKILL after 1s if still running
    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 input schema requiring 'pid' number
    export const ForceTerminateArgsSchema = z.object({ pid: z.number(), });
  • Dispatch in MCP call_tool request handler to terminal-handlers.handleForceTerminate
    result = await handlers.handleForceTerminate(args); break; case "list_sessions":
  • src/server.ts:868-881 (registration)
    Tool definition in MCP list_tools response: name, description, schema reference, annotations
    name: "force_terminate", description: ` Force terminate a running terminal session. ${CMD_PREFIX_DESCRIPTION}`, inputSchema: zodToJsonSchema(ForceTerminateArgsSchema), annotations: { title: "Force Terminate Process", readOnlyHint: false, destructiveHint: true, openWorldHint: 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/wonderwhy-er/DesktopCommanderMCP'

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