java.lang.Object
com.agentforge4j.tools.http.HttpToolProvider
- All Implemented Interfaces:
ToolProvider
ToolProvider that fulfils logical capabilities with single governed HTTP calls described
by code-defined HttpEndpointDefinitions. It is the tool-SPI-native successor to the
legacy endpoint-call command: capability resolution stays with the resolver; this provider maps
one capability invocation to one request, applies a transient-only retry/timeout policy that can
only tighten the runtime options, and maps the response to a ToolResult.
All definitions are validated at construction (fail-fast) so a bad configuration is rejected at wiring time, not mid-run. Secret header values are resolved through the supplied resolver at invoke time and are never inlined into a definition or routed through arguments.
-
Constructor Summary
ConstructorsConstructorDescriptionHttpToolProvider(String configuredName, List<HttpEndpointDefinition> definitions, Function<String, String> secretResolver, HttpClient httpClient, OutboundEgressGuard egressGuard, ToolExecutionOptions defaultOptions, long defaultMaxResponseBytes, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates a provider over a fixed set of endpoint definitions, validating them up front. -
Method Summary
Modifier and TypeMethodDescriptionhealth()invoke(ToolDescriptor descriptor, String arguments, ToolInvocationContext ctx, ToolExecutionOptions options) Invokes the resolved tool.
-
Constructor Details
-
HttpToolProvider
public HttpToolProvider(String configuredName, List<HttpEndpointDefinition> definitions, Function<String, String> secretResolver, HttpClient httpClient, OutboundEgressGuard egressGuard, ToolExecutionOptions defaultOptions, long defaultMaxResponseBytes, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates a provider over a fixed set of endpoint definitions, validating them up front.- Parameters:
configuredName- non-blank name;providerId()is"http:" + namedefinitions- endpoint definitions; non-null, each validated up frontsecretResolver- secret-reference key to value resolver, used at invoke timehttpClient- the JDK HTTP client used for all callsegressGuard- SSRF egress guard consulted against each mapped URL before the calldefaultOptions- fallback execution options when none are supplied at invokedefaultMaxResponseBytes- response body read cap for definitions that do not set one- Throws:
IllegalArgumentException- if the name is blank or any definition is invalid
-
-
Method Details
-
providerId
- Specified by:
providerIdin interfaceToolProvider- Returns:
- stable, non-blank provider id, for example
"mcp:github-official"
-
listTools
- Specified by:
listToolsin interfaceToolProvider- Returns:
- descriptors for every tool this provider currently exposes
-
invoke
public ToolResult invoke(ToolDescriptor descriptor, String arguments, ToolInvocationContext ctx, ToolExecutionOptions options) Description copied from interface:ToolProviderInvokes the resolved tool.- Specified by:
invokein interfaceToolProvider- Parameters:
descriptor- resolved descriptor; useToolSource.remoteToolName()for the remote namearguments- tool arguments as JSON text, ornullctx- invocation contextoptions- tunables; the provider may honour these best-effort, but the authoritative timeout is enforced by the execution service- Returns:
- the invocation result
-
health
- Specified by:
healthin interfaceToolProvider- Returns:
- current provider health
-