The MCP server specification requires that stdio-based servers must not write to stdout, as it will corrupt the JSON-RPC message transport. Currently, the SyncService and other parts of the server use console.log, console.warn, and console.error directly, with some writing to stdout.
This ticket covers the enhancement of the existing logger.mjs to provide a safe, centralized logging mechanism that exclusively uses stderr, and the refactoring of our services to adopt it.
Acceptance Criteria
- The
ai/mcp/server/logger.mjs file is updated to provide debug, info, warn, and error methods.
- All methods within the logger must use
console.error to ensure output is directed to stderr.
- All logging methods (
debug, info, warn, error) must be conditional and only log when aiConfig.debug is true.
- The
SyncService.mjs is refactored to import and use the new logger for all its console output.
console.log should be replaced with logger.info or logger.debug.
console.warn should be replaced with logger.warn.
console.error should be replaced with logger.error.
- The main server entry point,
ai/mcp/server/github-workflow/mcp-stdio.mjs, is also refactored to use the new logger.
Benefits
- Bug Fix: Prevents corruption of the
stdio message transport, ensuring server stability.
- Compliance: Adheres to the MCP server specification.
- Centralized Logging: Provides a single, consistent, and safe way to handle logging across all services.
- Improved Diagnostics: Prefixes logs with
[INFO], [WARN], etc., making stderr output easier to read and filter.
The MCP server specification requires that
stdio-based servers must not write tostdout, as it will corrupt the JSON-RPC message transport. Currently, theSyncServiceand other parts of the server useconsole.log,console.warn, andconsole.errordirectly, with some writing tostdout.This ticket covers the enhancement of the existing
logger.mjsto provide a safe, centralized logging mechanism that exclusively usesstderr, and the refactoring of our services to adopt it.Acceptance Criteria
ai/mcp/server/logger.mjsfile is updated to providedebug,info,warn, anderrormethods.console.errorto ensure output is directed tostderr.debug,info,warn,error) must be conditional and only log whenaiConfig.debugistrue.SyncService.mjsis refactored to import and use the new logger for all its console output.console.logshould be replaced withlogger.infoorlogger.debug.console.warnshould be replaced withlogger.warn.console.errorshould be replaced withlogger.error.ai/mcp/server/github-workflow/mcp-stdio.mjs, is also refactored to use the new logger.Benefits
stdiomessage transport, ensuring server stability.[INFO],[WARN], etc., makingstderroutput easier to read and filter.