Skip to main content
Glama

kill_process

Stop a background AI agent process by specifying its PID for lifecycle control.

Instructions

Terminate a running AI agent process by PID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYesThe process ID to terminate.

Implementation Reference

  • Schema definition (name, description, inputSchema) for the 'kill_process' tool, registered alongside other tools.
    name: 'kill_process',
    description: 'Terminate a running AI agent process by PID.',
    inputSchema: {
      type: 'object',
      properties: {
        pid: {
          type: 'number',
          description: 'The process ID to terminate.',
        },
      },
      required: ['pid'],
    },
  • src/app/mcp.ts:329-330 (registration)
    Registration: dispatches the 'kill_process' tool name to handleKillProcess in the CallToolRequest handler.
    case 'kill_process':
      return this.handleKillProcess(toolArguments);
  • Handler function that validates the 'pid' argument and delegates to processService.killProcess(). Returns the response as JSON.
    private async handleKillProcess(toolArguments: any): Promise<ServerResult> {
      if (!toolArguments.pid || typeof toolArguments.pid !== 'number') {
        throw new McpError(ErrorCode.InvalidParams, 'Missing or invalid required parameter: pid');
      }
    
      const pid = toolArguments.pid;
      try {
        const response = this.processService.killProcess(pid);
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(response, null, 2)
          }]
        };
      } catch (error: any) {
        const code = /not found/.test(error.message) ? ErrorCode.InvalidParams : ErrorCode.InternalError;
        const message = code === ErrorCode.InternalError
          ? `Failed to terminate process: ${error.message}`
          : error.message;
        throw new McpError(code, message);
      }
    }
  • Helper/implementation method in ProcessService that looks up the tracked process by PID, kills it with SIGTERM, marks it as 'failed', appends termination message to stderr, and returns the result.
    killProcess(pid: number): { pid: number; status: string; message: string } {
      const processEntry = this.processManager.get(pid);
      if (!processEntry) {
        throw new Error(`Process with PID ${pid} not found`);
      }
    
      if (processEntry.status !== 'running') {
        return {
          pid,
          status: processEntry.status,
          message: 'Process already terminated',
        };
      }
    
      processEntry.process.kill('SIGTERM');
      processEntry.status = 'failed';
      processEntry.stderr += '\nProcess terminated by user';
    
      return {
        pid,
        status: 'terminated',
        message: 'Process terminated successfully',
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full behavioral disclosure. It only states 'Terminate' without mentioning side effects (e.g., data loss, unrecoverable state) or required permissions.

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

Conciseness4/5

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

The description is a single, concise sentence that front-loads the key information. It is appropriately short for a simple tool, though it could include brief additional context.

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

Completeness3/5

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

Given the tool's simplicity (1 param, no output schema, no annotations), the description is adequate but lacks mention of return values or error handling, which would aid completeness.

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

Parameters3/5

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

Schema coverage is 100%, and the description adds no extra meaning beyond the schema. The schema already describes 'pid' as 'The process ID to terminate', so the description is redundant.

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 ('Terminate') and the resource ('running AI agent process by PID'), but it does not differentiate from the sibling tool 'cleanup_processes', which may also terminate processes.

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 'cleanup_processes' or 'doctor'. There is no mention of prerequisites or conditions for usage.

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/lailai258/agent-bridge-mcp'

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