Skip to main content
Glama
MrGNSS

Desktop Commander MCP

by MrGNSS

force_terminate

Terminate unresponsive terminal sessions by process ID to free system resources and restore control in Desktop Commander MCP.

Instructions

Force terminate a running terminal session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYes

Implementation Reference

  • The main handler function for the force_terminate tool. Validates input using the schema, calls terminalManager.forceTerminate(pid), and returns a formatted MCP response with success or failure message.
    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 force_terminate: requires a numeric PID.
    export const ForceTerminateArgsSchema = z.object({
      pid: z.number(),
    });
  • src/server.ts:72-77 (registration)
    Tool registration in the MCP server's listTools response, specifying name, description, and input schema.
    {
      name: "force_terminate",
      description:
        "Force terminate a running terminal session.",
      inputSchema: zodToJsonSchema(ForceTerminateArgsSchema),
    },
  • Core implementation in TerminalManager: attempts SIGINT kill, falls back to 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) {
        console.error(`Failed to terminate process ${pid}:`, error);
        return false;
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.8/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a 'force terminate' action which implies destructive behavior, but doesn't clarify permissions needed, side effects, or what happens to the terminal session. For a destructive tool with zero annotation coverage, this is insufficient.

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

Conciseness5/5

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

The description is a single, clear sentence with zero wasted words. It's appropriately sized for a simple tool and gets straight to the point without unnecessary elaboration.

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 annotations, no output schema, and 0% schema description coverage, the description is inadequate. It doesn't explain what 'force' means operationally, what permissions are required, what happens after termination, or how to identify the correct pid for a terminal session.

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?

Schema description coverage is 0%, so the description must compensate for the undocumented parameter. The description mentions terminating 'a running terminal session' but doesn't explain what 'pid' represents or how to obtain it. It adds minimal context beyond the schema's structural definition.

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. It doesn't distinguish from sibling tools like 'kill_process' which might serve a similar function, so it doesn't reach the highest score.

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?

No guidance is provided on when to use this tool versus alternatives like 'kill_process' or other process management tools. The description only states what it does, not when it's appropriate or what distinguishes it from siblings.

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