agentscope-ai / agentscope-ai/agentscope-java

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

Ouverte
#2,003 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area/core/tool bug
Langage dominant
Java
Étoiles
5.6k
Forks
1.3k
Merge moyen
4 j 12 h
PR mergées (30 j)
77

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.