Skip to content

fix: remove stdout pollution in stdio mode - #174

Merged
chrisdoc merged 6 commits into
mainfrom
fix/stdio-stdout-pollution
Nov 29, 2025
Merged

fix: remove stdout pollution in stdio mode#174
chrisdoc merged 6 commits into
mainfrom
fix/stdio-stdout-pollution

Conversation

@chrisdoc

@chrisdoc chrisdoc commented Nov 29, 2025

Copy link
Copy Markdown
Owner

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.

  • Runtime/Logging:
    • Replace @dotenvx/dotenvx/config with dotenvx.config({ quiet: true }) in src/index.ts and tests/integration/hevy-mcp.integration.test.ts to avoid stdout output.
    • Switch startup messages from console.log to console.error in src/index.ts.
  • CI/CD (.github/workflows/build-and-test.yml):
    • Run integration tests within the build job; remove separate integration-tests job.
    • Upload coverage to Codecov after integration tests.
    • Set otel-cicd-action needs to [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:

  • Modified dotenvx import to use config with quiet option to prevent stdout pollution
  • Changed console.log calls to console.error to keep stdout clean for IPC
  • Simplified CI workflow by merging integration tests into the build job

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

filio623 and others added 6 commits November 28, 2025 14:01
…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>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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 stdout was interfering with JSON-RPC communication in stdio mode. The fix involves configuring dotenvx to operate silently and redirecting all informational log messages from stdout to stderr. These adjustments ensure that stdout is exclusively used for JSON-RPC payloads, thereby stabilizing the communication channel.

Highlights

  • Dotenvx Configuration: Configured dotenvx to run in quiet mode by explicitly importing dotenvx and calling dotenvx.config({ quiet: true }). This prevents dotenvx from printing output to stdout.
  • Console Output Redirection: Redirected informational console.log messages related to client initialization and server startup to console.error. This ensures that standard output remains clear for JSON-RPC communication.
  • Integration Test Consistency: Applied the same dotenvx quiet mode configuration to the integration tests to maintain consistent behavior and prevent potential stdout pollution during testing.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/build-and-test.yml
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov

codecov Bot commented Nov 29, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f232c43) to head (6cb45f4).
⚠️ Report is 9 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/index.ts
Comment on lines 1 to 9
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";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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 });

Comment on lines +1 to 6
import dotenvx from "@dotenvx/dotenvx";

dotenvx.config({ quiet: true });

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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 });

@chrisdoc
chrisdoc merged commit 0ad6a1b into main Nov 29, 2025
20 of 21 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 29, 2025
## [1.12.8](v1.12.7...v1.12.8) (2025-11-29)

### Bug Fixes

* remove stdout pollution in stdio mode ([#174](#174)) ([0ad6a1b](0ad6a1b))

@gitstream-cm gitstream-cm Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants