Camel Quarkus

AI Tool

JVM since3.39.0 Native since3.39.0

Framework-agnostic consumer endpoint that registers a Camel route as an LLM tool in the shared AiToolRegistry.

What’s inside

Please refer to the above link for usage and configuration details.

Maven coordinates

Or add the coordinates to your existing project:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-ai-tool</artifactId>
</dependency>

Check the User guide for more information about writing Camel Quarkus applications.

Usage

The ai-tool component is a framework-agnostic consumer endpoint that registers Camel routes as LLM-callable tools in a shared AiToolRegistry. Framework-specific extensions (such as camel-quarkus-langchain4j-agent, camel-quarkus-openai, camel-quarkus-mcp-server) discover and invoke these tools at runtime.

Dependency

Routes using ai-tool: need camel-quarkus-ai-tool as a dependency. The bridge to Quarkus LangChain4j AI services is part of it, but it also needs camel-quarkus-langchain4j-agent (camel-langchain4j-agent) and Quarkus LangChain4j on the classpath.

Defining a tool

Use the ai-tool consumer endpoint to register a route as an AI tool. Tool parameters are declared via URI options.

public class MyRoutes extends RouteBuilder {
    @Override
    public void configure() {
        from("ai-tool:getWeather?tags=weather"
                + "&description=Get the current weather for a city"
                + "&parameter.city=string"
                + "&parameter.city.description=The city name"
                + "&parameter.city.required=true"
                + "&parameter.unit=string"
                + "&parameter.unit.enum=celsius,fahrenheit")
            .setBody(simple("Sunny in ${header.city}, temperature in ${header.unit}"));
    }
}

Arguments passed by the LLM are set as exchange headers (e.g. ${header.city}).

Schema, MCP hints and return direct

Instead of parameter.* options, argSchema takes a raw JSON Schema, inline or as a resource such as classpath:schemas/order.json. The two are mutually exclusive. The schema needs an object root with at least one property in properties. Only the top-level properties are set as headers. In native mode, a classpath: schema must be added to the native image, e.g. quarkus.native.resources.includes=schemas/order.json.

Further options (see the Camel ai-tool documentation for details):

  • title - display title for MCP tool listings.

  • readOnlyHint, destructiveHint, idempotentHint, openWorldHint - MCP hints. They are advisory, Camel does not enforce them, and an unset hint is not published.

  • returnDirect - AI producers that support it (such as openai) return the tool result to the caller without sending it back to the model. Also published as an MCP hint.

title and the MCP hints are not passed to Quarkus LangChain4j AI services: their tool specification has only the name, description and parameters (ToolSpecification.metadata() is empty).

from("ai-tool:createOrder?tags=orders&title=Create order&returnDirect=true"
        + "&argSchema=classpath:schemas/create-order.json")
    .to("direct:createOrder");

Tag-based grouping

Tools can be grouped by tags. AI producer endpoints use tags to discover a subset of available tools.

A tool with no tags is placed in a default pool and is available to all tag queries.

// Tagged tool — only visible to producers querying the "support" tag
from("ai-tool:lookupOrder?tags=support&description=Look up order status"
        + "&parameter.orderId=string&parameter.orderId.required=true")
    .to("sql:SELECT status FROM orders WHERE id = :#${header.orderId}");

// Untagged tool — added to every tag query; never exposed by the MCP server
from("ai-tool:greet?description=Greet a user"
        + "&parameter.name=string&parameter.name.required=true")
    .setBody(simple("Hello, ${header.name}!"));

Who receives registered tools

Camel agents (langchain4j-agent endpoints) receive registry tools only through their endpoint’s tags parameter — an agent without tags receives no registry tools (tools from the agent’s other sources, such as MCP clients or custom tool objects, are unaffected). Quarkus LangChain4j AI services (@RegisterAiService interfaces) receive every registered tool by default; restrict a service to a subset with the org.apache.camel.quarkus.component.ai.tool.CamelAiTools annotation.

@CamelAiTools rules:

  • It takes a single tag. A comma-separated list is not split.

  • A blank tag fails the build (when Quarkus LangChain4j and camel-langchain4j-agent are present).

  • It only applies to @RegisterAiService interfaces. On any other class (such as a CDI bean calling the service) it has no effect and the build logs a warning.

  • It has no effect on Camel agents (langchain4j-agent endpoints), which receive no tools from this bridge.

@RegisterAiService
@CamelAiTools("support")
public interface SupportAgent {
    String chat(@UserMessage String message);
}

The tool provider backing this is registered automatically when Quarkus LangChain4j and camel-langchain4j-agent are on the classpath.