The Model Context Protocol (MCP) servers are designed to communicate over stdio using JSON-RPC. Direct logging to stdout with console.log corrupts the message stream and breaks the server. While stderr is safe for error logging, standard diagnostic logs need to be conditional.
This ticket is to implement a centralized, debug-flag-aware logger to manage stdout logging across all MCP servers and refactor existing code to use it.
Acceptance Criteria
- A global
debug flag is added to ai/mcp/server/config.mjs, defaulting to false.
- A new logger module is created at
ai/mcp/server/logger.mjs.
- The logger module only outputs to
console.log when the debug flag in aiConfig is true.
- All existing
console.log statements in the knowledge-base and memory-core MCP server files are refactored to use the new logger module.
console.error statements are not affected and should remain as they are for logging to stderr.
The Model Context Protocol (MCP) servers are designed to communicate over stdio using JSON-RPC. Direct logging to
stdoutwithconsole.logcorrupts the message stream and breaks the server. Whilestderris safe for error logging, standard diagnostic logs need to be conditional.This ticket is to implement a centralized, debug-flag-aware logger to manage
stdoutlogging across all MCP servers and refactor existing code to use it.Acceptance Criteria
debugflag is added toai/mcp/server/config.mjs, defaulting tofalse.ai/mcp/server/logger.mjs.console.logwhen thedebugflag inaiConfigistrue.console.logstatements in theknowledge-baseandmemory-coreMCP server files are refactored to use the new logger module.console.errorstatements are not affected and should remain as they are for logging tostderr.