Package com.agentforge4j.starter.mcp
Class McpAutoConfiguration
java.lang.Object
com.agentforge4j.starter.mcp.McpAutoConfiguration
@AutoConfiguration(before=BootstrapAutoConfiguration.class)
@ConditionalOnClass(com.agentforge4j.mcp.client.McpToolProvider.class)
@EnableConfigurationProperties({McpProperties.class,ToolProperties.class})
public class McpAutoConfiguration
extends Object
Wires MCP servers from
agentforge4j.mcp.* into the runtime's tool SPI, and tool tunables from
agentforge4j.tools.*. Active only when the agentforge4j-mcp module is on the classpath; the exposed
ToolProvider, ToolPolicy, and ToolExecutionOptions beans are consumed by
BootstrapAutoConfiguration.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.agentforge4j.mcp.client.McpServerRegistrymcpServerRegistry(McpProperties properties, ToolProperties toolProperties) List<com.agentforge4j.core.spi.tool.ToolProvider>mcpToolProviders(com.agentforge4j.mcp.client.McpServerRegistry registry, McpProperties properties) Exposes oneMcpToolProviderper enabled configured server, wired with the corresponding connection from the registry.com.agentforge4j.core.spi.tool.ToolPolicycom.agentforge4j.core.spi.tool.ToolExecutionOptionstoolExecutionOptions(ToolProperties properties)
-
Constructor Details
-
McpAutoConfiguration
public McpAutoConfiguration()
-
-
Method Details
-
mcpServerRegistry
@Bean @ConditionalOnMissingBean public com.agentforge4j.mcp.client.McpServerRegistry mcpServerRegistry(McpProperties properties, ToolProperties toolProperties) - Parameters:
properties- bound MCP properties- Returns:
- a registry of connections for every enabled configured server
-
mcpToolProviders
@Bean public List<com.agentforge4j.core.spi.tool.ToolProvider> mcpToolProviders(com.agentforge4j.mcp.client.McpServerRegistry registry, McpProperties properties) Exposes oneMcpToolProviderper enabled configured server, wired with the corresponding connection from the registry. Each provider's ID is derived from the server configuration: ifproviderIdis set, it is used directly; otherwise, the provider ID defaults to"mcp:" + serverId. The provider ID is what agents use in theirproviderPreferencesto select this tool provider for MCP tool execution. The provider's connection is looked up from the registry by the server ID, so the registry bean must be initialized first. The returned providers are collected into a list and exposed as a single bean for the runtime to consume.- Parameters:
registry- the MCP server registryproperties- bound MCP properties- Returns:
- one
McpToolProviderper enabled configured server
-
secureDefaultToolPolicy
@Bean @ConditionalOnMissingBean(com.agentforge4j.core.spi.tool.ToolPolicy.class) public com.agentforge4j.core.spi.tool.ToolPolicy secureDefaultToolPolicy()- Returns:
- the secure-by-default tool policy when the application provides none; denies remote-network and local-process tools unless an explicit policy opts in
-
toolExecutionOptions
@Bean @ConditionalOnMissingBean(com.agentforge4j.core.spi.tool.ToolExecutionOptions.class) public com.agentforge4j.core.spi.tool.ToolExecutionOptions toolExecutionOptions(ToolProperties properties) - Parameters:
properties- bound tool properties- Returns:
- the tool execution options derived from configuration
-