Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a bug in MCP client auto configuration, will cause: IllegalStateException: Multiple tools with the same name #2301

Open
banalite opened this issue Feb 24, 2025 · 1 comment

Comments

@banalite
Copy link

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description
I am trying to using mcpSyncClient to list tools, but there is a exeception: java.lang.IllegalStateException: Multiple tools with the same name.

Environment
Please provide as many details as possible: Version: 1.0.0-M6. And main baranch: 1.0.0-SNAPSHOT

Steps to reproduce
Just using McpSyncClient to list tools

Expected behavior
A clear and concise description of what you expected to happen.

Minimal Complete Reproducible example
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ai.tool.resolution.ToolCallbackResolver]: Factory method 'toolCallbackResolver' threw exception with message: Multiple tools with the same name (getAlerts, getWeatherForecastByLocation)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:199) ~[spring-beans-6.2.3.jar:6.2.3]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:88) ~[spring-beans-6.2.3.jar:6.2.3]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:168) ~[spring-beans-6.2.3.jar:6.2.3]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-6.2.3.jar:6.2.3]
... 21 common frames omitted
Caused by: java.lang.IllegalStateException: Multiple tools with the same name (getAlerts, getWeatherForecastByLocation)
at org.springframework.ai.mcp.SyncMcpToolCallbackProvider.validateToolCallbacks(SyncMcpToolCallbackProvider.java:126) ~[spring-ai-mcp-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.mcp.SyncMcpToolCallbackProvider.getToolCallbacks(SyncMcpToolCallbackProvider.java:110) ~[spring-ai-mcp-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.mcp.SyncMcpToolCallbackProvider.getToolCallbacks(SyncMcpToolCallbackProvider.java:68) ~[spring-ai-mcp-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.autoconfigure.chat.model.ToolCallingAutoConfiguration.lambda$toolCallbackResolver$0(ToolCallingAutoConfiguration.java:58) ~[spring-ai-spring-boot-autoconfigure-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
at org.springframework.ai.autoconfigure.chat.model.ToolCallingAutoConfiguration.toolCallbackResolver(ToolCallingAutoConfiguration.java:58) ~[spring-ai-spring-boot-autoconfigure-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:171) ~[spring-beans-6.2.3.jar:6.2.3]
... 24 common frames omitted

@banalite
Copy link
Author

banalite commented Feb 24, 2025

The problem was caused by SseHttpClientTransportAutoConfiguration in spring-ai-mcp-client module. And I have fixed it locally.I would submit a pull request then.

banalite added a commit to banalite/spring-ai that referenced this issue Feb 24, 2025
…tion will always run for the class name in @ConditionalOnMissingClass is wrong.
banalite added a commit to banalite/spring-ai that referenced this issue Feb 24, 2025
…tion will always run for the class name in @ConditionalOnMissingClass is wrong.

Signed-off-by: Mota <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant