spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

spring-ai-starter-mcp-server-webmvc:1.1.0 McpTool cannot found in StatelessServerSpecificationFactoryAutoConfiguration#toolSpecs

Open LaCoCa opened this issue 1 week ago • 0 comments
trafficstars

Hi, My configuration is: spring-ai-starter-mcp-server-webmvc:1.1.0 spring.ai.mcp.server.protocol = STATELESS spring.ai.mcp.server.type= SYNC

McpTool was not scanned in case of AOP.

Example:

@Service public class CaseMcpTool {

@Tool(description = "{Get balance of case reference . Balance of case reference . Method load balance of the case reference.") @McpTool(description = "Get balance of case reference . Balance of case reference . Method load balance of the case reference.") public String findBalanceByCaseReference(@McpToolParam(description = "Case reference .") String reference) { return "1000"; } }

In AbstractAnnotatedMethodBeanPostProcessor#postProcessAfterInitialization the bean "caseMcpTool" is found and register. But in StatelessServerSpecificationFactoryAutoConfiguration#toolSpecs -> SyncStatelessMcpToolProvider.getToolSpecifications there is an issue here: public List<SyncToolSpecification> getToolSpecifications() {

	List<SyncToolSpecification> toolSpecs = this.toolObjects.stream()
		.map(toolObject -> Stream.of(this.doGetClassMethods(toolObject))
			.filter(method -> **method.isAnnotationPresent(McpTool.class)**)

method.isAnnotationPresent(McpTool.class)) cannot find McpTool annotation in case of AOP .

Maybe you have to use AopUtils.isAopProxy(toolObject)

When I add this ToolCallbackProvider , all is Ok:

@Bean public ToolCallbackProvider imxTools() { return MethodToolCallbackProvider.builder().toolObjects(new CaseMcpTool()).build(); }

Without ToolCallbackProvider , McpTool didn't work.

LaCoCa avatar Nov 14 '25 12:11 LaCoCa