Package io.openliberty.mcp.tools
Interface ToolManager.ToolDefinition
- All Superinterfaces:
FeatureManager.FeatureDefinition<ToolManager.ToolInfo,,ToolManager.ToolArguments, org.mcpjava.server.tools.ToolResponse, ToolManager.ToolDefinition> org.mcpjava.server.MetaCarrier.Builder<ToolManager.ToolDefinition>
- Enclosing interface:
- ToolManager
public static interface ToolManager.ToolDefinition
extends FeatureManager.FeatureDefinition<ToolManager.ToolInfo,ToolManager.ToolArguments,org.mcpjava.server.tools.ToolResponse,ToolManager.ToolDefinition>
A builder to define a new tool. Created with
ToolManager.newTool(String).
This construct is not thread-safe and should not be reused.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ToolManager.ToolDefinitionaddArgument(String name, String description, boolean required, Type type) Adds an argument to the tool.addArgument(String name, String description, boolean required, Type type, String defaultValue) Adds an argument to the tool.generateOutputSchema(Class<?> from) Sets the class to use to generate the output schema for structured content.register()Add the new tool to the tool manager.setAnnotations(ToolManager.ToolAnnotations annotations) Sets the annotations of the toolsetInputSchema(Object schema) Sets the input schema for this tool.setOutputSchema(Object schema) Sets the output schema for structured content.Sets the human-readable title of the toolMethods inherited from interface io.openliberty.mcp.features.FeatureManager.FeatureDefinition
setAsyncHandler, setDescription, setHandlerMethods inherited from interface org.mcpjava.server.MetaCarrier.Builder
putMetadata, setMetadata
-
Method Details
-
addArgument
default ToolManager.ToolDefinition addArgument(String name, String description, boolean required, Type type) Adds an argument to the tool.- Parameters:
name- the argument namedescription- the argument descriptionrequired- whether the argument is requiredtype- the argument type- Returns:
- self this builder
-
addArgument
ToolManager.ToolDefinition addArgument(String name, String description, boolean required, Type type, String defaultValue) Adds an argument to the tool.- Parameters:
name- the argument namedescription- the argument descriptionrequired- whether the argument is requiredtype- the argument typedefaultValue- the default value for the argument- Returns:
- self this builder
-
setAnnotations
Sets the annotations of the tool- Parameters:
annotations- the tool annotations- Returns:
- self this builder
-
setTitle
Sets the human-readable title of the tool- Parameters:
title- the title- Returns:
- self this builder
-
generateOutputSchema
Sets the class to use to generate the output schema for structured content.The class will be inspected and a schema generated which will match the JSON which JSON-B would generate for a class of this type.
Ignored if
setOutputSchema(Object)is called.- Parameters:
from- the class to use to generate the schema- Returns:
- self this builder
-
setOutputSchema
Sets the output schema for structured content.JSON-B will be used to convert
schemato JSON.- Parameters:
schema- the output schema- Returns:
- self this builder
-
setInputSchema
Sets the input schema for this tool.If not set, the input schema is generated automatically from the tool argument types.
JSON-B will be used to convert
schemato JSON.- Parameters:
schema- the input schema- Returns:
- self this builder
-
register
ToolManager.ToolInfo register()Add the new tool to the tool manager.- Specified by:
registerin interfaceFeatureManager.FeatureDefinition<ToolManager.ToolInfo,ToolManager.ToolArguments, org.mcpjava.server.tools.ToolResponse, ToolManager.ToolDefinition> - Returns:
- the tool info for the newly created tool
- Throws:
IllegalArgumentException- if a tool with the given name already exits
-