spring-projects / spring-projects/spring-ai

MCP Tool Callback Provider break when mcp server restart with change or stateless

Open
#4,928 7 comments 0 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 description

With the changes on:
https://github.com/spring-projects/spring-ai/commit/57831042ffa45f43e4dbb2dda3d2494796e6d0e1

Caches were introduced to avoid calling the MCP server. But this will break on below usecases:

  • The MCP Server is Stateless -> means no event from the server
  • The MCP Server restarted and has tool changes (I believe even if not stateless this also doesnt work)

Environment

Spring AI version 1.1.0

Steps to reproduce

Create a new Spring AI with MCP Client and connect it to STATELESS Spring AI mcp server

  • Remove/Add tool at runtime, or
  • Just remove the tool and redeploy mcp server

Expected behavior

There are multiple possible solutions:

  • cache with ttl
  • allow disabling the built-in cache, so the application can implement their own cache
  • invalidate cache on error and retry at DefaultToolCallingManager? (probably too overkill)

Workaround

  • Create a scheduled invalidate cache to act as ttl

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

Start by reviewing the cache changes in commit 57831042ffa45f43e4dbb2dda3d2494796e6d0e1 and the DefaultToolCallingManager entry point. Reproduce the issue with a stateless MCP server, then verify how tool changes after restart or redeployment are observed. Done means the chosen cache behavior keeps the available tools current in those scenarios.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.