-
Couldn't load subscription status.
- Fork 2k
Description
Bug description
When implementing an MCP server using Spring AI 1.1.0-M1 and annotating beans with @McpTool, the tools are not registered at server startup, even though the property spring.ai.mcp.server.annotation-scanner.enabled is explicitly set to true. The documentation (https://docs.spring.io/spring-ai/reference/1.1/api/mcp/mcp-server-boot-starter-docs.html) suggests that this should work without manual registration.
As a workaround, tools are registered if I annotate beans with @Tool and create a bean of type ToolCallbackProvider that manually passes the beans (e.g., via MethodToolCallbackProvider.builder().toolObjects(productService, timeService).build()). This workaround was standard in 1.0.x, but the documentation for 1.1.x indicates that @McpTool with annotation scanning should suffice.
This points to a problem either in the property spring.ai.mcp.server.annotation-scanner.enabled or the annotation scanning functionality for MCP tools in 1.1.x.
Environment
- Spring AI version: 1.1.0-M1
- Java version: 21
- MCP server transport: HTTP Streamable
- Property set:
spring.ai.mcp.server.annotation-scanner.enabled=true - Beans annotated with
@McpTool
Steps to reproduce
- Create a Spring Boot MCP server with Spring AI 1.1.0-M1.
- Annotate beans with
@McpTooland define tool methods. - Set
spring.ai.mcp.server.annotation-scanner.enabled=true. - Start the server.
- Observe that tools are not registered.
- Switch to
@Toolannotation and manually register beans via aToolCallbackProviderbean; tools are registered as expected.
Expected behavior
Beans annotated with @McpTool should be automatically registered as tools when the annotation scanner is enabled, per documentation, without requiring manual registration.
Minimal Complete Reproducible example
@Bean
ToolCallbackProvider productTools(ProductService productService, TimeService timeService) {
return MethodToolCallbackProvider.builder()
.toolObjects(productService, timeService)
.build();
}But this should not be necessary when using @McpTool and the annotation scanner property.
Please advise if there is a known issue or if a fix is planned for future releases.