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: 1. Conditions for ToolCallingAutoConfiguration are fulfilled, so it is actiaved. 1. Conditions for AnthropicChatAutoConfiguration are fulfilled, so it is activated. 1. 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 (assigned @ielatif 2025-10-01)
  • [ ] OpenAiModerationAutoConfiguration (assigned @ielatif 2025-10-01)
  • [ ] OpenAiAudioTranscriptionAutoConfiguration (assigned @ielatif 2025-10-01)
  • [ ] OpenAiAudioSpeechAutoConfiguration (assigned @ielatif 2025-10-01)
  • [ ] OpenAiImageAutoConfiguration (assigned @ielatif 2025-10-01)
  • [ ] OpenAiEmbeddingAutoConfiguration (assigned @ielatif 2025-10-01)
  • [ ] OCIGenAiChatAutoConfiguration
  • [ ] OCIGenAiEmbeddingAutoConfiguration
  • [ ] GoogleGenAiChatAutoConfiguration
  • [ ] GoogleGenAiTextEmbeddingAutoConfiguration
  • [ ] MiniMaxChatAutoConfiguration
  • [x] OllamaEmbeddingAutoConfiguration (#4495)
  • [x] OllamaApiAutoConfiguration (#4495)
  • [x] OllamaChatAutoConfiguration (#4495)
  • [ ] AzureOpenAiChatAutoConfiguration (assigned @loveysuby 2025-10-02)
  • [ ] AnthropicChatAutoConfiguration (assigned @loveysuby 2025-10-02)
  • [ ] VertexAiGeminiChatAutoConfiguration (assigned @centrumek 2025-10-02)
  • [ ] VertexAiMultiModalEmbeddingAutoConfiguration (assigned @centrumek 2025-10-02)
  • [ ] VertexAiTextEmbeddingAutoConfiguration (assigned @centrumek 2025-10-02)
  • [ ] 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.

Comment From: tzolov

If you consider helping with this issue, please contribute a single model auto-configuration at at time. You can use the #4495 as a reference.

Comment From: SuganthiThomas

Hi, I’d like to contribute to this issue. Could you please assign it to me?

Comment From: Kehrlann

@SuganthiThomas I wouldn't assign the whole issue. But please let us know which model you'd like to tackle before submitting a PR.

Comment From: ielatif

Hello, i'd like also to contribute to this. I'll handle OpenAI auto-configurations

  • OpenAiChatAutoConfiguration
  • OpenAiModerationAutoConfiguration
  • OpenAiAudioTranscriptionAutoConfiguration
  • OpenAiAudioSpeechAutoConfiguration
  • OpenAiImageAutoConfiguration
  • OpenAiEmbeddingAutoConfiguration

Comment From: Kehrlann

Sure thing, @ielatif . Please ping me in the PR once it's open.

Comment From: SuganthiThomas

Hi @Kehrlann ,

I will contribute following files

MistralAiChatAutoConfiguration

MistralAiOcrAutoConfiguration

MistralAiEmbeddingAutoConfiguration

MistralAiModerationAutoConfiguration

Thank You

Comment From: loveysuby

Hello, @Kehrlann. I`d like to refactor this model.

AzureOpenAiChatAutoConfiguration AnthropicChatAutoConfiguration

Comment From: centrumek

Hello, @Kehrlann

I'll take the following: - VertexAiGeminiChatAutoConfiguration - VertexAiMultiModalEmbeddingAutoConfiguration - VertexAiTextEmbeddingAutoConfiguration

Comment From: devbulchandani

Hey @Kehrlann, I have raise a PR fixing the following:

  • GoogleGenAiChatAutoConfiguration
  • GoogleGenAiTextEmbeddingAutoConfiguration

Comment From: HyunSangHan

Hi @Kehrlann, I'd like to fix: - DeepSeekChatAutoConfiguration

Comment From: centrumek

@Kehrlann VertexAI done -> https://github.com/spring-projects/spring-ai/pull/4535

I'll take the next tasks: - ZhiPuAiChatAutoConfiguration - ElevenLabsAutoConfiguration - BedrockConverseProxyChatAutoConfiguration