Spring Boot auto-configuration platform for Embabel Agent Framework, enabling annotation-driven profile activation and bootstrapping of agent configurations with MCP client support
Configure Model Context Protocol (MCP) clients for agent tool integration.
spring.ai.mcp.client.enabled=true
spring.ai.mcp.client.type=SYNC
spring.ai.mcp.client.name=my-agent
spring.ai.mcp.client.version=1.0.0
spring.ai.mcp.client.request-timeout=10s
spring.ai.mcp.client.initialized=trueimport io.modelcontextprotocol.client.McpSyncClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AgentService {
@Autowired
private List<McpSyncClient> mcpClients;
public void executeTask() {
if (mcpClients.isEmpty()) {
// No clients available
return;
}
McpSyncClient client = mcpClients.get(0);
// Use MCP client for tool execution
// See Spring AI MCP documentation for client API
}
}spring.ai.mcp.client.type=SYNC@Autowired
private List<McpSyncClient> mcpSyncClients;
public void syncOperation() {
McpSyncClient client = mcpSyncClients.get(0);
client.initialize(); // Blocking
// Blocking operations
}Use when: Traditional blocking code, simpler error handling.
spring.ai.mcp.client.type=ASYNCimport io.modelcontextprotocol.client.McpAsyncClient;
import reactor.core.publisher.Mono;
@Autowired
private List<McpAsyncClient> mcpAsyncClients;
public Mono<Void> asyncOperation() {
if (mcpAsyncClients.isEmpty()) {
return Mono.empty();
}
McpAsyncClient client = mcpAsyncClients.get(0);
return client.initialize()
.then(/* Reactive operations */);
}Use when: Reactive/WebFlux applications, non-blocking I/O.
spring.ai.mcp.client.initialized=trueBehavior:
Logging on failure:
ERROR c.e.a.a.p.QuiteMcpClientAutoConfiguration -
Failed to initialize MCP Sync Client: my-client - filesystem
- Application startup will continuespring.ai.mcp.client.initialized=false@Autowired
private List<McpSyncClient> clients;
@PostConstruct
public void initClients() {
for (McpSyncClient client : clients) {
try {
client.initialize();
logger.info("Client initialized successfully");
} catch (Exception e) {
logger.error("Failed to initialize client", e);
}
}
}Use when:
import org.springframework.ai.mcp.client.common.autoconfigure.configurer.McpSyncClientConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.Duration;
@Configuration
public class McpClientConfig {
@Bean
public McpSyncClientConfigurer customConfigurer() {
return (transportName, spec) -> {
// Customize per transport
if ("filesystem".equals(transportName)) {
return spec.requestTimeout(Duration.ofSeconds(30));
}
return spec;
};
}
}import org.springframework.ai.mcp.client.common.autoconfigure.configurer.McpAsyncClientConfigurer;
@Bean
public McpAsyncClientConfigurer asyncConfigurer() {
return (transportName, spec) -> spec
.requestTimeout(Duration.ofSeconds(20))
// Additional customizations
;
}MCP clients require transports. See Spring AI documentation for transport-specific setup.
See Spring AI MCP transport documentation for detailed transport configuration.
Built-in behavior: Failed client initialization doesn't prevent application startup.
// Automatic error handling (pseudocode)
try {
client.initialize();
clients.add(client); // Success
} catch (Throwable t) {
logger.error("Failed to initialize MCP Client: {} - Application continues",
clientName, t);
// Client excluded, app continues
}@Autowired
private List<McpSyncClient> mcpClients;
public void safeUse() {
if (mcpClients.isEmpty()) {
logger.warn("No MCP clients available");
// Fallback behavior
return;
}
// Use clients
}@Autowired
private List<McpSyncClient> clients;
public void retryInit() {
for (McpSyncClient client : clients) {
try {
if (!client.isInitialized()) {
client.initialize();
}
} catch (Exception e) {
logger.error("Retry failed", e);
}
}
}spring:
ai:
mcp:
client:
enabled: true
type: SYNC
name: dev-agent
version: 0.1.0
request-timeout: 30s
initialized: false # Manual init for debuggingspring:
ai:
mcp:
client:
enabled: true
type: ASYNC
name: prod-agent
version: 1.0.0
request-timeout: 5s
initialized: true# Disable MCP clients in tests
spring.ai.mcp.client.enabled=falsespring.ai.mcp.client.enabled=falseEffect: No MCP client beans created.
@SpringBootApplication(exclude = {
QuiteMcpClientAutoConfiguration.class
})
public class MyApp { }Or via properties:
spring.autoconfigure.exclude=\
com.embabel.agent.autoconfigure.platform.QuiteMcpClientAutoConfigurationMCP client beans are lists supporting multiple clients:
@Autowired
private List<McpSyncClient> mcpClients; // May contain multiple clients
public void useAll() {
for (McpSyncClient client : mcpClients) {
// Use each client
}
}
public void useSpecific(String transportName) {
for (McpSyncClient client : mcpClients) {
if (client.getTransportName().equals(transportName)) {
// Use specific client
}
}
}import org.springframework.ai.mcp.client.common.autoconfigure.handler.ClientMcpSyncHandlersRegistry;
import org.springframework.stereotype.Component;
@Component
public class MySyncHandlers implements ClientMcpSyncHandlersRegistry {
@Override
public void handleLogging(String transportName,
LoggingMessageNotification notification) {
logger.info("[{}] {}", transportName, notification.getMessage());
}
@Override
public void handleProgress(String transportName,
ProgressNotification notification) {
logger.info("Progress: {}", notification.getProgress());
}
// Implement other handler methods...
}import org.springframework.ai.mcp.client.common.autoconfigure.handler.ClientMcpAsyncHandlersRegistry;
import reactor.core.publisher.Mono;
@Component
public class MyAsyncHandlers implements ClientMcpAsyncHandlersRegistry {
@Override
public Mono<Void> handleLogging(String transportName,
LoggingMessageNotification notification) {
return Mono.fromRunnable(() ->
logger.info("[{}] {}", transportName, notification.getMessage())
);
}
// Implement other handler methods returning Mono<?>...
}Check:
spring.ai.mcp.client.enabled=trueMcpSchema.class on classpathSolution: Increase timeout:
spring.ai.mcp.client.request-timeout=30sCause: Transport auto-configuration not loaded.
Solution: Ensure transport dependency is present and configured.
Install with Tessl CLI
npx tessl i tessl/maven-com-embabel-agent--embabel-agent-platform-autoconfigure@0.3.0