Package io.openliberty.mcp.annotations
Annotation Interface Tool
Annotates a business method of a CDI bean as an exposed tool.
A result of a "tool call" operation is always represented as a ToolResponse. However, the annotated method can also
return other types that are converted according to the following rules.
- If it returns
Stringthen the response issuccessand contains a singleTextContent. - If it returns an implementation of
Contentthen the response issuccessand contains a single content object. - If it returns a
ListofContentimplementations or strings then the response issuccessand contains a list of relevant content objects. - It may also return a
CompletionStagethat wraps any of the type mentioned above.
There is a default content encoder registered; it encodes the returned value as JSON using JSON-B.
- See Also:
-
Nested Class Summary
Nested Classes -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionAdditional hints for clients.A human-readable description of the tool.Each tool must have a unique name.booleanIf set totrueand the method returns a typeXwhich is not specifically treated (see the conversion rules), then the return value is converted to JSON and used as astructuredContentof the result.A human-readable title for the tool. -
Field Summary
Fields
-
Field Details
-
ELEMENT_NAME
Constant value forname()indicating that the annotated element's name should be used as-is.- See Also:
-
-
Element Details
-
name
String nameEach tool must have a unique name.Intended for programmatic or logical use, but used for UI in past specs or as fallback if title isn't present.
By default, the name is derived from the name of the annotated method.
- Default:
- "<<element name>>"
-
title
String titleA human-readable title for the tool.- Default:
- ""
-
description
String descriptionA human-readable description of the tool. A hint to the model.- Default:
- ""
-
annotations
Tool.Annotations annotationsAdditional hints for clients.Note that the default value of this annotation member is ignored. In other words, the annotations have to be declared explicitly in order to be included in Tool metadata.
- Default:
- @io.openliberty.mcp.annotations.Tool.Annotations
-
structuredContent
boolean structuredContentIf set totrueand the method returns a typeXwhich is not specifically treated (see the conversion rules), then the return value is converted to JSON and used as astructuredContentof the result.Also the output schema is generated automatically from the return type.
- Default:
- false
-