Class ChenileToolCallback
java.lang.Object
org.chenile.mcp.model.ChenileToolCallback
- All Implemented Interfaces:
org.springframework.ai.tool.ToolCallback
The MCP transport adapter. Turns an MCP tool call into a
ChenileExchange and runs it through
ChenileEntryPoint, so a tool call passes through the chenile-highway exactly like an HTTP request:
header validation, pre/post processors, transformation, service selection and the service interceptors.
Each tool parameter is bound to the exchange by its HttpBindingType: the BODY parameter is passed
as JSON and typed by the highway's transformer (and body type selectors), HEADER parameters become headers and
a HEADERS parameter is merged into the headers. Polymorph fixed values are bound the same way.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChenileEntryPointprivate final ContextContainer(package private) static org.slf4j.Loggerprivate static final ObjectMapperprivate final OperationDefinitionprivate final List<ChenileToolCallback.ChenileToolParameter> private final ChenileServiceDefinitionprivate final org.springframework.ai.tool.execution.ToolCallResultConverterprivate final org.springframework.ai.tool.definition.ToolDefinitionprivate final org.springframework.ai.tool.metadata.ToolMetadata -
Constructor Summary
ConstructorsConstructorDescriptionChenileToolCallback(org.springframework.ai.tool.definition.ToolDefinition toolDefinition, org.springframework.ai.tool.metadata.ToolMetadata toolMetadata, ChenileEntryPoint chenileEntryPoint, ContextContainer contextContainer, ChenileServiceDefinition serviceDefinition, OperationDefinition operationDefinition, List<ChenileToolCallback.ChenileToolParameter> parameters) -
Method Summary
Modifier and TypeMethodDescriptionprivate StringasHeaderValue(JsonNode node) private voidbind(ChenileExchange exchange, ChenileToolCallback.ChenileToolParameter parameter, JsonNode valueNode) static StringbuildInputSchema(List<ChenileToolCallback.ChenileToolParameter> parameters) private voidcopyCallerHeaders(ChenileExchange exchange, org.springframework.ai.chat.model.ToolContext toolContext) Copies the headers of the HTTP request that carried the tool call (captured byChenileMcpHeaderExtractor) into the exchange.private StringerrorMessage(ChenileExchange exchange) org.springframework.ai.tool.definition.ToolDefinitionorg.springframework.ai.tool.metadata.ToolMetadataprivate ChenileExchangemakeExchange(String toolInput, org.springframework.ai.chat.model.ToolContext toolContext) private Objectprivate JsonNodeprivate static voidremoveRequiredFields(JsonNode node) By default all fields are marked as required.
-
Field Details
-
OBJECT_MAPPER
-
logger
static org.slf4j.Logger logger -
toolDefinition
private final org.springframework.ai.tool.definition.ToolDefinition toolDefinition -
toolMetadata
private final org.springframework.ai.tool.metadata.ToolMetadata toolMetadata -
chenileEntryPoint
-
contextContainer
-
serviceDefinition
-
operationDefinition
-
parameters
-
toolCallResultConverter
private final org.springframework.ai.tool.execution.ToolCallResultConverter toolCallResultConverter
-
-
Constructor Details
-
ChenileToolCallback
public ChenileToolCallback(org.springframework.ai.tool.definition.ToolDefinition toolDefinition, org.springframework.ai.tool.metadata.ToolMetadata toolMetadata, ChenileEntryPoint chenileEntryPoint, ContextContainer contextContainer, ChenileServiceDefinition serviceDefinition, OperationDefinition operationDefinition, List<ChenileToolCallback.ChenileToolParameter> parameters)
-
-
Method Details
-
getToolDefinition
public org.springframework.ai.tool.definition.ToolDefinition getToolDefinition()- Specified by:
getToolDefinitionin interfaceorg.springframework.ai.tool.ToolCallback
-
getToolMetadata
public org.springframework.ai.tool.metadata.ToolMetadata getToolMetadata()- Specified by:
getToolMetadatain interfaceorg.springframework.ai.tool.ToolCallback
-
call
-
call
-
makeExchange
private ChenileExchange makeExchange(String toolInput, org.springframework.ai.chat.model.ToolContext toolContext) -
copyCallerHeaders
private void copyCallerHeaders(ChenileExchange exchange, org.springframework.ai.chat.model.ToolContext toolContext) Copies the headers of the HTTP request that carried the tool call (captured byChenileMcpHeaderExtractor) into the exchange. They are copied before the entry point headers and the tool parameters, so a caller cannot override those. -
readInput
-
bind
private void bind(ChenileExchange exchange, ChenileToolCallback.ChenileToolParameter parameter, JsonNode valueNode) -
asHeaderValue
-
payload
-
errorMessage
-
buildInputSchema
-
removeRequiredFields
By default all fields are marked as required. We need to remove that from the schema manually- Parameters:
node-
-
CHENILE