@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 →
Related concepts
- toolproduces · A tool is an instrument or software capability that enables a person or system to perform a task, obtain information, or interact with resources.
- language modelconfigures · A language model is a computational model that represents patterns in linguistic tokens to estimate sequence probabilities and predict or generate language from context.
- tool usageconfigures · Tool use is an AI system's invocation of external software functions, services, or other capabilities 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.
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.

