Repository navigation
Keep stdout for JSON-RPC in four stdio servers: print diagnostics to stderr - #79
Open
vishalhabib99 wants to merge 1 commit into
Open
vishalhabib99 wants to merge 1 commit into
vishalhabib99 wants to merge 1 commit into
Conversation
|
Thanks for the contribution! Before we can merge this, we need @vishalhabib99 to sign the Salesforce Inc. Contributor License Agreement. |
Author
|
I've signed the Salesforce CLA; commenting so the check re-runs. |
vishalhabib99
force-pushed
the
fix/stdio-servers-print-to-stderr
branch
from
November 2, 2026 21:40
519bff3 to
61afddd
Compare
Author
|
Hi, just checking whether this one is on your radar. Four bundled stdio servers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The bundled
yfinance,google-sheets,jina_scrape_llm_summaryandserper-searchservers run over stdio by default (--transportdefaults tostdio, andserver_list.jsonstarts them withpython3 -m mcpuniverse.mcp.servers.<name>). On stdio, stdout is the JSON-RPC stream, but these servers report errors and progress with bareprint(). For exampleyahoo_finance/server.pyprintsCompany ticker {ticker} not found.whenever a tool gets an unknown ticker, which agents do often in the finance tasks.Python buffers stdout on a pipe, so the printed text isn't visible at first. Once about 8 KB has built up, it flushes into the stream mid-frame, the client gets a line that isn't JSON-RPC, and that response is lost:
Change
In those four servers, every
print(...)now passesfile=sys.stderr(62 calls), andimport sysis added where missing. The messages are unchanged and still visible (MCP clients show or log server stderr). No other changes. Three lines that would pass 120 characters putfile=sys.stderron its own line, sopylint mcpuniversestays clean.Checked
I reproduced it with a minimal FastMCP server written like
yahoo_finance(a tool that printsCompany ticker ... not found.and returns the same text), driven by the mcp stdio client, mcp 1.30.0:print(...)(main)ValidationError ... json_invalid)print(..., file=sys.stderr)(this branch)The four files still parse, and no
print()withoutfile=is left in them. I didn't run the servers against their live APIs (Yahoo Finance, Google Sheets, Jina, Serper).