-
Notifications
You must be signed in to change notification settings - Fork 183
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
Client hangs on valid server responses #192
Comments
I investigated this issue and found:
Here is my analysis to share what I found. Analysis of Hang ProblemDirect cause of the hang seems in those two lines: python-sdk/src/mcp/shared/session.py Line 218 in f10665d
python-sdk/src/mcp/shared/session.py Line 337 in f10665d
What is happening?
Those logics make the following line keep waiting forever: python-sdk/src/mcp/shared/session.py Line 236 in f10665d
DiscussionFollowing the typescript-sdk approach, we can resolve the hang by adding a cast. Specifically, changing python-sdk/src/mcp/shared/session.py Line 337 in f10665d
However, I wonder about the intended design in the MCP spec - why is There are three possibilities:
@dsp-ant Could you help guide our understanding of this issue? The above analysis might be missing important aspects of the MCP design, so we'd appreciate your insights on how to best address this. |
The MCP is based on JSON RPC 2.0, where
|
Thank you for the analysis. This is super helpful. We should fix this. We will stick to the JSON RPC standard and hence allow string or a number. Now we should NOT cast to integer but rather allow the _response_streams, since a string can contain a uuid or any other format that cannot be casted. Now I am not even sure I fully follow WHY the bug is happening. It seems to me that the _response_stream dictionary uses If any of you have time to see you can produce a unit tests for this, this would be massive help. There are some examples for creating a test with a client and a server in the repo. |
I see, then I misunderstood the JSON rpc protocol. It seems that the id needs to be exactly the same in the sense that they should also be the same type: number or string. Then this might have been a misimplementation on typescript sdk's side. Closing as this is the expected behavior. |
@dsp-ant Let me clarify the situation:
|
This test ensures that the server properly preserves and returns the same request ID in responses, which is a fundamental part of the JSON-RPC protocol. The test initializes the server, sends requests with custom IDs, and verifies that these IDs are correctly returned. Github-Issue:#192
Describe the bug
Both of the actions operations are valid as per specification.
To Reproduce
This repository contains the files.
By modifying
server.py
then runuv run client.py
should give you the behavior.It also has a client implemented with typescript sdk as comparison.
Expected behavior
The client should perform normally, as the client written with typescript sdk.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
n/a
The text was updated successfully, but these errors were encountered: