fix: remove stdout pollution in stdio mode - #174
Conversation
…rt that prints colored status messages - Remove console.log statements that pollute JSON-RPC stream - Fixes stdio-based MCP client communication errors The dotenvx library and console.log statements were writing to stdout, which breaks the Model Context Protocol's stdio transport. MCP requires clean stdout with only JSON-RPC messages. Environment variables can still be passed via the env parameter when launching the server, so dotenvx is not required for stdio mode.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary of ChangesHello @chrisdoc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where unwanted output to Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #174 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 2 2
=========================================
Hits 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
The pull request correctly addresses the issue of stdout pollution from dotenvx by enabling its quiet mode. This is a good fix for ensuring clean JSON-RPC communication over stdio. The changes to use console.error for logging instead of console.log are also appropriate for this goal. I've added a couple of suggestions to improve code structure by grouping all imports at the top of the files, which is a common best practice for maintainability.
| import { fileURLToPath } from "node:url"; | ||
| import dotenvx from "@dotenvx/dotenvx"; | ||
|
|
||
| // Configure dotenvx with quiet mode to prevent stdout pollution in stdio mode | ||
| dotenvx.config({ quiet: true }); | ||
|
|
||
| import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | ||
| import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; | ||
| import { z } from "zod"; |
There was a problem hiding this comment.
For better code organization and adherence to common style practices, it's best to group all import statements at the top of the file, before any executable code. This change splits the import statements with the dotenvx.config() call, which can be confusing for developers and some tooling. Moving the configuration call after all imports will improve readability and maintainability.
| import { fileURLToPath } from "node:url"; | |
| import dotenvx from "@dotenvx/dotenvx"; | |
| // Configure dotenvx with quiet mode to prevent stdout pollution in stdio mode | |
| dotenvx.config({ quiet: true }); | |
| import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | |
| import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; | |
| import { z } from "zod"; | |
| import { fileURLToPath } from "node:url"; | |
| import dotenvx from "@dotenvx/dotenvx"; | |
| import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | |
| import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; | |
| import { z } from "zod"; | |
| // Configure dotenvx with quiet mode to prevent stdout pollution in stdio mode | |
| dotenvx.config({ quiet: true }); | |
| import dotenvx from "@dotenvx/dotenvx"; | ||
|
|
||
| dotenvx.config({ quiet: true }); | ||
|
|
||
| import { Client } from "@modelcontextprotocol/sdk/client/index.js"; | ||
| import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js"; |
There was a problem hiding this comment.
Similar to the change in src/index.ts, it's best practice to keep all import statements grouped at the top of the file. This change introduces executable code between import statements. Consolidating imports at the beginning of the file improves code structure and readability.
| import dotenvx from "@dotenvx/dotenvx"; | |
| dotenvx.config({ quiet: true }); | |
| import { Client } from "@modelcontextprotocol/sdk/client/index.js"; | |
| import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js"; | |
| import dotenvx from "@dotenvx/dotenvx"; | |
| import { Client } from "@modelcontextprotocol/sdk/client/index.js"; | |
| import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js"; | |
| dotenvx.config({ quiet: true }); | |
## [1.12.8](v1.12.7...v1.12.8) (2025-11-29) ### Bug Fixes * remove stdout pollution in stdio mode ([#174](#174)) ([0ad6a1b](0ad6a1b))
There was a problem hiding this comment.
✨ PR Review
LGTM
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how
Use quiet mode for dotenvx to prevent stdout pollution that breaks JSON-RPC communication in stdio mode.
Note
Suppresses stdout pollution by using dotenvx quiet mode and stderr logging; consolidates CI to run integration tests in the build job and uploads coverage to Codecov, updating OTEL job dependencies.
@dotenvx/dotenvx/configwithdotenvx.config({ quiet: true })insrc/index.tsandtests/integration/hevy-mcp.integration.test.tsto avoid stdout output.console.logtoconsole.errorinsrc/index.ts..github/workflows/build-and-test.yml):buildjob; remove separateintegration-testsjob.otel-cicd-actionneedsto[build].Written by Cursor Bugbot for commit 6cb45f4. This will update automatically on new commits. Configure here.
✨ PR Description
Purpose: Fix stdout pollution by configuring dotenvx in quiet mode and redirecting log messages to stderr in stdio mode.
Main changes:
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how