Skip to main content
Glama

start_process

Launch and monitor long-running terminal processes while capturing output to log files for tracking and analysis.

Instructions

Start a long-running process and capture its output to a log file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUnique process identifier
commandYesCommand to execute
cwdNoWorking directory (optional)

Implementation Reference

  • The implementation of the start_process handler in ProcessManager.
    async startProcess(input: StartProcessInput): Promise<{ id: string; status: 'started' }> {
      if (!input.command || input.command.trim() === '') {
        throw new Error('Command is required');
      }
    
      if (this.processes.has(input.id)) {
        throw new Error(`Process '${input.id}' is already running`);
      }
    
      const logFile = path.join(this.logService.logsDir, `${input.id}.log`);
    
      const childProcess = spawn(input.command, [], {
        shell: true,
        cwd: input.cwd || process.cwd(),
        stdio: ['ignore', 'pipe', 'pipe'],
      });
    
      // Stream stdout and stderr to log file
      childProcess.stdout?.on('data', (data) => {
        this.logService.appendLog(logFile, data.toString());
      });
    
      childProcess.stderr?.on('data', (data) => {
        this.logService.appendLog(logFile, data.toString());
      });
    
      this.processes.set(input.id, {
        id: input.id,
        process: childProcess,
        logFile,
        status: 'running',
      });
    
      // Store log file path for retrieval after process exits
      this.logFiles.set(input.id, logFile);
    
      // Auto-cleanup when process exits naturally
      childProcess.on('exit', () => {
        this.processes.delete(input.id);
      });
    
      return { id: input.id, status: 'started' };
    }
  • src/index.ts:94-97 (registration)
    The tool execution logic routing in the MCP request handler.
    case 'start_process': {
      const result = await processManager.startProcess(args as any);
      return { content: [{ type: 'text', text: JSON.stringify(result) }] };
    }
  • src/index.ts:28-41 (registration)
    The tool registration details for start_process.
    {
      name: 'start_process',
      description: 'Start a long-running process and capture its output to a log file',
      inputSchema: {
        type: 'object',
        properties: {
          id: { type: 'string', description: 'Unique process identifier' },
          command: { type: 'string', description: 'Command to execute' },
          cwd: { type: 'string', description: 'Working directory (optional)' },
        },
        required: ['id', 'command'],
      },
    },
    {

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/h004888/mcp_terminal_process'

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