-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Bug description
There is a special case in MCP tools, where excluding the ToolCallingAutoConfiguration
would be desirable. In a regular Boot application, this would be achieved through:
@SpringBootApplication(exclude = { ToolCallingAutoConfiguration.class })
public class SampleMcpClientWebfluxApplication {
//...
}
However, this does exclude the configuration, because, in my application, I use Anthropic and AnthropicChatAutoConfiguration
. But that auto-configuration pulls in ToolCallingAutoConfiguration
(source), which cannot be excluded independently anymore.
Environment
Spring AI 1.0.x and 1.1.x are affected.
Expected behavior
It is possible to work around this specific case, but it requires diving into the auto-configurations and figuring their dependencies.
I think using @ImportAutoConfiguration
on auto-configuration classes is an anti-pattern, because it breaks the "exclusion" part of the auto-configuration contract.
What should really happen in this case is that:
- Conditions for
ToolCallingAutoConfiguration
are fulfilled, so it is actiaved. - Conditions for
AnthropicChatAutoConfiguration
are fulfilled, so it is activated. - Anthropic is marked
@AutoConfiguration(after = {ToolCallingAutoConfiguration.class})
, so the ordering is taking care of for me.
By doing so, it becomes possible for users to disable auto-configurations.
Problematic classes
- ZhiPuAiChatAutoConfiguration
- MistralAiChatAutoConfiguration (assigned @SuganthiThomas 2025-10-01)
- MistralAiOcrAutoConfiguration (assigned @SuganthiThomas 2025-10-01)
- MistralAiEmbeddingAutoConfiguration (assigned @SuganthiThomas 2025-10-01)
- MistralAiModerationAutoConfiguration (assigned @SuganthiThomas 2025-10-01)
- ElevenLabsAutoConfiguration
- OpenAiChatAutoConfiguration (Fix openai auto-configuration #4548)
- OpenAiModerationAutoConfiguration (Fix openai auto-configuration #4548)
- OpenAiAudioTranscriptionAutoConfiguration (Fix openai auto-configuration #4548)
- OpenAiAudioSpeechAutoConfiguration (Fix openai auto-configuration #4548)
- OpenAiImageAutoConfiguration (Fix openai auto-configuration #4548)
- OpenAiEmbeddingAutoConfiguration (Fix openai auto-configuration #4548)
- OCIGenAiChatAutoConfiguration
- OCIGenAiEmbeddingAutoConfiguration
- GoogleGenAiChatAutoConfiguration (Fix google genai auto configurations #4543)
- GoogleGenAiTextEmbeddingAutoConfiguration (Fix google genai auto configurations #4543)
- MiniMaxChatAutoConfiguration
- OllamaEmbeddingAutoConfiguration (Fix ollama auto-configuration #4495)
- OllamaApiAutoConfiguration (Fix ollama auto-configuration #4495)
- OllamaChatAutoConfiguration (Fix ollama auto-configuration #4495)
- AzureOpenAiChatAutoConfiguration (GH-4494: Fix anthropic model auto-configuration #4550)
- AnthropicChatAutoConfiguration (GH-4494: Fix anthropic model auto-configuration #4550)
- VertexAiGeminiChatAutoConfiguration (Fix VertexAI auto-configuration #4535)
- VertexAiMultiModalEmbeddingAutoConfiguration (Fix VertexAI auto-configuration #4535)
- VertexAiTextEmbeddingAutoConfiguration (Fix VertexAI auto-configuration #4535)
- BedrockConverseProxyChatAutoConfiguration
- DeepSeekChatAutoConfiguration
Each of those can be fixed independently, see #4495 for Ollama.
Fix
All @ImportAutoConfiguration
should be removed. I don't know of any project who uses that annotation (if you'd like to check, their starters are in Boot directly).
This might break existing behavior, and would require thinking about the auto-configuration of excluded classes.