@Tool annotation
A tool annotation is metadata attached to a method or tool definition that marks it as invocable and describes its operation and characteristics to clients or AI systems.
Spring AI in Action
The @Tool annotation marks a method as a callable tool that an AI application can expose to a language model.
- How it is used
- Exposes Spring-managed Java methods so language models can request real-time data, repository queries, or external capabilities.
- How deep it goes
- Explains annotation metadata, parameter descriptions, registration points, invocation flow, and method security without detailing framework internals.
- Examples
- Uses time-zone lookup, board-game complexity queries, prompt registration, MCP exposure, and secured premium-user access.
- What you can do after
- Build callable Spring AI tools from annotated Java methods and register or secure them for model-driven application requests.
Software Testing with Generative AI
A LangChain4j annotation that marks a method as an invocable tool and supplies natural-language metadata describing its operation.
- How it is used
- Marks methods as LLM-callable tools and describes when their operations match user instructions.
- How deep it goes
- Explains annotation-based method matching, parameter extraction, registration, and execution, but does not detail model decision internals.
- Examples
- Demonstrates room creation, booking creation, database display, and a combined prompt requesting all three operations.
- What you can do after
- Apply it via LangChain4j to expose Java methods that an LLM can select and invoke from natural-language prompts.
Read how Software Testing with Generative AI explains @Tool annotation →
What to know first
- language modelA language model is a computational model of linguistic sequences that estimates their probabilities or predicts tokens from context, enabling it to generate or evaluate language.
- promptA prompt is text or other input supplied to an AI model to provide instructions, context, or other information that guides its response or generated output.
Related concepts
- toolconfigures · A software tool is a capability or utility that enables a person or system to perform a defined task or operation.
- language modelconfigures · A language model is a computational model of linguistic sequences that estimates their probabilities or predicts tokens from context, enabling it to generate or evaluate language.
- tool useconfigures · Tool use is the capability of an AI system or agent to request external software operations through defined interfaces to obtain information or perform actions.
- parameter annotationused by · A LangChain4j annotation that supplies natural-language context for a tool method parameter so a language model can extract its value from a prompt.
Questions about @Tool annotation
What is @Tool annotation?
A tool annotation is metadata attached to a method or tool definition that marks it as invocable and describes its operation and characteristics to clients or AI systems.
Which Manning books explain @Tool annotation?
Spring AI in Action and Software Testing with Generative AI.
What should I know before learning @Tool annotation?
Manning books that teach @Tool annotation usually introduce language model and prompt first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

