Skip to content

fix(mcp): expose resumableStreams and openConnectionOnStartup for str…#2012

Closed
wkflash wants to merge 1 commit into
agentscope-ai:mainfrom
wkflash:fix/mcp-streamable-http-disable-sse
Closed

fix(mcp): expose resumableStreams and openConnectionOnStartup for str…#2012
wkflash wants to merge 1 commit into
agentscope-ai:mainfrom
wkflash:fix/mcp-streamable-http-disable-sse

Conversation

@wkflash

@wkflash wkflash commented Jul 4, 2026

Copy link
Copy Markdown

Summary

Expose resumableStreams and openConnectionOnStartup on McpClientBuilder for Streamable HTTP transport, with
bidirectional call-order safety.

Closes #2003.

Problem

When connecting to a Streamable HTTP MCP server that disables SSE and only accepts POST, tool calls hang indefinitely. The
underlying MCP Java SDK (HttpClientStreamableHttpTransport.Builder) already supports these options, but AgentScope's
builder did not expose them.

Solution

Two new fluent methods + tools.json config support:

Java API

McpClientBuilder.create("example")
    .streamableHttpTransport("https://sse-disabled.example.com/mcp")
    .resumableStreams(false)
    .openConnectionOnStartup(false)
    .buildSync();

tools.json

{
  "mcpServers": {
    "my-server": {
      "transport": "http",
      "url": "https://example.com/mcp",
      "resumableStreams": false,
      "openConnectionOnStartup": false
    }
  }
}

Bidirectional safety

Unlike the approach that only writes to the config object, this PR stores values in both a builder-level field AND syncs to
the config if already present. Both call orders work:

// order 1: transport first → instanceOf check writes to config

// order 2: options first → builder field stored, applied when transport is created
.resumableStreams(false).streamableHttpTransport(url)

Tests

- resumableStreams / openConnectionOnStartup after streamableHttpTransportstored correctly
- resumableStreams / openConnectionOnStartup before streamableHttpTransportstored correctly
- Called on SSE transportsilently ignored, type unchanged
- Called before any transportno NPE
- Both options combined
- JSON deserialization of resumableStreams / openConnectionOnStartup

…eamable HTTP transport

- Add resumableStreams(boolean) and openConnectionOnStartup(boolean) to McpClientBuilder
  with bidirectional safety: builder field + instanceof check covers both call orders
- Wire options through to HttpClientStreamableHttpTransport.Builder
- Add resumableStreams and openConnectionOnStartup to tools.json McpServerConfig
- Wire JSON config through McpServerRegistrar
- Add tests covering both call orders, SSE ignore, no-transport safety, and JSON parsing
@wkflash wkflash requested a review from a team July 4, 2026 16:58
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


王坤 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../io/agentscope/core/tool/mcp/McpClientBuilder.java 83.33% 2 Missing and 2 partials ⚠️
...tscope/harness/agent/tools/McpServerRegistrar.java 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@wkflash wkflash closed this Jul 4, 2026
@wkflash wkflash deleted the fix/mcp-streamable-http-disable-sse branch July 4, 2026 23:15
@wkflash wkflash restored the fix/mcp-streamable-http-disable-sse branch July 4, 2026 23:53
@wkflash wkflash deleted the fix/mcp-streamable-http-disable-sse branch July 5, 2026 00:46
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.

[Bug]:McpClientBuilder.streamableHttpTransport does not expose resumableStreams option — hangs on SSE-disabled MCP servers

2 participants