Skip to main content
Glama
MrGNSS

Desktop Commander MCP

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;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral context. It implies a destructive action ('force terminate') but doesn't clarify permissions needed, side effects, error conditions, or what constitutes a 'terminal session'. More transparency about the operation's impact would be helpful.

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 extremely concise at just one sentence with zero wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly despite its brevity.

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, 0% schema coverage, and no output schema, the description is inadequate. It should explain more about the operation's consequences, parameter meaning, and expected outcomes given the tool's complexity and potential impact.

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%, and the description provides no information about the single parameter 'pid'. It doesn't explain what 'pid' represents, valid ranges, or format expectations, leaving the parameter completely undocumented beyond the schema's type declaration.

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 target resource ('a running terminal session'), providing specific verb+resource pairing. However, it doesn't differentiate from sibling tools like 'kill_process' which might serve similar functions, preventing a perfect 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 about when to use this tool versus alternatives like 'kill_process' or 'list_sessions'. The description lacks context about prerequisites, appropriate scenarios, or exclusions, offering only basic functional information.

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

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