Unconditional set SamplingCompatibility upon MCP client session initialization may cause streamable HTTP to hang forever #17867

Closed
opened 2026-02-21 19:40:43 -05:00 by yindo · 0 comments
Owner

Originally created by @Vivecccccc on GitHub (Sep 22, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.8.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

For any workflow orchestrating Playwright MCP as tool nodes, which integrated to Dify via Streamable HTTP with /mcp route:

  • the node sent a tool call request to the server, the server was able to receive it
  • the node would not receive anything but wait for 60s until MCP Error -32001 Request timed out exception occurred on the server-side (printed in logs)
  • the node received the expected response (not error) from the server and proceed.

✔️ Expected Behavior

The node should receive the response right away upon the server responds.

Actual Behavior

See Steps to Reproduce

Findings:

The current implementation for MCP client session's initialization would set SamplingCapability regardless of the callback function's validity. This may cause the streamable HTTP to hang forever, refers to https://github.com/modelcontextprotocol/python-sdk/issues/680, as the server expected to get response from the client as per the sampling request.
Meanwhile, due to the default request timeout setting from the Playwright-MCP side, the server would wait for at most 60s (60000ms) to time out the sampling request that sent to the client, then push back the result.

The official MCP SDK has adapted the changes the set the sampling capability to None in case there's no valid callback, see https://github.com/modelcontextprotocol/python-sdk/commit/7f94bef85e0967e77ffcd795bb7e647a5293afdb, which may resolve this issue.

Originally created by @Vivecccccc on GitHub (Sep 22, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.8.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce For any workflow orchestrating Playwright MCP as tool nodes, which integrated to Dify via Streamable HTTP with `/mcp` route: - the node sent a tool call request to the server, the server was able to receive it - the node would not receive anything but wait for 60s until **MCP Error -32001 Request timed out** exception occurred on the server-side (printed in logs) - the node received the expected response (not error) from the server and proceed. ### ✔️ Expected Behavior The node should receive the response right away upon the server responds. ### ❌ Actual Behavior See **Steps to Reproduce** ### Findings: The current implementation for MCP client session's [initialization](https://github.com/langgenius/dify/blob/50050527ebfcd914b8578462ce8f1191465de72d/api/core/mcp/session/client_session.py#L111-L118) would set SamplingCapability regardless of the callback function's validity. This may cause the streamable HTTP to hang forever, refers to https://github.com/modelcontextprotocol/python-sdk/issues/680, as the server expected to get response from the client as per the sampling request. Meanwhile, due to the [default request timeout](https://github.com/modelcontextprotocol/typescript-sdk/blob/c94ba4b43cd305e39d88985c73d6b9bc1153da84/src/shared/protocol.ts#L60) setting from the Playwright-MCP side, the server would wait for at most 60s (60000ms) to time out the sampling request that sent to the client, then push back the result. The official MCP SDK has adapted the changes the set the sampling capability to None in case there's no valid callback, see https://github.com/modelcontextprotocol/python-sdk/commit/7f94bef85e0967e77ffcd795bb7e647a5293afdb, which may resolve this issue.
yindo closed this issue 2026-02-21 19:40:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#17867