Skip to content

fix: allow consumption of entire response body for large payloads #493

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ewong5
Copy link

@ewong5 ewong5 commented Aug 15, 2025

Motivation and Context

See this issue: #470

How Has This Been Tested?

Tested using the test classes provided and locally trying E2E

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@rsg-coder
Copy link

This issue is still reproducible with this fix.

Setup
MCP Server is Python (FastMcp 2.9) which is hosting a calculator tool.
Client is a Java client using SSE to connect to the server and calling tools in a loop
Took the code changes of the above commit

Client Code
`

static void execTools(McpSyncClient client, List<McpSchema.Tool> tools) {

    var toolCallResult1 = client.callTool(McpSchema.CallToolRequest.builder().name("multiply_two_numbers").arguments(Map.of("n1", 12, "n2", 49)).build());
    System.out.println(toolCallResult1.content());

    var toolCallResult2 = client.callTool(McpSchema.CallToolRequest.builder().name("divide_two_numbers").arguments(Map.of("n1", 12, "n2", 49)).build());
    System.out.println(toolCallResult2.content());

    var toolCallResult3 = client.callTool(McpSchema.CallToolRequest.builder().name("add_two_numbers").arguments(Map.of("n1", 12, "n2", 49)).build());
    System.out.println(toolCallResult3.content());

    var toolCallResult4 = client.callTool(McpSchema.CallToolRequest.builder().name("subtract_two_numbers").arguments(Map.of("n1", 12, "n2", 49)).build());
    System.out.println(toolCallResult4.content());



}

`

Error
The error happens after 14-15 iterations of these calls.

`
22:11:56.374 [main] DEBUG i.m.spec.McpClientSession - Sending message for method tools/call
Exception in thread "main" reactor.core.Exceptions$ReactiveException: java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 10000ms in 'source(MonoDeferContextual)' (and no fallback has been configured)
at reactor.core.Exceptions.propagate(Exceptions.java:410)
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:102)
at reactor.core.publisher.Mono.block(Mono.java:1779)
at io.modelcontextprotocol.client.McpSyncClient.callTool(McpSyncClient.java:227)
at agentic.mcp.StandardMcpClient.execTools(StandardMcpClient.java:131)
at agentic.mcp.StandardMcpClient.lambda$main$2(StandardMcpClient.java:107)
at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104)
at java.base/java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:617)
at agentic.mcp.StandardMcpClient.main(StandardMcpClient.java:99)
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:104)
... 7 more
Caused by: java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 10000ms in 'source(MonoDeferContextual)' (and no fallback has been configured)
at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.handleTimeout(FluxTimeout.java:296)
at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.doTimeout(FluxTimeout.java:281)
at reactor.core.publisher.FluxTimeout$TimeoutTimeoutSubscriber.onNext(FluxTimeout.java:420)
at reactor.core.publisher.FluxOnErrorReturn$ReturnSubscriber.onNext(FluxOnErrorReturn.java:162)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.propagateDelay(MonoDelay.java:270)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:285)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)

`

On the python side, I am getting errors that the resource is closed anyio.ClosedResourceError
Verified with another mcp client which works without errors on both client and server
Please let me know if I am missing something.

Thanks in advance.

-Ravi

@rsg-coder
Copy link

One more observation, as an addition to my previous comment.
This issue is reproducible with 0.11.2 + the changes of this commit.

With the latest build of main + the changes of this commit + changes of #502, the client is very stable and I have not had any issue across multiple repeated tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants