Skip to main content
Glama
wonderwhy-er

Claude Desktop Commander MCP

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,
        },
    },
    {
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 'force terminate' which implies a destructive action, but doesn't clarify permissions needed, side effects, error conditions, or what 'force' entails compared to regular termination. This leaves significant behavioral gaps.

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 description is reasonably concise with two sentences, but the second sentence about 'Desktop Commander' terminology adds minimal value for tool selection. The structure is front-loaded with the core purpose, but could be more focused.

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 operation with no annotations, 0% schema coverage, and no output schema, the description is inadequate. It doesn't explain the parameter, behavioral implications, success/failure conditions, or what distinguishes it from similar sibling tools.

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 'pid' parameter. The description provides no information about what 'pid' represents, its format, or valid values. This leaves the single required parameter completely unexplained.

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 ('a running terminal session'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'kill_process' or 'interact_with_process', which might have overlapping functionality.

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'. The second sentence references 'Desktop Commander' terminology but doesn't offer practical usage context 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

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

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