Skip to content

MCP Client Ignores Custom Stream Endpoint and Falls Back to /mcp During mcp Tool Discovery #1196

@abhadra2

Description

@abhadra2

Describe the Bug:
When creating an MCP client using StreamableHttpServerParameters with a custom endpoint (/mcp/stream), the client still attempts to connect to the default /mcp endpoint internally while fetching the toolset.

As a result, the MCP client fails with a 404 Not Found error if the server is not exposed on /mcp.

The issue appears to be that the configured endpoint URL is not being consistently honored during tool discovery / initialization.

Steps to Reproduce:
Start an MCP server exposing the stream endpoint at:

http://localhost:8080/mcp/stream

Create the MCP client with:

StreamableHttpServerParameters serverParameters =
new StreamableHttpServerParameters(
"http://localhost:8080/mcp/stream",
Map.of(
"Content-Type", "application/json",
"Accept", "application/json, text/event-stream"
),
null,
null,
null
);

Initialize the toolset and fetch tools:

try (McpToolset toolset = new McpToolset(serverParameters, new ObjectMapper())) {

toolset.getTools(null)
        .subscribe(
                tool -> System.out.println(tool.name()),
                error -> System.err.println(error.getMessage())
        );

}

Observe that the client attempts to connect to:

/mcp

instead of:

/mcp/stream

The client throws:

io.modelcontextprotocol.spec.McpTransportException:
Server Not Found. Status code:404

Expected Behavior:

The MCP client should consistently use the endpoint provided in StreamableHttpServerParameters.

In this case, all requests should go to:

http://localhost:8080/mcp/stream

and tool discovery should succeed.

Observed Behavior:

The MCP client internally falls back to /mcp during initialization/tool discovery, ignoring the configured /mcp/stream endpoint.

Error:

13:35:53.322 [HttpClient-1-Worker-0] WARN io.modelcontextprotocol.client.LifecycleInitializer -- Handling exception
io.modelcontextprotocol.spec.McpTransportException: Server Not Found. Status code:404, response-event:AggregateResponseEvent[
responseInfo=jdk.internal.net.http.ResponseInfoImpl@400b75d8,
data={"timestamp":"2026-05-14T12:35:53.215+00:00","path":"/mcp","status":404,"error":"Not Found","requestId":"8c50bb2d-1"}
]

Additionally, server-side logs confirm that the incoming request is made against:

/mcp

instead of:

/mcp/stream

If the MCP server is exposed on /mcp, the same client code works successfully.

Environment Details:

  • ADK Library Version (see maven dependency): 1.2.0
  • OS: [e.g., macOS, Linux, Windows]: macOS, Linux

Model Information:

  • Which model is being used: (e.g., gemini-2.5-pro) : gemini-2.5-pro

🟡 Optional Information

Providing this information greatly speeds up the resolution process.

Regression:
Did this work in a previous version of ADK? (Yes/No) If so, which one? Not tried

Logs:
13:35:53.322 [HttpClient-1-Worker-0] WARN io.modelcontextprotocol.client.LifecycleInitializer -- Handling exception

io.modelcontextprotocol.spec.McpTransportException: Server Not Found. Status code:404, response-event:AggregateResponseEvent[
responseInfo=jdk.internal.net.http.ResponseInfoImpl@400b75d8,
data={"timestamp":"2026-05-14T12:35:53.215+00:00","path":"/mcp","status":404,"error":"Not Found","requestId":"8c50bb2d-1"}
]

Additional Context:

The issue only occurs when using a custom MCP endpoint path.
The same code works correctly if the server is exposed on the default /mcp endpoint.
This suggests the configured URL is not being propagated consistently during initialization or tool discovery.

Minimal Reproduction Code:
Please provide a code snippet or a link to a Gist/repo that isolates the issue.

StreamableHttpServerParameters serverParameters = new StreamableHttpServerParameters("http://localhost:8080/mcp/stream",Map.of(
                "Content-Type", "application/json",
                "Accept", "application/json, text/event-stream"
        ), null, null, null);

        try (McpToolset toolset = new McpToolset(serverParameters, new ObjectMapper())) {
            System.out.println("MCP Server Tools:\n");

            toolset.getTools(null)
                    .subscribe(
                            tool -> System.out.println("- " + tool.name() + ": " + tool.description()),
                            error -> System.err.println("Error: " + error.getMessage()),
                            () -> System.out.println("\nDone!")
                    );
        }

How often has this issue occurred?:

  • Always (100%)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions