Resolves #13877
Fatal startup failures in guarded MCP entrypoints now use the shared logger's fatalStartup() path, which preserves the existing per-server log sink and also forces one operator-visible line to stderr before the process exits. stdout remains untouched for stdio MCP protocol frames. This turns stale-config overlay crashes from a generic client-side Server disconnected into an actionable stderr message that includes the --migrate-config remediation already produced by assertConfigFresh().
Evidence: L2 (logger behavior unit coverage + cross-server guarded-entrypoint source invariant + reproduced local stale-overlay repair) -> L2 required (MCP startup diagnostics contract). No residuals.
Deltas from ticket
The implementation keeps the fix inside the existing shared MCP logger instead of adding one-off console.error() calls to each entrypoint. The entrypoints still call the shared fatal path explicitly, so normal runtime logging behavior is unchanged.
Test Evidence
- Reproduced the original failure against current
dev: Knowledge Base exited code 1 with empty stderr; repo log showed Stale config overlay and the npm run prepare -- --migrate-config fix.
- Ran
node ./ai/scripts/setup/initServerConfigs.mjs --migrate-config in the affected sibling checkouts; the same Knowledge Base and GitHub Workflow initialize probes then stayed alive after timeout.
npm run agent-preflight -- ai/mcp/server/shared/logger.mjs ai/mcp/server/memory-core/mcp-server.mjs ai/mcp/server/knowledge-base/mcp-server.mjs ai/mcp/server/github-workflow/mcp-server.mjs ai/mcp/server/gitlab-workflow/mcp-server.mjs ai/mcp/server/neural-link/mcp-server.mjs test/playwright/unit/ai/mcp/server/shared/logger.spec.mjs test/playwright/unit/ai/mcp/server/McpServerListToolsSmoke.spec.mjs passed.
npm run test-unit -- test/playwright/unit/ai/mcp/server/shared/logger.spec.mjs test/playwright/unit/ai/mcp/server/McpServerListToolsSmoke.spec.mjs passed after rebase: 37 tests.
git diff --cached --check passed before commit; git diff --check origin/dev..HEAD passed after rebase.
Post-Merge Validation
Commit
cb9641351d — fix(ai): echo MCP startup failures to stderr (#13877)
Authored by Euclid (GPT-5, Codex Desktop). Session db5b2ecf-db91-4b7d-9498-ccef00426a1c.
Resolves #13877
Fatal startup failures in guarded MCP entrypoints now use the shared logger's
fatalStartup()path, which preserves the existing per-server log sink and also forces one operator-visible line to stderr before the process exits. stdout remains untouched for stdio MCP protocol frames. This turns stale-config overlay crashes from a generic client-sideServer disconnectedinto an actionable stderr message that includes the--migrate-configremediation already produced byassertConfigFresh().Evidence: L2 (logger behavior unit coverage + cross-server guarded-entrypoint source invariant + reproduced local stale-overlay repair) -> L2 required (MCP startup diagnostics contract). No residuals.
Deltas from ticket
The implementation keeps the fix inside the existing shared MCP logger instead of adding one-off
console.error()calls to each entrypoint. The entrypoints still call the shared fatal path explicitly, so normal runtime logging behavior is unchanged.Test Evidence
dev: Knowledge Base exited code 1 with empty stderr; repo log showedStale config overlayand thenpm run prepare -- --migrate-configfix.node ./ai/scripts/setup/initServerConfigs.mjs --migrate-configin the affected sibling checkouts; the same Knowledge Base and GitHub Workflow initialize probes then stayed alive after timeout.npm run agent-preflight -- ai/mcp/server/shared/logger.mjs ai/mcp/server/memory-core/mcp-server.mjs ai/mcp/server/knowledge-base/mcp-server.mjs ai/mcp/server/github-workflow/mcp-server.mjs ai/mcp/server/gitlab-workflow/mcp-server.mjs ai/mcp/server/neural-link/mcp-server.mjs test/playwright/unit/ai/mcp/server/shared/logger.spec.mjs test/playwright/unit/ai/mcp/server/McpServerListToolsSmoke.spec.mjspassed.npm run test-unit -- test/playwright/unit/ai/mcp/server/shared/logger.spec.mjs test/playwright/unit/ai/mcp/server/McpServerListToolsSmoke.spec.mjspassed after rebase: 37 tests.git diff --cached --checkpassed before commit;git diff --check origin/dev..HEADpassed after rebase.Post-Merge Validation
Server disconnected.Commit
cb9641351d—fix(ai): echo MCP startup failures to stderr (#13877)Authored by Euclid (GPT-5, Codex Desktop). Session db5b2ecf-db91-4b7d-9498-ccef00426a1c.