@@ -57,17 +57,25 @@ class Server extends Base {
5757 // 3. Setup Handlers
5858 this . setupRequestHandlers ( ) ;
5959
60- // 4. Wait for Connection Service
61- await ConnectionService . ready ( ) ;
60+ // 4. Connect Transport (Stdio)
61+ // We connect early to ensure the MCP client handshake succeeds even if the Bridge is down.
62+ this . transport = new StdioServerTransport ( ) ;
63+ await this . mcpServer . connect ( this . transport ) ;
64+ logger . info ( 'Neural Link MCP Server transport connected' ) ;
65+
66+ // 5. Wait for Connection Service
67+ // This might take time if spawning a new Bridge process
68+ try {
69+ await ConnectionService . ready ( ) ;
70+ } catch ( e ) {
71+ logger . error ( 'ConnectionService failed to initialize:' , e ) ;
72+ // We do not throw here, so the server stays alive to report health errors
73+ }
6274
63- // 5 . Perform Health Check & Log Status
75+ // 6 . Perform Health Check & Log Status
6476 const health = await HealthService . healthcheck ( ) ;
6577 this . logStartupStatus ( health ) ;
6678
67- // 6. Connect Transport (Stdio)
68- this . transport = new StdioServerTransport ( ) ;
69- await this . mcpServer . connect ( this . transport ) ;
70-
7179 logger . info ( 'Neural Link MCP Server started' ) ;
7280 }
7381
@@ -119,7 +127,7 @@ class Server extends Base {
119127 if ( ! exemptFromHealthCheck . includes ( name ) ) {
120128 const health = await HealthService . healthcheck ( ) ;
121129 if ( health . status !== 'healthy' ) {
122- return {
130+ return {
123131 content : [ {
124132 type : 'text' ,
125133 text : `Cannot execute ${ name } : Neural Link is unhealthy.\nDetails: ${ health . details . join ( ', ' ) } `
0 commit comments