fixes #343 and #344#440
Conversation
# Conflicts: # src/sktime_mcp/server.py
| # Stdio safety: redirect stdout to stderr to protect MCP JSON-RPC | ||
| # streams from being corrupted by stray prints in third-party libraries. | ||
| original_stdout = sys.stdout | ||
| sys.stdout = sys.stderr |
There was a problem hiding this comment.
Is this really desired? Could you explain in more details the problem that motivated this change? Although there is a comment, I'm not sure if I understand the practical problem that was happening
There was a problem hiding this comment.
You're right, the current comment was probably too vague.
The intent behind this change is to protect the MCP JSON-RPC transport stream. Since MCP communicates over stdout/stdin, any accidental "print()" or third-party library output written to stdout can corrupt protocol messages and cause the client to fail parsing responses.
For example, if stdout contains:
loading model...
{"jsonrpc":"2.0","id":1,"result":...}
the client may fail because it expects stdout to contain only JSON-RPC payloads.
By redirecting:
sys.stdout = sys.stderr
any accidental prints/debug output are pushed to stderr instead, keeping stdout reserved for MCP responses.
That said, the current implementation also included an unused "original_stdout" variable, which I’ll remove since stdout is not restored later.
Reference Issues/PRs
Fixes #343 and #344
What does this implement/fix? Explain your changes.
Refactors runtime configuration handling by centralizing environment-variable-based settings into a dedicated configuration module and simplifying runtime initialization logic.
Key Changes
Added
Updated
"src/sktime_mcp/runtime/executor.py"
"src/sktime_mcp/server.py"
"README.md"
Validation / Error Handling
Does your contribution introduce a new dependency?
No new dependencies introduced.
What should a reviewer concentrate their feedback on?
Centralized configuration approach
Settings API design
Runtime behavior compatibility
Logging initialization changes
Testing / Validation
Verified locally:
Any other comments?
This refactor mainly aims to:
PR checklist
For all contributions