The motivation is to simplify tool definition for MCP server, we could introduce a specialization of @Component such as @ToolComponent and auto-configure corresponding beans as ToolCallbackProvider:

@Qualifier
@Component
@Target({ElementType.TYPE, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface ToolComponent {

    @AliasFor(annotation = Component.class)
    String value() default "";

}
    @Bean
    @ConditionalOnMissingBean
    ToolCallbackProvider toolCallbackProvider(@ToolComponent Object[] tools) {
        return MethodToolCallbackProvider.builder().toolObjects(tools).build();
    }

Then we can write tools like this:

@ToolComponent
public class WeatherTool {

    @Tool
    public String getWeatherForecastByLocation(String latitude, String longitude) {
        ...
    }
}

I'd like to contribute if the proposal is accepted.

Comment From: YunKuiLu

Does this project meet your mind? https://github.com/spring-ai-community/mcp-annotations

Comment From: quaff

Does this project meet your mind? https://github.com/spring-ai-community/mcp-annotations

Thanks for letting me know this project, I had a peek and didn't find annotation like @ToolComponent.

Comment From: tzolov

Starting with 1.1.0-SNAPSHOT the mcp-annotations are integrated with proper spring-ai auto-configuraitons: https://docs.spring.io/spring-ai/reference/1.1-SNAPSHOT/api/mcp/mcp-annotations-overview.html I'm closing this issue as resolved. Feel free to re-open if something is missing.