Skip to content

redirect error prints to stderr to avoid corrupting MCP stdio transport#98

Open
MatthewKhouzam wants to merge 1 commit into
eclipse-cdt-cloud:masterfrom
MatthewKhouzam:stderr
Open

redirect error prints to stderr to avoid corrupting MCP stdio transport#98
MatthewKhouzam wants to merge 1 commit into
eclipse-cdt-cloud:masterfrom
MatthewKhouzam:stderr

Conversation

@MatthewKhouzam
Copy link
Copy Markdown
Contributor

@MatthewKhouzam MatthewKhouzam commented May 12, 2026

What it does

Removes STDout to allow mcps to work

How to test

Run it.

Follow-ups

Will add a flag for stdout.

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Summary by CodeRabbit

  • Refactor
    • Enhanced error message handling in client operations to properly route errors to standard error stream, improving compatibility with system logging and monitoring tools.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

The PR adds a sys import and redirects error messages in multiple TspClient methods from standard output to standard error by updating print() calls to include file=sys.stderr, without altering request/response parsing or return control flow.

Changes

Error Output Redirection

Layer / File(s) Summary
Redirect error messages to stderr
tsp/tsp_client.py
Adds sys import and updates HTTP error-handling print() statements across all TspClient methods to write to stderr instead of stdout while preserving error message content and control flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 In stderr's garden, errors now flow,
Where warnings belong, away from the show,
With sys in hand and messages bright,
TspClient speaks truth on stderr's right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: redirecting error prints to stderr instead of stdout to avoid corrupting MCP stdio transport. It matches the core purpose of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tsp/tsp_client.py (2)

186-186: ⚡ Quick win

Misleading error message.

The error message says "get trace failed" but this is in the fetch_experiment method. Since you're already modifying this line, consider correcting the message to "get experiment failed".

📝 Proposed fix for error message clarity
-            print("get trace failed: {0}".format(response.status_code), file=sys.stderr)
+            print("get experiment failed: {0}".format(response.status_code), file=sys.stderr)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tsp/tsp_client.py` at line 186, In the fetch_experiment function update the
stderr print so the error text correctly reflects the operation: change the
message from "get trace failed" to "get experiment failed" while keeping the
status code (response.status_code) and file=sys.stderr intact so the log remains
informative.

667-667: ⚡ Quick win

Copy-paste error in error message.

The error message says "post extension failed" but this is in the delete_configuration method. Since you're already modifying this line, consider correcting the message to "delete configuration failed".

📝 Proposed fix for error message clarity
-            print("post extension failed: {0}".format(response.status_code), file=sys.stderr)
+            print("delete configuration failed: {0}".format(response.status_code), file=sys.stderr)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tsp/tsp_client.py` at line 667, The error log in delete_configuration
mistakenly says "post extension failed"; update the message in the
delete_configuration method to accurately reflect the operation by changing the
printed string to "delete configuration failed" (keep including the
response.status_code as before) so the print call correctly reads that the
delete configuration request failed; locate the print in delete_configuration
and replace the misleading text only.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tsp/tsp_client.py`:
- Line 186: In the fetch_experiment function update the stderr print so the
error text correctly reflects the operation: change the message from "get trace
failed" to "get experiment failed" while keeping the status code
(response.status_code) and file=sys.stderr intact so the log remains
informative.
- Line 667: The error log in delete_configuration mistakenly says "post
extension failed"; update the message in the delete_configuration method to
accurately reflect the operation by changing the printed string to "delete
configuration failed" (keep including the response.status_code as before) so the
print call correctly reads that the delete configuration request failed; locate
the print in delete_configuration and replace the misleading text only.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3701371-fc9e-419b-98f4-4fca5a432074

📥 Commits

Reviewing files that changed from the base of the PR and between 6eb49d6 and d5a9e5e.

📒 Files selected for processing (1)
  • tsp/tsp_client.py

Copy link
Copy Markdown
Contributor

@arfio arfio left a comment

Choose a reason for hiding this comment

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

I did not see any other places where this change was required, so this change looks good to me!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants