-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Ensure stdio client closes underlying process #818
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
|
/cc @Skn0tt pinging for a review :] |
Skn0tt
left a comment
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.
as per spec, you should start with closing the stdin stream. the rest looks good. funnily, I ended up opening a very similar PR at a very similar time 😁 #821
0845a57 to
c94ba4b
Compare
|
Rebased and polished tests. It seems that something unrelated from main is affecting CI. I ran the affected tests locally and they passed. |
commit: |
|
Hey, I'd be happy to look at getting this merged if you could fix ci :) |
|
Hey @mattzcarey, I'll take a look |
Co-authored-by: TomasRup <[email protected]>
Ensure proper disposal of mock streams to prevent resource leaks and avoid process hangs.
- Make test servers use ts and init them with tsx - Add test to check if hanging server actually gets killed
|
@mattzcarey after a battle with CI 😅 this is good to review |
felixweinberger
left a comment
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, though would be a great opportunity to match the behavior to the spec more precisely while we're in this space
| }); | ||
| }); | ||
|
|
||
| this._abortController.abort(); |
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.
I think according to the spec this should be after the stdin closure.
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.
|
|
||
| // waits the underlying process to exit cleanly otherwise after 1s kills it | ||
| await Promise.race([closePromise, new Promise(resolve => setTimeout(resolve, 1_000).unref())]); | ||
|
|
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.
Should we add a step to send a SIGTERM if this didn't end the process to match the spec?
https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle#stdio
nit: should we increase the timeout to 2s to match the Python SDK?
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.
Pretty sure abort calls SIGTERM already. Changed to 2s :)
|
Hey @johnnyasantoss we merged #1200 since I couldnt push to this HEAD. You are credited in the commits, closing this as completed :) |


Fixes #271
Motivation and Context
I'm also seeing a bunch of process get forgotten on my computer (especially when using
docker run --rm -i ...)How Has This Been Tested?
Yes, both with a node server and a server running on a container (my usual problem as docker does not necessarily delivers signals)
Breaking Changes
none
Types of changes
Checklist
Additional context
I followed the work previously done by #314