-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Prevent stdio connection hang for missing server path. #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6a85c7f
to
90f224d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! Sorry for the delay in reviews.
This PR identified an issue where the SDK is not handling missing server paths. I'd suggest a slightly different approach for a solution though. Should we implement error handling for the server path instead?
No problem! I'm trying to remember if I had issues when I was developing an mcp server, and had some bug in the connection procedure or something and then that was causing the client to hang indefinitely. For now, it probably makes sense to do a simpler check that the server file as you suggest, and then worry about more complicated cases if that is still an issue. About to fly right now, and won't have a chance to come back to this for a little while. I'm happy for you to make any changes you want, otherwise I'll hopefully get to it in a few weeks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Motivation and Context
The stdio connection was hanging indefinitely for a bad server file path (e.g. command
uv
, argsrun non-existing-file.py
).I think because the read/write streams were not being closed properly in that case.
This makes it so that errors due to the underlying mcp server stopping early raises a
ProcessTerminatedEarlyError
.How Has This Been Tested?
Added a test (including catching if it does hang for more than 1s)
Breaking Changes
Should not be a breaking change.
Types of changes
Checklist
Additional context