@@ -9,6 +9,7 @@ import fs from 'node:fs';
99import net from 'node:net' ;
1010
1111import { logger } from '../logger.js' ;
12+ import { START_INDICATOR } from '../server.js' ;
1213import type { CallToolResult } from '../third_party/index.js' ;
1314import { PipeTransport } from '../third_party/index.js' ;
1415
@@ -56,7 +57,7 @@ export async function startDaemon(mcpArgs: string[] = []) {
5657 logger ( 'Starting daemon...' ) ;
5758 const child = spawn ( process . execPath , [ DAEMON_SCRIPT_PATH , ...mcpArgs ] , {
5859 detached : true ,
59- stdio : 'ignore' ,
60+ stdio : [ 'ignore' , 'ignore' , 'pipe' ] ,
6061 cwd : process . cwd ( ) ,
6162 } ) ;
6263
@@ -72,8 +73,19 @@ export async function startDaemon(mcpArgs: string[] = []) {
7273 waitForFile ( getPidFilePath ( ) ) . then ( resolve ) . catch ( reject ) ;
7374 } ) ;
7475
75- child . unref ( ) ;
7676 logger ( `Pid file found ${ getPidFilePath ( ) } ` ) ;
77+
78+ child . stderr . pipe ( process . stderr ) ;
79+ await new Promise < void > ( resolve => {
80+ child . stderr . on ( 'data' , data => {
81+ if ( data . toString ( ) . includes ( START_INDICATOR ) ) {
82+ child . stderr . unpipe ( process . stderr ) ;
83+ child . stderr . destroy ( ) ;
84+ child . unref ( ) ;
85+ resolve ( ) ;
86+ }
87+ } ) ;
88+ } ) ;
7789}
7890
7991const SEND_COMMAND_TIMEOUT = 60_000 ; // ms
0 commit comments