Skip to content

Conversation

gitmotion
Copy link
Owner

Pull Request Overview

This PR implements a logging abstraction to prevent log pollution of stdout space for MCP (Model Context Protocol) usage. All console logging has been replaced with a custom Logger class that outputs to stderr with prefixed tags to avoid interfering with MCP communication.

  • Introduces a singleton Logger class that outputs to stderr instead of stdout
  • Replaces all console.log/error calls with logger.info/warn/error methods
  • Updates project documentation with contribution guidelines for logging usage
File Description
src/utils/logger.ts New singleton Logger class implementation with stderr output
src/index.ts Replaces all console logging with Logger abstraction and code formatting improvements
package.json Version bump from 1.3.4 to 1.3.5
build/utils/logger.js Compiled JavaScript output of the Logger class
build/index.js Compiled JavaScript output with logging changes
README.md Updated documentation with contribution guidelines and logging requirements
.github/PULL_REQUEST_TEMPLATE.md New PR template enforcing logging guidelines
Commit logs: * bugfix: print/log to sys.stderr insted of sys.stdout (#6)

Printing/logging sys.stdout causes initialization problems:

2025-08-04T17:31:34.484+02:00 DEBUG 43668 --- [mcp-tests] [pool-2-thread-1] io.modelcontextprotocol.spec.McpSchema : Received JSON message: Topic 'MY_TOPIC' is marked as public. No authentication required.
2025-08-04T17:31:34.485+02:00 ERROR 43668 --- [mcp-tests] [pool-2-thread-1] i.m.c.transport.StdioClientTransport : Error processing inbound message for line: Topic 'MY_TOPIC' is marked as public. No authentication required.

com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Topic': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 6]

Printing/logging sys.stdout causes initialization problems:

Error processing inbound message for line: Sending notification to http://server.example/TOPIC with Markdown formatting

  • add logger class abstraction using console.error to prevent initialization issues

  • update build files

  • bump version and update readme and include github pull request template

* bugfix: print/log to sys.stderr insted of sys.stdout (#6)

Printing/logging sys.stdout causes initialization problems:

2025-08-04T17:31:34.484+02:00 DEBUG 43668 --- [mcp-tests] [pool-2-thread-1] io.modelcontextprotocol.spec.McpSchema   : Received JSON message: Topic 'MY_TOPIC' is marked as public. No authentication required.
2025-08-04T17:31:34.485+02:00 ERROR 43668 --- [mcp-tests] [pool-2-thread-1] i.m.c.transport.StdioClientTransport     : Error processing inbound message for line: Topic 'MY_TOPIC' is marked as public. No authentication required.

com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Topic': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 6]

* bugfix: print/log to sys.stderr insted of sys.stdout (#7)

Printing/logging sys.stdout causes initialization problems:

Error processing inbound message for line: Sending notification to http://server.example/TOPIC with Markdown formatting

* add logger class abstraction using console.error to prevent initialization issues

* update build files

* bump version and update readme and include github pull request template

---------

Co-authored-by: michalcamona <[email protected]>
@gitmotion gitmotion self-assigned this Aug 6, 2025
@gitmotion gitmotion added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Aug 6, 2025
@gitmotion gitmotion merged commit cf09dad into main Aug 6, 2025
@gitmotion gitmotion deleted the dev branch August 6, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant