-
Notifications
You must be signed in to change notification settings - Fork 163
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
Shutting down console application which uses mcpclient does not kill the stdio process #155
Comments
@eiriktsarpalis |
How is your server implemented? The server going away at that point is up to the server. |
To my knowledge, there's nothing one process can proactively do to say "if I'm ever killed, please also kill the following processes". The client can gracefully have code to shutdown / kill child processes it creates, and it does, but if the client is killed and thus can't run that code, it's not able to kill the server. The server itself can have code to say "if the stdin I'm reading from ends up abruptly, I should stop processing and go away", and the implementation makes it possible to do that today. But it relies on the coding of the server not doing things like blocking forever, which is why I asked how the server is implemented. Did you write the server? What does the code for it look like? |
I did write that server, code is based on this C# SDK. Note that wen I use this same tool in Claude Desktop (or any other tool), these tools get shutdown/killed when Claude Desktop is also closed (via the Quit option in the taskbar). |
I'm pretty sure there is stuff like this.
I've been meaning to implement this in the MCP C# SDK, but it hasn't been as high priority as the HTTP streaming transport. Although, I'm sure someone else could also take a look at the dotnet cli/sdk PR and do something similar for stdio servers. |
Is it really necessary? I'd hope the client going away would cause the server's stdin to close, at which point it should automatically shut down. If that's still not happening, we should figure out why. Forcefully killing the server without giving it a chance to gracefully exit is far from ideal. |
Describe the bug
Shutting down console application with CTRL-C or just killing it and uses mcpclient does not kill the stdio process
To Reproduce
Install a dotnet tool mcpserver:
And this C# code in a console app:
See also https://github.com/StefH/mcptest
Expected behavior
When the application stops, is killed (using close) or using CTRL-C, it's expected that the spawned child process (the stdio server) is also killed.
This is not the case, using when manually calling DisposeAsync on the McpClient, the process is killed.
The text was updated successfully, but these errors were encountered: