agentscope-ai / agentscope-ai/agentscope-java

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

未关闭
#2,003 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area/core/tool bug
主要语言
Java
星标
5.6k
派生
1.3k
平均合并
4 天 12 小时
30 天内合并 PR
77

描述

When connecting to a Streamable HTTP MCP server that disables SSE (only accepts POST requests), tool calls hang
indefinitely. The MCP server is discovered and tools are registered successfully during initialization, but actual tool
invocations (callTool) never return — PRE_ACTING fires without a corresponding POST_ACTING.

The root cause is that McpClientBuilder.streamableHttpTransport(url) does not expose the underlying MCP SDK's
HttpClientStreamableHttpTransport.Builder options resumableStreams and openConnectionOnStartup. Both default to true,
meaning the transport always attempts to establish an SSE connection even when the server does not support it. Direct curl
POST calls to the same server work correctly, confirming the issue is in the transport layer, not the server.

To Reproduce

1. Configure a Streamable HTTP MCP server that returns 405 Method Not Allowed for SSE requests (e.g. WeCom Document MCP):

// tools.json
{
"mcpServers": {
"example": {
"transport": "streamableHttp",
"url": "https://qyapi.weixin.qq.com/mcp/robot-doc?apikey=xxx"
}
}
}

2. Build the agent with HarnessAgent.builder()...build().
3. Send a message that triggers an MCP tool call.
4. Observe that PRE_ACTING (tool call started) appears in logs, but POST_ACTING (tool call completed) never fires — the
call hangs.

Minimal reproduction without HarnessAgent:

McpClientWrapper client = McpClientBuilder.create("test")
.streamableHttpTransport("https://sse-disabled-mcp-server.example.com/mcp")
.buildSync();

Toolkit toolkit = new Toolkit();
toolkit.registerMcpClient(client).block();

ReActAgent agent = ReActAgent.builder()
.name("test").model(model).toolkit(toolkit).build();

// This call will hang when the agent tries to invoke an MCP tool
agent.call(new UserMessage("use a tool")).block();

Expected behavior

Tool calls complete successfully against SSE-disabled Streamable HTTP MCP servers.

McpClientBuilder should expose the transport builder options: resumableStreams(false) and openConnectionOnStartup(false),
either via:

McpClientBuilder.create("test")
.streamableHttpTransport(url)
.resumableStreams(false) // API option
.buildSync();

Or via tools.json:

{
"transport": "streamableHttp",
"url": "https://...",
"resumableStreams": false
}

Error messages

During initialization (recovered, tools registered):
io.modelcontextprotocol.spec.McpTransportException: Invalid SSE response. Status code: 405
{"error":"Method Not Allowed","message":"SSE is disabled. Please use POST for /mcp/robot-doc","allowed_methods":["POST"]}

During tool invocation (no error — just hangs forever):
PRE_ACTING | name=create_doc ← fires
POST_ACTING | ← never fires

Environment

- AgentScope-Java Version: 2.0.0-RC4
- MCP Java SDK: 0.17.0 (transitive dependency)
- Java Version: 17
- OS: macOS

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。