Skip to main content
Glama

force_terminate

Destructive

Terminate a running terminal session by specifying its process ID to stop unresponsive or unwanted processes.

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

  • Dispatch handler for the 'force_terminate' tool call in MCP server request handler
    case "force_terminate":
        result = await handlers.handleForceTerminate(args);
        break;
  • src/server.ts:908-921 (registration)
    Tool registration in list_tools handler defining name, description, input schema, and annotations for 'force_terminate'
    {
        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,
        },
    },
  • MCP tool handler function that validates input with schema and delegates to forceTerminate implementation
    /**
     * Handle force_terminate command
     */
    export async function handleForceTerminate(args: unknown): Promise<ServerResult> {
        const parsed = ForceTerminateArgsSchema.parse(args);
        return forceTerminate(parsed);
    }
  • Zod schema defining input parameters for force_terminate tool (requires pid: number)
    export const ForceTerminateArgsSchema = z.object({
      pid: z.number(),
    });
  • Core forceTerminate function that handles argument parsing, virtual sessions, and delegates to terminalManager.forceTerminate
    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 pid = parsed.data.pid;
    
      // Handle virtual Node.js sessions (node:local)
      if (virtualNodeSessions.has(pid)) {
        virtualNodeSessions.delete(pid);
        return {
          content: [{
            type: "text",
            text: `Cleared virtual Node.js session ${pid}`
          }],
        };
      }
    
      const success = terminalManager.forceTerminate(pid);
      return {
        content: [{
          type: "text",
          text: success
            ? `Successfully initiated termination of session ${pid}`
            : `No active session found for PID ${pid}`
        }],
      };
    }
  • TerminalManager.forceTerminate method that sends SIGINT followed by SIGKILL if needed to terminate the process
    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;
        }
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=true and readOnlyHint=false, so the agent knows this is a destructive write operation. The description adds the specific target ('terminal session') which provides useful context beyond annotations, but doesn't elaborate on permissions needed, side effects, or error conditions that would be helpful for a destructive tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The first sentence is appropriately concise and front-loaded. However, the second sentence about referencing as 'DC: ...' is unnecessary meta-instruction that doesn't help the agent understand the tool's functionality, reducing overall efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no output schema and 0% parameter documentation, the description is inadequate. It doesn't explain what happens after termination, potential errors, or provide any context about the 'pid' parameter that would help the agent use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for the single 'pid' parameter, the description carries full burden but provides no information about what 'pid' represents, its format, or how to obtain it. The schema only indicates it's a number, leaving the agent guessing about proper parameter usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('force terminate') and resource ('a running terminal session'), making the purpose immediately understandable. However, it doesn't differentiate from the sibling 'kill_process' tool, which appears to serve a similar function, missing an opportunity for clear distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'kill_process' or 'interact_with_process'. It only includes irrelevant meta-instructions about referencing it as 'DC: ...', which doesn't help the agent understand appropriate usage contexts or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/wonderwhy-er/ClaudeComputerCommander'

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