spring-projects / spring-projects/spring-ai

MCPServer Redeployment causes this behavior "Error sending message: 404" in MCPClient

Open
#2,785 7 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

mcp
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Bug Report

Bug description

I have a MCP Server and the MCP client built. First, I spin up the MCP Server and then the MCP client. My client app interacts with the MCP server and works fine.
However, when I restart or redeploy the MCP Server, the client app interacts with the MCP server, and I observe the following error:

2025-04-17T11:02:40.637-05:00 ERROR 14929 --- [onPool-worker-3] i.m.c.t.HttpClientSseClientTransport : Error sending message: 404 
Detailed Error
2025-04-17T11:02:39.088-05:00 INFO 14929 --- [nio-8086-exec-4] com.llm.controller.ChatsController : userInput message : UserInput(prompt=Find me all the phones ?) 2025-04-17T11:02:39.088-05:00 INFO 14929 --- [nio-8086-exec-4]  

com.llm.controller.ChatsController : requestSpec : org.springframework.ai.chat.client.DefaultChatClient$DefaultChatClientRequestSpec@2f15ab7e 2025-04-17T11:02:39.088-05:00 INFO 14929 --- [nio-8086-exec-4] com.llm.controller.ChatsController : responseSpec1 : org.springframework.ai.chat.client.DefaultChatClient$DefaultCallResponseSpec@21d250ec 2025-04-17T11:02:40.132-05:00 DEBUG 14929 --- [nio-8086-exec-4] o.s.a.m.tool.DefaultToolCallingManager : Executing tool call: spring_ai_mcp_client_person_mcp_server_getAllProducts 

2025-04-17T11:02:40.637-05:00 ERROR 14929 --- [onPool-worker-3] i.m.c.t.HttpClientSseClientTransport : Error sending message: 404 

2025-04-17T11:06:40.155-05:00 ERROR 14929 --- [nio-8086-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: reactor.core.Exceptions$ReactiveException: java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 240000ms in 'source(MonoCreate)' (and no fallback has been configured)] with root cause


Environment

  • Spring AI version: 1.0.0-M7
  • Java version: 21
  • Vector Store: [Provide details if used, or leave blank]

Steps to reproduce

  1. Spin up the MCP Server.
  2. Spin up the MCP client and interact with the MCP Server (this works fine).
  3. Restart or redeploy the MCP Server.
  4. Have the MCP client interact with the MCP server again.
  5. Observe the error.

Expected behavior

I expected the MCP client to interact with the MCP server successfully after the server restart, without any errors.

Minimal Complete Reproducible example

You can view the complete example in my GitHub repository.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the sequence in the issue and linked mcp-webmvc example: start the MCP server and client, then restart the server and invoke a tool. Start by tracing the MCP client's HttpClientSseClientTransport logs around the 404 and timeout. Done means the client successfully interacts with the redeployed server without the 404 or subsequent timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.