Repository navigation
fix(ENG-15479): stop mcp start quietly when the client closes stdout - #583
Open
cloudsmith-iduffy wants to merge 3 commits into
Open
cloudsmith-iduffy wants to merge 3 commits into
cloudsmith-iduffy wants to merge 3 commits into
Conversation
The mcp stdio transport writes in an anyio task group, which raises the BrokenPipeError inside an ExceptionGroup. The error reached the top-level handler, which reported it and exited with status 1. Fixes CLOUDSMITH-CLI-20 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change that treats a client closing stdout as a normal MCP session end.
No open issues 🎉
What changed in this PR
Updates cloudsmith mcp start to treat a client closing stdout as a normal session end rather than an error.
Changes:
- Handles
BrokenPipeErrorinside exception groups while allowing unrelated errors to propagate. - Adds a subprocess regression test using the real MCP transport and a closed stdout pipe.
- Documents the corrected exit behavior in the changelog.
| File | Description |
|---|---|
cloudsmith_cli/core/mcp/server.py |
Suppresses grouped broken-pipe errors during stdio operation. |
cloudsmith_cli/cli/tests/commands/test_mcp.py |
Verifies successful exit when the client closes stdout. |
CHANGELOG.md |
Records the MCP disconnect fix. |
Review effort: Balanced
* origin/master: fix(ENG-15484): accept --color on click versions before 8.2 (#582) fix(no-ticket): stop retrying unknown hosts and show backoff retries (#542) fix(no-ticket): stop credential helpers from overwriting config files that do not parse (#540) fix(no-ticket): remove the pnpm launcher when .npmrc does not exist (#539) fix(no-ticket): keep the user's Cargo registry credential provider (#532) # Conflicts: # CHANGELOG.md
BartoszBlizniak
approved these changes
Nov 3, 2026
cloudsmith-iduffy
enabled auto-merge (squash)
November 3, 2026 15:57
Copilot started work to resolve merge conflicts on behalf of
cloudsmith-iduffy
November 3, 2026 15:58
…en-pipe # Conflicts: # CHANGELOG.md Co-authored-by: cloudsmith-iduffy <178375997+cloudsmith-iduffy@users.noreply.github.com>
auto-merge was automatically disabled
November 3, 2026 16:04
Head branch was pushed to by a user without write access
This branch has not been deployed
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.
Description
Sentry CLOUDSMITH-CLI-20 is a
BrokenPipeErrorfromcloudsmith mcp starton 1.30.0 (Homebrew). The MCP client closed its end of stdout while the server was writing a reply.The mcp library writes stdio replies in an anyio task group. The task group wraps the
BrokenPipeErrorin anExceptionGroup. The error leftDynamicMCPServer.run(), andAliasGroup.mainreported it to Sentry and exited with status 1.run()now catches the closed pipe withexcept* BrokenPipeErrorand returns. A client that goes away is a normal end of the session. Any other error in the group is still raised.Linear: ENG-15479. Fixes CLOUDSMITH-CLI-20
Type of Change
Additional Notes
The patch in ENG-15479 does not fix this. It catches a plain
BrokenPipeError, but mcp 2.3.0 raisesExceptionGroup(BrokenPipeError), and its test mocked the plain error. To see the real error, run the stdio server with stdout on a closed pipe:The new test does this in a subprocess with the real library. It fails on master with exit status 1 and the
ExceptionGrouptraceback.After the fix, Python still prints
Exception ignored while finalizing file <_io.BufferedWriter name=8>to stderr. That writer is a private copy of fd 1 that mcp opens, and the CLI cannot reach it. The message does not change the exit status. Sentry does not see it, because the SDK runs withdefault_integrations=False.🤖 Generated with Claude Code