Bug description I developed a MCP server with webmvc SSE endpoint but when a client connects via /sse endpoint, after appx 5 min later server drops connection. This is happen because Client-side needs from server-side to ping itself. Current release doesnt support this and @tzolov suggested a solution but does spring ai support this not sure.
Environment JDK:17 Spring Boot: 3.5.3 Spring AI: 1.0.0
Steps to reproduce You can reproduce this bug on any setup. I try with Spring example with webmvc https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/weather/starter-webmvc-server You can start this app and just connect it with cursor or vscode and then 5min later client will got an error.
Client-side servername: LOCAL-SERVER, "LOCAL-SERVER": { "url": "http://localhost:8080/sse" }
2025-07-18 21:18:05.422 [info] user-LOCAL-SERVER: Handling CreateClient action 2025-07-18 21:18:05.422 [info] user-LOCAL-SERVER: Creating streamableHttp transport 2025-07-18 21:18:05.422 [info] user-LOCAL-SERVER: Connecting to streamableHttp server 2025-07-18 21:18:05.432 [error] user-LOCAL-SERVER: Client error for command Error POSTing to endpoint (HTTP 404): {"timestamp":"2025-07-18T18:18:05.431+00:00","status":404,"error":"Not Found","path":"/sse"} 2025-07-18 21:18:05.433 [info] user-LOCAL-SERVER: Client closed for command 2025-07-18 21:18:05.433 [error] user-LOCAL-SERVER: Error connecting to streamableHttp server, falling back to SSE: Error POSTing to endpoint (HTTP 404): {"timestamp":"2025-07-18T18:18:05.431+00:00","status":404,"error":"Not Found","path":"/sse"} 2025-07-18 21:18:05.433 [error] user-LOCAL-SERVER: Error connecting to streamableHttp server, falling back to SSE: Error POSTing to endpoint (HTTP 404): {"timestamp":"2025-07-18T18:18:05.431+00:00","status":404,"error":"Not Found","path":"/sse"} 2025-07-18 21:18:05.433 [info] user-LOCAL-SERVER: Connecting to SSE server 2025-07-18 21:18:05.448 [info] user-LOCAL-SERVER: Successfully connected to streamableHttp server 2025-07-18 21:18:05.448 [info] user-LOCAL-SERVER: Storing streamableHttp client 2025-07-18 21:18:05.449 [info] user-LOCAL-SERVER: Handling ListOfferings action 2025-07-18 21:18:05.449 [info] user-LOCAL-SERVER: Listing offerings 2025-07-18 21:18:05.449 [info] user-LOCAL-SERVER: Connected to streamableHttp server, fetching offerings 2025-07-18 21:18:05.452 [info] listOfferings: Found 3 tools 2025-07-18 21:18:05.452 [info] user-LOCAL-SERVER: Found 3 tools 2025-07-18 21:23:09.107 [error] user-LOCAL-SERVER: Client error for command SSE error: TypeError: terminated: Body Timeout Error
Expected behavior You can add periodic ping option to keep alive for each client connection. (time)
Comment From: sunyuhan1998
Same issue: #3763
Comment From: sunyuhan1998
I think it would be better if we wait for MCP's SDK to resolve the issue instead of doing the processing in Spring AI first based on a temporary solution?
Comment From: albayrakkonur
java sdk release a new version 0.11.0. Developers added a function (KeepAliveScheduler) to ping client-side periodically. https://github.com/modelcontextprotocol/java-sdk/releases/tag/v0.11.0. This will fix the issue.