Skip to content

Conversation

@ThomasVitale
Copy link
Contributor

@ThomasVitale ThomasVitale commented May 18, 2025

Currently, the MCP Tool autoconfiguration defines the SyncMcpToolCallbackProvider and AsyncMcpToolCallbackProvider beans returning the ToolCallbackProvider interface. That generates autowiring warnings in IDEs when trying to inject the specific class.

Screenshot 2025-05-18 at 19 25 37

The Spring Boot project recommends being specific:

When declaring a @bean method, provide as much type information as possible in the method’s return type. For example, if your bean’s concrete class implements an interface the bean method’s return type should be the concrete class and not the interface. Providing as much type information as possible in @bean methods is particularly important when using bean conditions as their evaluation can only rely upon to type information that is available in the method signature.

See https://docs.spring.io/spring-boot/reference/features/developing-auto-configuration.html#features.developing-auto-configuration.condition-annotations.bean-conditions

This PR ensures concrete classes are used. That's also in line with what included in the documentation:

Screenshot 2025-05-18 at 19 35 47

Currently, the MCP Tool autoconfiguration defines the SyncMcpToolCallbackProvider and AsyncMcpToolCallbackProvider beans returning the ToolCallbackProvider interface. That generates autowiring warnings in IDEs when trying to inject the specific class.

The Spring Boot project recommends being specific. 'When declaring a @bean method, provide as much type information as possible in the method’s return type. For example, if your bean’s concrete class implements an interface the bean method’s return type should be the concrete class and not the interface. Providing as much type information as possible in @bean methods is particularly important when using bean conditions as their evaluation can only rely upon to type information that is available in the method signature.'

See https://docs.spring.io/spring-boot/reference/features/developing-auto-configuration.html#features.developing-auto-configuration.condition-annotations.bean-conditions

This PR ensures concrete classes are used.

Signed-off-by: Thomas Vitale <[email protected]>
@markpollack markpollack added this to the 1.0.0 milestone May 18, 2025
@tzolov
Copy link
Contributor

tzolov commented May 18, 2025

Thanks @ThomasVitale
There is small risk with List beans but lets take it

@tzolov tzolov added the MCP label May 18, 2025
@tzolov tzolov merged commit 81137ca into spring-projects:main May 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants