-
Notifications
You must be signed in to change notification settings - Fork 435
fix: handle the client disconnect so that the server does not crash. #380
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
base: main
Are you sure you want to change the base?
Conversation
Hi @wolfdancer! While the changes look sane, I am not able to duplicate the inciting condition. Here is a video, where I repeatedly connect and disconnect from the server reference implementation Doing this test prompted me to make a PR for that server to replace If the server stays up, the Inspector doesn't seem to have a problem reconnecting for me. Can you provide a way to duplicate the problem in order to test that your changes are fixing it? |
Hi @cliffhall, I can confirm that the issue is fixed with the latest code based on my test with a MCP server that I am putting together. Let me take another look at the code to see if some other change actually fixed this bug. |
Hi again @cliffhall, I am not sure why at the moment, but apparently this only happens with the github MCP server. The reason that I though it was fixed was beacuse I used a MCP server that I was writing and that MCP server was just a python application. Please see attached screen recording. In the recording, I cloned this repo and ran the server/client separately. Through comparison I realized it was not the way I started the server, but the MCP server itself that made the difference. inspector-disconnect-bug-with-github-mcp-server.movSince I have Github MCP server installed on my Claude client, I was able to just launch inspector in the following command and reproduce the issue |
hi again @cliffhall, I think I have figured out that the issue is from how the server handles the stderr output from the MCP server. The Github MCP server must print something in stderr, which the inspector server is sending over to the inspector client and fails in the case where the client is disconnected, causing the server to crash. This can be reproduced with my example MCP server that prints out messages in stderr: https://github.com/wolfdancer/mcp-example.py. The command to launch is From the tests and revewing the code, I have realized two things that I missed the first time:
The PR as of now (2025-05-18 11:46pm Pacific) should be good to go. Please let me know if you have any feedback. Cheers. |
@wolfdancer Not being a Python person, I don't have @olaservo @evalstate If either of you have |
Hi there. I did a round of testing and it only happens with the official Github MCP Server, which is written in Go, and my testing server, which is written in Python. This cannot be reproduced with TypeScript MCP servers, which are all the servers in the servers repo. It appears to be the way node handles the kill signal. I cannot get the MCP server written in TypeScript to catch the signal when the inspector is shutting it down. If @olaservo or @evalstate , if you have your own python MCP server, something like this should do the trick: https://github.com/wolfdancer/mcp-example.py/blob/main/arxiv_server.py#L101-L109 |
hi @cliffhall, thanks for the list. I should have looked further. I applied the change to git server and was able to reproduce the issue. Assuming you have docker, I think this will work without the need to mess with python environments
Please let me know if this clarifies. I can do a screen capturing with the above steps if that helps. |
Ok. Breaks as expected. Breaking.mov
Doesn't break with your fix. NotBreaking.mov |
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! 👍
@wolfdancer just need to run prettier to pass the CI. |
Sorry about that. I forgot to run prettier with the async update commit. Updated. |
weird... based on CoPilot, it is something to do with ToolsTab.tsx. I'll take a further look later today. |
Hi @cliffhall, can you approve when you get a chance? I ran the prettier. I also figured out how to fix the second PR build. I am not sure why it would suddenly fail but I did confirm the build failure locally, and confirmed that the build pass with the change in 80377bc |
This issue is currently keeping us from merging any PRs. The problem stems from a recent breaking change added to the SDK. You can see more about it in this draft PR I made yesterday to try and address it. We won't be merging it because the changes are going to be fixed in the SDK shortly. You can revert the change in your PR as well. |
This reverts commit 80377bc.
I have reverted the latest commit. I will squash the commits when the PR is ready for merge. |
I noticed that the Inspector can only connect to a server once. Once disconnected, nothing appears to work. Upon some debugging, I realized that it is because the server got an error in its SSE message in the case where the client is disconnected.
Motivation and Context
With this change, the "Restart" and "Disconnect" buttons at the bottom of the SideBar will work as expected.
How Has This Been Tested?
Yes. The test scenario is pretty straightforward:
Breaking Changes
No.
Types of changes
Checklist
Additional context
Before I realized it was the server that was crashing, I was looking into client-server communication. In that process, I cleaned up the console logging so that it is clear which API on the server was called without having to remember the code. I believe that makes an easier troubleshooting experience although I understand those changes are not related to the bug fix. I am happy to submit a separate PR for the logging enhancement if that is better.