Bug description
I can successfully connect to my MCP server using the URL "http://localhost:3000/mcp-hub/sse/cf9ec4527e3c4a2cbb149a85ea45ab01" with the local open-source tool MCP Inspector(https://github.com/modelcontextprotocol/inspector).
However, I cannot connect to the same URL with the Spring AI SDK because I don’t know how to split it into baseUri and sseEndpoint.
BTW , "cf9ec4527e3c4a2cbb149a85ea45ab01" is one of my multiple MCP server UUIDs.
Waiting for your help—I’d really appreciate it!
Environment
java.version: 17
spring-ai version : 1.1.0-SNAPSHOT
Steps to reproduce
I tried different cases as below:
1. "http://localhost:3000" and "/mcp-hub/sse/cf9ec4527e3c4a2cbb149a85ea45ab01"
2025/07/29 19:55:01.074 [ForkJoinPool.commonPool-worker-1] WARN i.m.client.LifecycleInitializer-288 - Failed to initialize
java.lang.RuntimeException: Sending message failed with a non-OK HTTP code: 404 - No transport found for sessionId
at io.modelcontextprotocol.client.transport.HttpClientSseClientTransport.lambda$sendMessage$9(HttpClientSseClientTransport.java:426)
at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:113)
... ....
Caused by: io.modelcontextprotocol.spec.McpError: Client failed to initialize by explicit API call
at io.modelcontextprotocol.client.LifecycleInitializer.lambda$withIntitialization$2(LifecycleInitializer.java:289)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
-
"http://localhost:3000/mcp-hub" and "/sse/cf9ec4527e3c4a2cbb149a85ea45ab01"
2025/07/29 19:57:37.299 [HttpClient-1-Worker-0] ERROR reactor.core.publisher.Operators-324 - Operator called default onErrorDropped reactor.core.Exceptions$ErrorCallbackNotImplemented: io.modelcontextprotocol.spec.McpError: Invalid SSE response. Status code: 404 Line: {"error_msg":"404 Route Not Found"} Caused by: io.modelcontextprotocol.spec.McpError: Invalid SSE response. Status code: 404 Line: {"error_msg":"404 Route Not Found"} at io.modelcontextprotocol.client.transport.ResponseSubscribers$SseLineSubscriber.hookOnNext(ResponseSubscribers.java:173) at io.modelcontextprotocol.client.transport.ResponseSubscribers$SseLineSubscriber.hookOnNext(ResponseSubscribers.java:67)
Invalid SSE response. Status code: 404 Line: {"error_msg":"404 Route Not Found"} -
"http://localhost:3000/mcp-hub/sse" and "/cf9ec4527e3c4a2cbb149a85ea45ab01" The error messages were the same as in Case 2.
My Code ` public static McpSyncClient buildSyncMcpClientTransport(MCPServerInfo mcpServerInfo) {
HttpClient.Builder clientBuilder = HttpClient.newBuilder();
clientBuilder.connectTimeout(Duration.ofSeconds(10));
McpClientTransport transport = HttpClientSseClientTransport
.builder(mcpServerInfo.getBaseUri())
.sseEndpoint(mcpServerInfo.getSseEndpoint())
.clientBuilder(clientBuilder)
.objectMapper(new ObjectMapper())
.build();
NamedClientMcpTransport namedTransport = new NamedClientMcpTransport(mcpServerInfo.getName(), transport);
McpSyncClient mcpClient = McpClient.sync(namedTransport.transport())
.clientInfo(new McpSchema.Implementation("client-name", "1.0.0"))
.requestTimeout(Duration.ofSeconds(15)).build();
try {
mcpClient.initialize();
} catch (Exception e) {
log.error("SSE initialization failed: URI={}, Endpoint={}, Error={}",
mcpServerInfo.getBaseUri(), mcpServerInfo.getSseEndpoint(), e.getMessage());
throw new RuntimeException("SSE connection failed, please check server status or configuration", e);
}
ToolCallbackProvider provider = new SyncMcpToolCallbackProvider(mcpClient);
ToolCallback[] tools = provider.getToolCallbacks();
try {
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(tools);
log.debug("Original MCP tool list: {}", jsonString);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return mcpClient;
} ` BTW I can succesfully connect to amap mcp server with above spring ai code . "baseUri": "https://mcp.amap.com", "sseEndpoint": "/sse?key=mykey",
Comment From: wilocu
take