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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique process identifier | |
| command | Yes | Command to execute | |
| cwd | No | Working directory (optional) |
Implementation Reference
- src/processManager.ts:17-59 (handler)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'], }, }, {