Merge pull request #2 from buddhistrhythm/fix/mcpready-loopback-health

fix: decouple mcp health from loopback self-check
This commit is contained in:
Huakson Huilnner Santos Lima
2026-04-04 21:05:16 -03:00
committed by GitHub
3 changed files with 554 additions and 543 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+12 -5
View File
@@ -437,8 +437,13 @@ export class WorkerService {
}); });
} }
// Connect to MCP server // Mark MCP as externally ready once the bundled stdio server binary exists.
// Codex/Claude Desktop connect to this binary directly; the loopback client
// below is only a best-effort self-check and should not mark health false.
const mcpServerPath = path.join(__dirname, 'mcp-server.cjs'); const mcpServerPath = path.join(__dirname, 'mcp-server.cjs');
this.mcpReady = existsSync(mcpServerPath);
// Best-effort loopback MCP self-check
getSupervisor().assertCanSpawn('mcp server'); getSupervisor().assertCanSpawn('mcp server');
const transport = new StdioClientTransport({ const transport = new StdioClientTransport({
command: 'node', command: 'node',
@@ -460,7 +465,7 @@ export class WorkerService {
await Promise.race([mcpConnectionPromise, timeoutPromise]); await Promise.race([mcpConnectionPromise, timeoutPromise]);
} catch (connectionError) { } catch (connectionError) {
clearTimeout(timeoutId!); clearTimeout(timeoutId!);
logger.warn('WORKER', 'MCP server connection failed, cleaning up subprocess', { logger.warn('WORKER', 'MCP loopback self-check failed, cleaning up subprocess', {
error: connectionError instanceof Error ? connectionError.message : String(connectionError) error: connectionError instanceof Error ? connectionError.message : String(connectionError)
}); });
try { try {
@@ -468,7 +473,10 @@ export class WorkerService {
} catch { } catch {
// Best effort: the supervisor handles later process cleanup for survivors. // Best effort: the supervisor handles later process cleanup for survivors.
} }
throw connectionError; logger.info('WORKER', 'Bundled MCP server remains available for external stdio clients', {
path: mcpServerPath
});
return;
} }
clearTimeout(timeoutId!); clearTimeout(timeoutId!);
@@ -483,8 +491,7 @@ export class WorkerService {
getSupervisor().unregisterProcess('mcp-server'); getSupervisor().unregisterProcess('mcp-server');
}); });
} }
this.mcpReady = true; logger.success('WORKER', 'MCP loopback self-check connected');
logger.success('WORKER', 'MCP server connected');
// Start orphan reaper to clean up zombie processes (Issue #737) // Start orphan reaper to clean up zombie processes (Issue #737)
this.stopOrphanReaper = startOrphanReaper(() => { this.stopOrphanReaper = startOrphanReaper(() => {