Skip to content

[BUG] McpSyncClientCustomizer sampling method has concurrency safety issues with shared state #4127

@huidongyin

Description

@huidongyin

There are concurrency safety issues in the sampling method of McpSyncClientCustomizer. When multiple MCP clients send requests simultaneously, it may lead to model routing errors and exceptions.

running code : https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/sampling

Image code location: https://github.com/spring-projects/spring-ai-examples/blob/main/model-context-protocol/sampling/mcp-weather-webmvc-server/src/main/java/org/springframework/ai/mcp/sample/server/WeatherService.java

then , client code will lead to model routing errors :
code location :

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions