jamesnetherton commented on code in PR #646:
URL:
https://github.com/apache/camel-quarkus-examples/pull/646#discussion_r4797083351
##########
ai-tool-support-desk/README.adoc:
##########
@@ -0,0 +1,253 @@
+= AI Tool Support Desk with LangChain4j and MCP: A Camel Quarkus example
+:cq-example-description: An example that shows how to serve Camel routes as AI
tools to a LangChain4j agent and, over MCP, to the AI assistant of the support
staff
+
+{cq-description}
+
+TIP: Check the
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus
User guide] for prerequisites
+and other general information.
+
+== What the example does
+
+The support desk of an online shop. Customers chat with an AI assistant about
their orders, and the support staff
+use an AI assistant of their own, for example Claude Code, over the Model
Context Protocol (MCP). Both assistants call
Review Comment:
To stay vendor neutral, suggest: "…use an AI assistant of their own (any MCP
client that supports the Streamable HTTP transport, such as Claude Code, Codex,
GitHub Copilot in VS Code, Cursor or Gemini CLI)…"
##########
ai-tool-support-desk/README.adoc:
##########
@@ -0,0 +1,253 @@
+= AI Tool Support Desk with LangChain4j and MCP: A Camel Quarkus example
+:cq-example-description: An example that shows how to serve Camel routes as AI
tools to a LangChain4j agent and, over MCP, to the AI assistant of the support
staff
+
+{cq-description}
+
+TIP: Check the
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus
User guide] for prerequisites
+and other general information.
+
+== What the example does
+
+The support desk of an online shop. Customers chat with an AI assistant about
their orders, and the support staff
+use an AI assistant of their own, for example Claude Code, over the Model
Context Protocol (MCP). Both assistants call
+Camel routes as tools: the `ai-tool` component (`camel-quarkus-ai-tool`) turns
a route into a tool, and the tags of
+the tool routes in `ToolRoutes` tell the two audiences apart. Every tool must
have a tag, because an untagged tool is
+offered to every agent, whatever tags the agent asks for.
+
+image::architecture.svg["Components: the customers chat with a
langchain4j-agent that calls the ai-tool routes tagged customer, the AI
assistant of the support staff calls the ones tagged support over MCP, and all
tools work on PostgreSQL"]
+
+[cols="2,4,7",options="header"]
+|===
+|Component |Class / route id |Purpose
+|Customer API |`ChatResource`, route `customer-returns` |`POST /support/chat`,
`GET /support/returns`. Sets `customerId` and `customerVerified` from the
logged-in user.
+|Chat |route `chat` |Throttle, prompt `prompts/support-agent.txt`, memory per
customer, `langchain4j-agent` with `tags=customer`.
+|Agent setup |`SupportAgentConfiguration` |Chat model (`support-desk.llm.*`),
last 20 messages per customer, generic text for failing or unknown tools.
+|Customer tools |`ToolRoutes`: `get_order`, `track_shipment`,
`request_return`, `escalate_to_human` |Only for the logged-in customer: the SQL
uses `customerId`, never an argument.
+|Support tools |`ToolRoutes`: `list_pending_returns`, `decide_return`
|Published at `/mcp` (`quarkus.camel.mcp-server.tags=support`), role `support`
only.
+|Authorization |`VerifiedCustomerPolicy` (bean `verifiedCustomers`) |Lets only
verified customers call `request_return` and `escalate_to_human`. A denied call
never runs the route.
+|Admin API |`AdminResource` |Kill switch `POST /admin/tools/{tool}/disable`
and `/enable` (JSON content type only, against CSRF). Role `support`.
+|HTTP security |`application.properties` |Deny all paths, except `/support/*`
(role `customer`), `/admin/*` and `/mcp` (role `support`).
+|Database |`db/schema.sql`, `sql/*.sql` |The tables, and the SQL of the tools
(short statements are inline in the routes).
+|Dev stand-ins |route `fake-carrier` (`StandInRoutes`), Dev Services, `%dev`
users |The carrier, PostgreSQL with `db/demo-data.sql`, users `alice`, `bob`,
`dave` and `carol`.
+|===
+
+* Customers chat at `POST /support/chat`. The `chat` route calls the
`langchain4j-agent` component
+ (`camel-quarkus-langchain4j-agent`) with `tags=customer`, so the model gets
the customer tools:
+** `get_order` reads an order of the customer with its items from PostgreSQL.
+** `track_shipment` asks the carrier API about an order on its way, in a
circuit breaker.
+** `request_return`, for verified customers, returns items of an order
delivered at most 30 days ago, one return per
+ order. A return of up to 50 EUR is approved right away, a larger one waits
for the support staff. The items are
+ nested arguments, described by the JSON schema in
`schemas/request-return.json`.
+** `escalate_to_human`, for verified customers, stores a ticket in the
`tickets` table, where it stays `OPEN`.
+ Handing it over to a ticketing system is out of scope.
+* The `camel-quarkus-mcp-server` extension publishes the tools tagged
`support` at `/mcp`:
+** `list_pending_returns` lists the returns that wait for approval, with their
order, items and customer.
+** `decide_return` approves or rejects a pending return. Deciding again
changes nothing.
+
+image::return-flow.svg["Return flow: the model calls request_return,
VerifiedCustomerPolicy lets only verified customers through, the route checks
the return rules and approves a return of up to 50 EUR right away, a larger one
waits until the support staff call decide_return over MCP"]
+
+Paying the refund is out of scope: a real system would hand the approved
return over to a payment system, for example
+via Kafka.
+
+The endpoint options of a tool route describe the tool to the model
(`description`, `parameter.*` or `argSchema`, and
+MCP hints such as `readOnlyHint`), and its steps hold the business rules. The
model only chooses a tool and its
+arguments. In particular, it cannot:
+
+* Choose the customer. `ChatResource` hands the authenticated user to the
routes in the `customerId` exchange property,
+ and the SQL statements filter by it.
+* Act for a customer who may not. `VerifiedCustomerPolicy`, the
`authorizationPolicy` of the write tools, only lets
+ verified customers call them. It decides on the exchange properties set from
the authenticated user, never on the
+ arguments, and a denied call never runs the route: the model only learns
that it is not authorized.
+* Run away. A customer has one message in progress at most (another one gets
HTTP 429), and the model gets at most 5
+ rounds of tool calls per message (`maxToolCallingRoundTrips`). Then the
customer gets HTTP 502, although the tool
+ calls made so far stay done. A failing tool only tells the model `Tool
execution failed`, and a tool it does not
+ have tells it that the tool is not available.
+* Feed the assistant of the support staff with text written by customers,
which could carry instructions to it. The
Review Comment:
This claim is too strong: `list_pending_returns` returns `customerId`, which
is the login name. In a real shop where customers choose their usernames,
that's customer-controlled text going into the support assistant's context.
Either drop `customerId` from the tool output
(`sql/list-pending-returns.sql:23`) or soften the wording here.
##########
ai-tool-support-desk/src/main/resources/application.properties:
##########
@@ -0,0 +1,80 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+quarkus.banner.enabled=false
+
+# The chat model of the customer support agent: granite4.1:3b served by Ollama
on your machine, through the OpenAI
+# compatible API of Ollama. To use another OpenAI compatible API, set the
SUPPORT_DESK_LLM_BASE_URL,
+# SUPPORT_DESK_LLM_MODEL and SUPPORT_DESK_LLM_API_KEY environment variables.
+support-desk.llm.base-url=http://localhost:11434/v1
+support-desk.llm.model=granite4.1:3b
+# Ollama ignores the API key, but the OpenAI client needs one
+support-desk.llm.api-key=ollama
+# A small model on a laptop CPU may need a few minutes to answer
+support-desk.llm.timeout=3m
+
+# PostgreSQL holds the orders, returns and tickets. In dev and test mode, Dev
Services start it, create
+# the tables with db/schema.sql and load the demo data of db/demo-data.sql.
Otherwise set QUARKUS_DATASOURCE_JDBC_URL,
+# QUARKUS_DATASOURCE_USERNAME and QUARKUS_DATASOURCE_PASSWORD, and create the
tables with db/schema.sql.
+quarkus.datasource.db-kind=postgresql
+quarkus.datasource.devservices.init-script-path=db/schema.sql,db/demo-data.sql
+
+# The carrier API. In dev mode, the stand-in of StandInRoutes serves it, so
that the example runs without an account.
+# Otherwise set SUPPORT_DESK_CARRIER_URL.
+%dev.support-desk.carrier.url=http://localhost:${quarkus.http.port}/fake/carrier
+# The circuit breaker of track_shipment handles a failing carrier call, the
HTTP client does not retry it
+camel.component.http.automatic-retries-disabled=true
+
+# The MCP server for the support staff publishes the ai-tool routes tagged
"support" at /mcp
+quarkus.camel.mcp-server.tags=support
+quarkus.mcp.server.server-info.name=support-desk
+# The MCP server wants the CORS filter, for MCP clients running in a browser:
allow their origins with
+# quarkus.http.cors.origins
+quarkus.http.cors.enabled=true
+
+# HTTP basic authentication. Every path is denied unless a permission below
allows it: the chat is for customers, the
+# kill switch and the MCP server for the support staff.
+quarkus.http.auth.basic=true
+quarkus.security.users.embedded.enabled=true
Review Comment:
`quarkus.security.users.embedded.enabled=true` has no profile prefix, so the
properties-file realm is active in prod mode too. Right now that's safe,
because there are no users and everything returns 401. But the README then
tells people to configure users here, and Quarkus doesn't recommend this realm
for production (plain-text or MD5 passwords). Suggest:
```properties
%dev,test.quarkus.security.users.embedded.enabled=true
```
and pointing production to OIDC.
##########
ai-tool-support-desk/src/main/java/org/acme/ai/tool/support/desk/ToolRoutes.java:
##########
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.acme.ai.tool.support.desk;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * The AI tools of the support desk. Each route is one tool: the route id is
the tool name, the ai-tool endpoint
+ * describes the tool to the model and the steps hold the business rules.
+ * <p>
+ * The tools tagged {@code customer} are given to the customer chat agent (see
{@link SupportDeskRoutes}), the tools
+ * tagged {@code support} are published to the support staff by the MCP server
({@code quarkus.camel.mcp-server.tags} in
+ * {@code application.properties}).
+ * <p>
+ * The customer tools only ever act on the orders of the logged-in customer:
{@link ChatResource} puts the authenticated
+ * user into the {@code customerId} exchange property and the SQL statements
filter by it. The model cannot choose the
+ * customer. The customer tools that change something are guarded by the
{@code verifiedCustomers} authorization policy
+ * ({@link VerifiedCustomerPolicy}): only verified customers may call them.
+ */
+@ApplicationScoped
+public class ToolRoutes extends RouteBuilder {
+
+ @Override
+ public void configure() {
+ from("ai-tool:get_order?tags=customer"
+ + "&description=Get an order of the customer with its status,
delivery date and items"
+ + "¶meter.orderId=integer"
+ + "¶meter.orderId.description=The order number"
+ + "¶meter.orderId.required=true"
+ + "&readOnlyHint=true")
+ .routeId("get_order")
+ .to("sql:classpath:sql/get-order.sql?outputType=SelectOne")
+ .choice()
+ .when(simple("${body} == null"))
+ .setBody(simple("Order ${header.orderId} not found"))
+ .end();
+
+ from("ai-tool:track_shipment?tags=customer"
+ + "&description=Track the shipment of an order of the customer
with the carrier"
+ + "¶meter.orderId=integer"
+ + "¶meter.orderId.description=The order number"
+ + "¶meter.orderId.required=true"
+ + "&readOnlyHint=true"
+ + "&openWorldHint=true")
+ .routeId("track_shipment")
+ // Only shipments on their way are tracked, get_order tells
about the other orders
+ .to("sql:SELECT tracking_number FROM orders WHERE id =
CAST(:#orderId AS INTEGER)"
+ + " AND customer_id = :#${exchangeProperty.customerId}
AND status = 'SHIPPED'"
+ + "?outputType=SelectOne")
+ .choice()
+ .when(simple("${body} == null"))
+ .setBody(simple("Order ${header.orderId} is not on its way,
get_order tells its status"))
+ .stop()
+ .end()
+ .setProperty("trackingNumber", simple("${body}"))
+ // Only the tracking number leaves the application, none of
the headers of the tool call
+ .removeHeaders("*")
+ // A slow or failing carrier API must not break the
conversation
+ .circuitBreaker()
+
.faultToleranceConfiguration().timeoutEnabled(true).timeoutDuration(5000).end()
+
.toD("{{support-desk.carrier.url}}/shipments/${exchangeProperty.trackingNumber}?httpMethod=GET")
+ .convertBodyTo(String.class)
Review Comment:
Minor: the carrier's response goes to the customer model as-is. That's
third-party text in the prompt. It's fine for the example, but worth adding to
the list of what the model can and cannot do in the README.
##########
ai-tool-support-desk/README.adoc:
##########
@@ -0,0 +1,253 @@
+= AI Tool Support Desk with LangChain4j and MCP: A Camel Quarkus example
+:cq-example-description: An example that shows how to serve Camel routes as AI
tools to a LangChain4j agent and, over MCP, to the AI assistant of the support
staff
+
+{cq-description}
+
+TIP: Check the
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus
User guide] for prerequisites
+and other general information.
+
+== What the example does
+
+The support desk of an online shop. Customers chat with an AI assistant about
their orders, and the support staff
+use an AI assistant of their own, for example Claude Code, over the Model
Context Protocol (MCP). Both assistants call
+Camel routes as tools: the `ai-tool` component (`camel-quarkus-ai-tool`) turns
a route into a tool, and the tags of
+the tool routes in `ToolRoutes` tell the two audiences apart. Every tool must
have a tag, because an untagged tool is
+offered to every agent, whatever tags the agent asks for.
+
+image::architecture.svg["Components: the customers chat with a
langchain4j-agent that calls the ai-tool routes tagged customer, the AI
assistant of the support staff calls the ones tagged support over MCP, and all
tools work on PostgreSQL"]
+
+[cols="2,4,7",options="header"]
+|===
+|Component |Class / route id |Purpose
+|Customer API |`ChatResource`, route `customer-returns` |`POST /support/chat`,
`GET /support/returns`. Sets `customerId` and `customerVerified` from the
logged-in user.
+|Chat |route `chat` |Throttle, prompt `prompts/support-agent.txt`, memory per
customer, `langchain4j-agent` with `tags=customer`.
+|Agent setup |`SupportAgentConfiguration` |Chat model (`support-desk.llm.*`),
last 20 messages per customer, generic text for failing or unknown tools.
+|Customer tools |`ToolRoutes`: `get_order`, `track_shipment`,
`request_return`, `escalate_to_human` |Only for the logged-in customer: the SQL
uses `customerId`, never an argument.
+|Support tools |`ToolRoutes`: `list_pending_returns`, `decide_return`
|Published at `/mcp` (`quarkus.camel.mcp-server.tags=support`), role `support`
only.
+|Authorization |`VerifiedCustomerPolicy` (bean `verifiedCustomers`) |Lets only
verified customers call `request_return` and `escalate_to_human`. A denied call
never runs the route.
+|Admin API |`AdminResource` |Kill switch `POST /admin/tools/{tool}/disable`
and `/enable` (JSON content type only, against CSRF). Role `support`.
+|HTTP security |`application.properties` |Deny all paths, except `/support/*`
(role `customer`), `/admin/*` and `/mcp` (role `support`).
+|Database |`db/schema.sql`, `sql/*.sql` |The tables, and the SQL of the tools
(short statements are inline in the routes).
+|Dev stand-ins |route `fake-carrier` (`StandInRoutes`), Dev Services, `%dev`
users |The carrier, PostgreSQL with `db/demo-data.sql`, users `alice`, `bob`,
`dave` and `carol`.
+|===
+
+* Customers chat at `POST /support/chat`. The `chat` route calls the
`langchain4j-agent` component
+ (`camel-quarkus-langchain4j-agent`) with `tags=customer`, so the model gets
the customer tools:
+** `get_order` reads an order of the customer with its items from PostgreSQL.
+** `track_shipment` asks the carrier API about an order on its way, in a
circuit breaker.
+** `request_return`, for verified customers, returns items of an order
delivered at most 30 days ago, one return per
+ order. A return of up to 50 EUR is approved right away, a larger one waits
for the support staff. The items are
+ nested arguments, described by the JSON schema in
`schemas/request-return.json`.
+** `escalate_to_human`, for verified customers, stores a ticket in the
`tickets` table, where it stays `OPEN`.
+ Handing it over to a ticketing system is out of scope.
+* The `camel-quarkus-mcp-server` extension publishes the tools tagged
`support` at `/mcp`:
+** `list_pending_returns` lists the returns that wait for approval, with their
order, items and customer.
+** `decide_return` approves or rejects a pending return. Deciding again
changes nothing.
+
+image::return-flow.svg["Return flow: the model calls request_return,
VerifiedCustomerPolicy lets only verified customers through, the route checks
the return rules and approves a return of up to 50 EUR right away, a larger one
waits until the support staff call decide_return over MCP"]
+
+Paying the refund is out of scope: a real system would hand the approved
return over to a payment system, for example
+via Kafka.
+
+The endpoint options of a tool route describe the tool to the model
(`description`, `parameter.*` or `argSchema`, and
+MCP hints such as `readOnlyHint`), and its steps hold the business rules. The
model only chooses a tool and its
+arguments. In particular, it cannot:
+
+* Choose the customer. `ChatResource` hands the authenticated user to the
routes in the `customerId` exchange property,
+ and the SQL statements filter by it.
+* Act for a customer who may not. `VerifiedCustomerPolicy`, the
`authorizationPolicy` of the write tools, only lets
+ verified customers call them. It decides on the exchange properties set from
the authenticated user, never on the
+ arguments, and a denied call never runs the route: the model only learns
that it is not authorized.
+* Run away. A customer has one message in progress at most (another one gets
HTTP 429), and the model gets at most 5
+ rounds of tool calls per message (`maxToolCallingRoundTrips`). Then the
customer gets HTTP 502, although the tool
+ calls made so far stay done. A failing tool only tells the model `Tool
execution failed`, and a tool it does not
+ have tells it that the tool is not available.
+* Feed the assistant of the support staff with text written by customers,
which could carry instructions to it. The
+ reason of a return is a code, and the items are named after the catalog.
+
+Each tool has a kill switch: `POST /admin/tools/{tool}/disable` stops the
route of
Review Comment:
Worth noting that the kill switch is in memory and only affects the node
it's called on: it doesn't survive a restart and doesn't apply across replicas.
##########
ai-tool-support-desk/README.adoc:
##########
@@ -0,0 +1,253 @@
+= AI Tool Support Desk with LangChain4j and MCP: A Camel Quarkus example
+:cq-example-description: An example that shows how to serve Camel routes as AI
tools to a LangChain4j agent and, over MCP, to the AI assistant of the support
staff
+
+{cq-description}
+
+TIP: Check the
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus
User guide] for prerequisites
+and other general information.
+
+== What the example does
+
+The support desk of an online shop. Customers chat with an AI assistant about
their orders, and the support staff
+use an AI assistant of their own, for example Claude Code, over the Model
Context Protocol (MCP). Both assistants call
+Camel routes as tools: the `ai-tool` component (`camel-quarkus-ai-tool`) turns
a route into a tool, and the tags of
+the tool routes in `ToolRoutes` tell the two audiences apart. Every tool must
have a tag, because an untagged tool is
+offered to every agent, whatever tags the agent asks for.
+
+image::architecture.svg["Components: the customers chat with a
langchain4j-agent that calls the ai-tool routes tagged customer, the AI
assistant of the support staff calls the ones tagged support over MCP, and all
tools work on PostgreSQL"]
+
+[cols="2,4,7",options="header"]
+|===
+|Component |Class / route id |Purpose
+|Customer API |`ChatResource`, route `customer-returns` |`POST /support/chat`,
`GET /support/returns`. Sets `customerId` and `customerVerified` from the
logged-in user.
+|Chat |route `chat` |Throttle, prompt `prompts/support-agent.txt`, memory per
customer, `langchain4j-agent` with `tags=customer`.
+|Agent setup |`SupportAgentConfiguration` |Chat model (`support-desk.llm.*`),
last 20 messages per customer, generic text for failing or unknown tools.
+|Customer tools |`ToolRoutes`: `get_order`, `track_shipment`,
`request_return`, `escalate_to_human` |Only for the logged-in customer: the SQL
uses `customerId`, never an argument.
+|Support tools |`ToolRoutes`: `list_pending_returns`, `decide_return`
|Published at `/mcp` (`quarkus.camel.mcp-server.tags=support`), role `support`
only.
+|Authorization |`VerifiedCustomerPolicy` (bean `verifiedCustomers`) |Lets only
verified customers call `request_return` and `escalate_to_human`. A denied call
never runs the route.
+|Admin API |`AdminResource` |Kill switch `POST /admin/tools/{tool}/disable`
and `/enable` (JSON content type only, against CSRF). Role `support`.
+|HTTP security |`application.properties` |Deny all paths, except `/support/*`
(role `customer`), `/admin/*` and `/mcp` (role `support`).
+|Database |`db/schema.sql`, `sql/*.sql` |The tables, and the SQL of the tools
(short statements are inline in the routes).
+|Dev stand-ins |route `fake-carrier` (`StandInRoutes`), Dev Services, `%dev`
users |The carrier, PostgreSQL with `db/demo-data.sql`, users `alice`, `bob`,
`dave` and `carol`.
+|===
+
+* Customers chat at `POST /support/chat`. The `chat` route calls the
`langchain4j-agent` component
+ (`camel-quarkus-langchain4j-agent`) with `tags=customer`, so the model gets
the customer tools:
+** `get_order` reads an order of the customer with its items from PostgreSQL.
+** `track_shipment` asks the carrier API about an order on its way, in a
circuit breaker.
+** `request_return`, for verified customers, returns items of an order
delivered at most 30 days ago, one return per
+ order. A return of up to 50 EUR is approved right away, a larger one waits
for the support staff. The items are
+ nested arguments, described by the JSON schema in
`schemas/request-return.json`.
+** `escalate_to_human`, for verified customers, stores a ticket in the
`tickets` table, where it stays `OPEN`.
+ Handing it over to a ticketing system is out of scope.
+* The `camel-quarkus-mcp-server` extension publishes the tools tagged
`support` at `/mcp`:
+** `list_pending_returns` lists the returns that wait for approval, with their
order, items and customer.
+** `decide_return` approves or rejects a pending return. Deciding again
changes nothing.
+
+image::return-flow.svg["Return flow: the model calls request_return,
VerifiedCustomerPolicy lets only verified customers through, the route checks
the return rules and approves a return of up to 50 EUR right away, a larger one
waits until the support staff call decide_return over MCP"]
+
+Paying the refund is out of scope: a real system would hand the approved
return over to a payment system, for example
+via Kafka.
+
+The endpoint options of a tool route describe the tool to the model
(`description`, `parameter.*` or `argSchema`, and
+MCP hints such as `readOnlyHint`), and its steps hold the business rules. The
model only chooses a tool and its
+arguments. In particular, it cannot:
+
+* Choose the customer. `ChatResource` hands the authenticated user to the
routes in the `customerId` exchange property,
+ and the SQL statements filter by it.
+* Act for a customer who may not. `VerifiedCustomerPolicy`, the
`authorizationPolicy` of the write tools, only lets
+ verified customers call them. It decides on the exchange properties set from
the authenticated user, never on the
+ arguments, and a denied call never runs the route: the model only learns
that it is not authorized.
+* Run away. A customer has one message in progress at most (another one gets
HTTP 429), and the model gets at most 5
+ rounds of tool calls per message (`maxToolCallingRoundTrips`). Then the
customer gets HTTP 502, although the tool
+ calls made so far stay done. A failing tool only tells the model `Tool
execution failed`, and a tool it does not
+ have tells it that the tool is not available.
+* Feed the assistant of the support staff with text written by customers,
which could carry instructions to it. The
+ reason of a return is a code, and the items are named after the catalog.
+
+Each tool has a kill switch: `POST /admin/tools/{tool}/disable` stops the
route of
+the tool, which removes it from the chat agent and from the MCP server, until
`POST /admin/tools/{tool}/enable`.
+
+== Prerequisites
Review Comment:
For readers new to the topic, a short quick start before the architecture
table would help: start Ollama, run `mvn quarkus:dev`, send one curl. Also,
Ollama in Docker on macOS has no GPU, so a native Ollama install is much faster
with this model.
##########
ai-tool-support-desk/README.adoc:
##########
@@ -0,0 +1,253 @@
+= AI Tool Support Desk with LangChain4j and MCP: A Camel Quarkus example
+:cq-example-description: An example that shows how to serve Camel routes as AI
tools to a LangChain4j agent and, over MCP, to the AI assistant of the support
staff
+
+{cq-description}
+
+TIP: Check the
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus
User guide] for prerequisites
+and other general information.
+
+== What the example does
+
+The support desk of an online shop. Customers chat with an AI assistant about
their orders, and the support staff
+use an AI assistant of their own, for example Claude Code, over the Model
Context Protocol (MCP). Both assistants call
+Camel routes as tools: the `ai-tool` component (`camel-quarkus-ai-tool`) turns
a route into a tool, and the tags of
+the tool routes in `ToolRoutes` tell the two audiences apart. Every tool must
have a tag, because an untagged tool is
+offered to every agent, whatever tags the agent asks for.
+
+image::architecture.svg["Components: the customers chat with a
langchain4j-agent that calls the ai-tool routes tagged customer, the AI
assistant of the support staff calls the ones tagged support over MCP, and all
tools work on PostgreSQL"]
+
+[cols="2,4,7",options="header"]
+|===
+|Component |Class / route id |Purpose
+|Customer API |`ChatResource`, route `customer-returns` |`POST /support/chat`,
`GET /support/returns`. Sets `customerId` and `customerVerified` from the
logged-in user.
+|Chat |route `chat` |Throttle, prompt `prompts/support-agent.txt`, memory per
customer, `langchain4j-agent` with `tags=customer`.
+|Agent setup |`SupportAgentConfiguration` |Chat model (`support-desk.llm.*`),
last 20 messages per customer, generic text for failing or unknown tools.
+|Customer tools |`ToolRoutes`: `get_order`, `track_shipment`,
`request_return`, `escalate_to_human` |Only for the logged-in customer: the SQL
uses `customerId`, never an argument.
+|Support tools |`ToolRoutes`: `list_pending_returns`, `decide_return`
|Published at `/mcp` (`quarkus.camel.mcp-server.tags=support`), role `support`
only.
+|Authorization |`VerifiedCustomerPolicy` (bean `verifiedCustomers`) |Lets only
verified customers call `request_return` and `escalate_to_human`. A denied call
never runs the route.
+|Admin API |`AdminResource` |Kill switch `POST /admin/tools/{tool}/disable`
and `/enable` (JSON content type only, against CSRF). Role `support`.
+|HTTP security |`application.properties` |Deny all paths, except `/support/*`
(role `customer`), `/admin/*` and `/mcp` (role `support`).
+|Database |`db/schema.sql`, `sql/*.sql` |The tables, and the SQL of the tools
(short statements are inline in the routes).
+|Dev stand-ins |route `fake-carrier` (`StandInRoutes`), Dev Services, `%dev`
users |The carrier, PostgreSQL with `db/demo-data.sql`, users `alice`, `bob`,
`dave` and `carol`.
+|===
+
+* Customers chat at `POST /support/chat`. The `chat` route calls the
`langchain4j-agent` component
+ (`camel-quarkus-langchain4j-agent`) with `tags=customer`, so the model gets
the customer tools:
+** `get_order` reads an order of the customer with its items from PostgreSQL.
+** `track_shipment` asks the carrier API about an order on its way, in a
circuit breaker.
+** `request_return`, for verified customers, returns items of an order
delivered at most 30 days ago, one return per
+ order. A return of up to 50 EUR is approved right away, a larger one waits
for the support staff. The items are
+ nested arguments, described by the JSON schema in
`schemas/request-return.json`.
+** `escalate_to_human`, for verified customers, stores a ticket in the
`tickets` table, where it stays `OPEN`.
+ Handing it over to a ticketing system is out of scope.
+* The `camel-quarkus-mcp-server` extension publishes the tools tagged
`support` at `/mcp`:
+** `list_pending_returns` lists the returns that wait for approval, with their
order, items and customer.
+** `decide_return` approves or rejects a pending return. Deciding again
changes nothing.
+
+image::return-flow.svg["Return flow: the model calls request_return,
VerifiedCustomerPolicy lets only verified customers through, the route checks
the return rules and approves a return of up to 50 EUR right away, a larger one
waits until the support staff call decide_return over MCP"]
+
+Paying the refund is out of scope: a real system would hand the approved
return over to a payment system, for example
+via Kafka.
+
+The endpoint options of a tool route describe the tool to the model
(`description`, `parameter.*` or `argSchema`, and
+MCP hints such as `readOnlyHint`), and its steps hold the business rules. The
model only chooses a tool and its
+arguments. In particular, it cannot:
+
+* Choose the customer. `ChatResource` hands the authenticated user to the
routes in the `customerId` exchange property,
+ and the SQL statements filter by it.
+* Act for a customer who may not. `VerifiedCustomerPolicy`, the
`authorizationPolicy` of the write tools, only lets
+ verified customers call them. It decides on the exchange properties set from
the authenticated user, never on the
+ arguments, and a denied call never runs the route: the model only learns
that it is not authorized.
+* Run away. A customer has one message in progress at most (another one gets
HTTP 429), and the model gets at most 5
+ rounds of tool calls per message (`maxToolCallingRoundTrips`). Then the
customer gets HTTP 502, although the tool
+ calls made so far stay done. A failing tool only tells the model `Tool
execution failed`, and a tool it does not
+ have tells it that the tool is not available.
+* Feed the assistant of the support staff with text written by customers,
which could carry instructions to it. The
+ reason of a return is a code, and the items are named after the catalog.
+
+Each tool has a kill switch: `POST /admin/tools/{tool}/disable` stops the
route of
+the tool, which removes it from the chat agent and from the MCP server, until
`POST /admin/tools/{tool}/enable`.
+
+== Prerequisites
+
+The chat needs a model that can call tools. By default, the example uses
+https://ollama.com/library/granite4.1:3b[granite4.1:3b] served by
https://ollama.com/[Ollama] on your machine:
+
+[source,shell]
+----
+docker run --rm -d -v cqex-ai-tool-support-desk-ollama:/root/.ollama -p
11434:11434 --name cqex-ai-tool-support-desk-ollama ollama/ollama:0.24.0
+docker exec cqex-ai-tool-support-desk-ollama ollama pull granite4.1:3b
+----
+
+To use another server with an OpenAI compatible API, set the
`SUPPORT_DESK_LLM_BASE_URL`, `SUPPORT_DESK_LLM_MODEL` and
+`SUPPORT_DESK_LLM_API_KEY` environment variables. Small models are more likely
to call a wrong tool.
+
+Dev mode and the tests also need Docker or Podman, for the PostgreSQL started
by Dev Services.
+
+== Start in Development mode
+
+[source,shell]
+----
+mvn clean compile quarkus:dev
+----
+
+The above command compiles the project, starts the application and lets the
Quarkus tooling watch for changes in your
+workspace. Any modifications in your project will automatically take effect in
the running application.
+
+TIP: Please refer to the Development mode section of
+https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel
Quarkus User guide] for more details.
+
+In dev mode, the users are demo users with HTTP basic authentication, whose
password is their user name: `alice` and
+`bob` are verified customers, `dave` is a customer who has not verified their
account, and `carol` is support staff.
+Dev Services load the demo data of `src/main/resources/db/demo-data.sql`, and
`StandInRoutes` stands in for the
+carrier.
+
+=== Chat with the support desk
+
+[source,shell]
+----
+curl -s -u alice:alice -X POST http://localhost:8080/support/chat \
+ -H 'Content-Type: application/json' \
+ -d '{"message": "Please return the two USB-C cables of order 1001, they are
too short."}'
+----
+
+[source,json]
+----
+{ "reply": "Your return of the two USB-C cables of order 1001 is approved, for
a refund of 25.00 EUR." }
+----
+
+The customer sees their returns with `GET /support/returns`:
+
+[source,shell]
+----
+curl -s -u alice:alice http://localhost:8080/support/returns
+----
+
+[source,json]
+----
+[ { "returnId": 3, "orderId": 1001, "amount": 25.00, "status": "APPROVED" } ]
+----
+
+Other things to ask `alice`'s assistant: to return the smart speaker of order
1002 (129 EUR, so it waits for approval)
+or the desk lamp of order 1004 (delivered 60 days ago, so it is refused),
where order 1003 is (tracked with the
+carrier), about order 2001 (`bob`'s, so it is not found), or for a human
(opens a ticket). As `dave`, the assistant can
+look up order 3001, but it cannot return it nor open a ticket.
+
+=== Use the support tools from an AI assistant
Review Comment:
Suggest replacing the `claude mcp add` command with generic connection
details, and keeping MCP Inspector as the hands-on walkthrough:
```
The support staff connect their AI assistant to the MCP server as `carol`.
Any MCP client that
supports the Streamable HTTP transport and custom headers works, such as
Claude Code, Codex,
GitHub Copilot in VS Code, Cursor or Gemini CLI. Configure it, as its
documentation describes, with:
* URL: `http://localhost:8080/mcp`
* Transport: Streamable HTTP
* Header: `Authorization: Basic Y2Fyb2w6Y2Fyb2w=` (`carol:carol`, dev mode
only)
```
##########
ai-tool-support-desk/README.adoc:
##########
@@ -0,0 +1,253 @@
+= AI Tool Support Desk with LangChain4j and MCP: A Camel Quarkus example
+:cq-example-description: An example that shows how to serve Camel routes as AI
tools to a LangChain4j agent and, over MCP, to the AI assistant of the support
staff
+
+{cq-description}
+
+TIP: Check the
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus
User guide] for prerequisites
+and other general information.
+
+== What the example does
+
+The support desk of an online shop. Customers chat with an AI assistant about
their orders, and the support staff
+use an AI assistant of their own, for example Claude Code, over the Model
Context Protocol (MCP). Both assistants call
+Camel routes as tools: the `ai-tool` component (`camel-quarkus-ai-tool`) turns
a route into a tool, and the tags of
+the tool routes in `ToolRoutes` tell the two audiences apart. Every tool must
have a tag, because an untagged tool is
+offered to every agent, whatever tags the agent asks for.
+
+image::architecture.svg["Components: the customers chat with a
langchain4j-agent that calls the ai-tool routes tagged customer, the AI
assistant of the support staff calls the ones tagged support over MCP, and all
tools work on PostgreSQL"]
+
+[cols="2,4,7",options="header"]
+|===
+|Component |Class / route id |Purpose
+|Customer API |`ChatResource`, route `customer-returns` |`POST /support/chat`,
`GET /support/returns`. Sets `customerId` and `customerVerified` from the
logged-in user.
+|Chat |route `chat` |Throttle, prompt `prompts/support-agent.txt`, memory per
customer, `langchain4j-agent` with `tags=customer`.
+|Agent setup |`SupportAgentConfiguration` |Chat model (`support-desk.llm.*`),
last 20 messages per customer, generic text for failing or unknown tools.
+|Customer tools |`ToolRoutes`: `get_order`, `track_shipment`,
`request_return`, `escalate_to_human` |Only for the logged-in customer: the SQL
uses `customerId`, never an argument.
+|Support tools |`ToolRoutes`: `list_pending_returns`, `decide_return`
|Published at `/mcp` (`quarkus.camel.mcp-server.tags=support`), role `support`
only.
+|Authorization |`VerifiedCustomerPolicy` (bean `verifiedCustomers`) |Lets only
verified customers call `request_return` and `escalate_to_human`. A denied call
never runs the route.
+|Admin API |`AdminResource` |Kill switch `POST /admin/tools/{tool}/disable`
and `/enable` (JSON content type only, against CSRF). Role `support`.
+|HTTP security |`application.properties` |Deny all paths, except `/support/*`
(role `customer`), `/admin/*` and `/mcp` (role `support`).
+|Database |`db/schema.sql`, `sql/*.sql` |The tables, and the SQL of the tools
(short statements are inline in the routes).
+|Dev stand-ins |route `fake-carrier` (`StandInRoutes`), Dev Services, `%dev`
users |The carrier, PostgreSQL with `db/demo-data.sql`, users `alice`, `bob`,
`dave` and `carol`.
+|===
+
+* Customers chat at `POST /support/chat`. The `chat` route calls the
`langchain4j-agent` component
+ (`camel-quarkus-langchain4j-agent`) with `tags=customer`, so the model gets
the customer tools:
+** `get_order` reads an order of the customer with its items from PostgreSQL.
+** `track_shipment` asks the carrier API about an order on its way, in a
circuit breaker.
+** `request_return`, for verified customers, returns items of an order
delivered at most 30 days ago, one return per
+ order. A return of up to 50 EUR is approved right away, a larger one waits
for the support staff. The items are
+ nested arguments, described by the JSON schema in
`schemas/request-return.json`.
+** `escalate_to_human`, for verified customers, stores a ticket in the
`tickets` table, where it stays `OPEN`.
+ Handing it over to a ticketing system is out of scope.
+* The `camel-quarkus-mcp-server` extension publishes the tools tagged
`support` at `/mcp`:
+** `list_pending_returns` lists the returns that wait for approval, with their
order, items and customer.
+** `decide_return` approves or rejects a pending return. Deciding again
changes nothing.
+
+image::return-flow.svg["Return flow: the model calls request_return,
VerifiedCustomerPolicy lets only verified customers through, the route checks
the return rules and approves a return of up to 50 EUR right away, a larger one
waits until the support staff call decide_return over MCP"]
+
+Paying the refund is out of scope: a real system would hand the approved
return over to a payment system, for example
+via Kafka.
+
+The endpoint options of a tool route describe the tool to the model
(`description`, `parameter.*` or `argSchema`, and
+MCP hints such as `readOnlyHint`), and its steps hold the business rules. The
model only chooses a tool and its
+arguments. In particular, it cannot:
+
+* Choose the customer. `ChatResource` hands the authenticated user to the
routes in the `customerId` exchange property,
+ and the SQL statements filter by it.
+* Act for a customer who may not. `VerifiedCustomerPolicy`, the
`authorizationPolicy` of the write tools, only lets
+ verified customers call them. It decides on the exchange properties set from
the authenticated user, never on the
+ arguments, and a denied call never runs the route: the model only learns
that it is not authorized.
+* Run away. A customer has one message in progress at most (another one gets
HTTP 429), and the model gets at most 5
+ rounds of tool calls per message (`maxToolCallingRoundTrips`). Then the
customer gets HTTP 502, although the tool
+ calls made so far stay done. A failing tool only tells the model `Tool
execution failed`, and a tool it does not
+ have tells it that the tool is not available.
+* Feed the assistant of the support staff with text written by customers,
which could carry instructions to it. The
+ reason of a return is a code, and the items are named after the catalog.
+
+Each tool has a kill switch: `POST /admin/tools/{tool}/disable` stops the
route of
+the tool, which removes it from the chat agent and from the MCP server, until
`POST /admin/tools/{tool}/enable`.
+
+== Prerequisites
+
+The chat needs a model that can call tools. By default, the example uses
+https://ollama.com/library/granite4.1:3b[granite4.1:3b] served by
https://ollama.com/[Ollama] on your machine:
+
+[source,shell]
+----
+docker run --rm -d -v cqex-ai-tool-support-desk-ollama:/root/.ollama -p
11434:11434 --name cqex-ai-tool-support-desk-ollama ollama/ollama:0.24.0
+docker exec cqex-ai-tool-support-desk-ollama ollama pull granite4.1:3b
+----
+
+To use another server with an OpenAI compatible API, set the
`SUPPORT_DESK_LLM_BASE_URL`, `SUPPORT_DESK_LLM_MODEL` and
+`SUPPORT_DESK_LLM_API_KEY` environment variables. Small models are more likely
to call a wrong tool.
+
+Dev mode and the tests also need Docker or Podman, for the PostgreSQL started
by Dev Services.
+
+== Start in Development mode
+
+[source,shell]
+----
+mvn clean compile quarkus:dev
+----
+
+The above command compiles the project, starts the application and lets the
Quarkus tooling watch for changes in your
+workspace. Any modifications in your project will automatically take effect in
the running application.
+
+TIP: Please refer to the Development mode section of
+https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel
Quarkus User guide] for more details.
+
+In dev mode, the users are demo users with HTTP basic authentication, whose
password is their user name: `alice` and
+`bob` are verified customers, `dave` is a customer who has not verified their
account, and `carol` is support staff.
+Dev Services load the demo data of `src/main/resources/db/demo-data.sql`, and
`StandInRoutes` stands in for the
+carrier.
+
+=== Chat with the support desk
+
+[source,shell]
+----
+curl -s -u alice:alice -X POST http://localhost:8080/support/chat \
+ -H 'Content-Type: application/json' \
+ -d '{"message": "Please return the two USB-C cables of order 1001, they are
too short."}'
+----
+
+[source,json]
+----
+{ "reply": "Your return of the two USB-C cables of order 1001 is approved, for
a refund of 25.00 EUR." }
+----
+
+The customer sees their returns with `GET /support/returns`:
+
+[source,shell]
+----
+curl -s -u alice:alice http://localhost:8080/support/returns
+----
+
+[source,json]
+----
+[ { "returnId": 3, "orderId": 1001, "amount": 25.00, "status": "APPROVED" } ]
+----
+
+Other things to ask `alice`'s assistant: to return the smart speaker of order
1002 (129 EUR, so it waits for approval)
+or the desk lamp of order 1004 (delivered 60 days ago, so it is refused),
where order 1003 is (tracked with the
+carrier), about order 2001 (`bob`'s, so it is not found), or for a human
(opens a ticket). As `dave`, the assistant can
+look up order 3001, but it cannot return it nor open a ticket.
+
+=== Use the support tools from an AI assistant
+
+The support staff connect their AI assistant to the MCP server at
`http://localhost:8080/mcp` as `carol`. With
+Claude Code:
+
+[source,shell]
+----
+claude mcp add --transport http support-desk http://localhost:8080/mcp \
+ --header "Authorization: Basic $(printf 'carol:carol' | base64)"
+----
+
+Then ask Claude Code, for example, "Which returns wait for approval? Approve
the one for the headphones." It calls
+`list_pending_returns`, then `decide_return`. The
https://github.com/modelcontextprotocol/inspector[MCP Inspector]
+(`npx @modelcontextprotocol/inspector`, transport `Streamable HTTP`, header
`Authorization: Basic Y2Fyb2w6Y2Fyb2w=`)
+shows the two support tools with their hints. Without credentials the MCP
server answers with HTTP 401, and customers
+get HTTP 403.
+
+=== Switch a tool off
+
+[source,shell]
+----
+curl -s -u carol:carol -X POST -H 'Content-Type: application/json'
http://localhost:8080/admin/tools/decide_return/disable
+curl -s -u carol:carol -X POST -H 'Content-Type: application/json'
http://localhost:8080/admin/tools/decide_return/enable
+----
+
+While `decide_return` is disabled, the MCP clients are notified that the tool
list changed and no longer see it.
+
+=== Package and run the application
+
+Once you are done with developing you may want to package and run the
application.
+
+TIP: Find more details about the JVM mode and Native mode in the Package and
run section of
+https://camel.apache.org/camel-quarkus/latest/first-steps.html#_package_and_run_the_application[Camel
Quarkus User guide]
+
+Outside of dev mode, there are no Dev Services, no demo data, no demo users
and no stand-in. Start PostgreSQL with the
+tables of `src/main/resources/db/schema.sql`, and point the application at it
and at the carrier API, which must answer
+`GET <url>/shipments/<trackingNumber>`:
+
+[source,shell]
+----
+docker run --rm -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres --name
cqex-ai-tool-support-desk-postgres \
+ -v
${PWD}/src/main/resources/db/schema.sql:/docker-entrypoint-initdb.d/schema.sql
docker.io/library/postgres:18
+export QUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://localhost:5432/postgres
+export QUARKUS_DATASOURCE_USERNAME=postgres
+export QUARKUS_DATASOURCE_PASSWORD=postgres
+export SUPPORT_DESK_CARRIER_URL=https://carrier.example.com
+----
+
+Configure the users, see the
https://quarkus.io/guides/security-properties[Quarkus guide], or better use an
identity
Review Comment:
Please make this stronger than "or better use OIDC". Something like: "The
properties-based users are for dev mode and tests only. In production, use an
identity provider such as OpenID Connect, see the `secure-partner-gateway`
example." It's also worth one sentence saying basic auth needs TLS outside
localhost.
##########
ai-tool-support-desk/README.adoc:
##########
@@ -0,0 +1,253 @@
+= AI Tool Support Desk with LangChain4j and MCP: A Camel Quarkus example
+:cq-example-description: An example that shows how to serve Camel routes as AI
tools to a LangChain4j agent and, over MCP, to the AI assistant of the support
staff
+
+{cq-description}
+
+TIP: Check the
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus
User guide] for prerequisites
+and other general information.
+
+== What the example does
+
+The support desk of an online shop. Customers chat with an AI assistant about
their orders, and the support staff
+use an AI assistant of their own, for example Claude Code, over the Model
Context Protocol (MCP). Both assistants call
+Camel routes as tools: the `ai-tool` component (`camel-quarkus-ai-tool`) turns
a route into a tool, and the tags of
+the tool routes in `ToolRoutes` tell the two audiences apart. Every tool must
have a tag, because an untagged tool is
+offered to every agent, whatever tags the agent asks for.
+
+image::architecture.svg["Components: the customers chat with a
langchain4j-agent that calls the ai-tool routes tagged customer, the AI
assistant of the support staff calls the ones tagged support over MCP, and all
tools work on PostgreSQL"]
+
+[cols="2,4,7",options="header"]
+|===
+|Component |Class / route id |Purpose
+|Customer API |`ChatResource`, route `customer-returns` |`POST /support/chat`,
`GET /support/returns`. Sets `customerId` and `customerVerified` from the
logged-in user.
+|Chat |route `chat` |Throttle, prompt `prompts/support-agent.txt`, memory per
customer, `langchain4j-agent` with `tags=customer`.
+|Agent setup |`SupportAgentConfiguration` |Chat model (`support-desk.llm.*`),
last 20 messages per customer, generic text for failing or unknown tools.
+|Customer tools |`ToolRoutes`: `get_order`, `track_shipment`,
`request_return`, `escalate_to_human` |Only for the logged-in customer: the SQL
uses `customerId`, never an argument.
+|Support tools |`ToolRoutes`: `list_pending_returns`, `decide_return`
|Published at `/mcp` (`quarkus.camel.mcp-server.tags=support`), role `support`
only.
+|Authorization |`VerifiedCustomerPolicy` (bean `verifiedCustomers`) |Lets only
verified customers call `request_return` and `escalate_to_human`. A denied call
never runs the route.
+|Admin API |`AdminResource` |Kill switch `POST /admin/tools/{tool}/disable`
and `/enable` (JSON content type only, against CSRF). Role `support`.
+|HTTP security |`application.properties` |Deny all paths, except `/support/*`
(role `customer`), `/admin/*` and `/mcp` (role `support`).
+|Database |`db/schema.sql`, `sql/*.sql` |The tables, and the SQL of the tools
(short statements are inline in the routes).
+|Dev stand-ins |route `fake-carrier` (`StandInRoutes`), Dev Services, `%dev`
users |The carrier, PostgreSQL with `db/demo-data.sql`, users `alice`, `bob`,
`dave` and `carol`.
+|===
+
+* Customers chat at `POST /support/chat`. The `chat` route calls the
`langchain4j-agent` component
+ (`camel-quarkus-langchain4j-agent`) with `tags=customer`, so the model gets
the customer tools:
+** `get_order` reads an order of the customer with its items from PostgreSQL.
+** `track_shipment` asks the carrier API about an order on its way, in a
circuit breaker.
+** `request_return`, for verified customers, returns items of an order
delivered at most 30 days ago, one return per
+ order. A return of up to 50 EUR is approved right away, a larger one waits
for the support staff. The items are
+ nested arguments, described by the JSON schema in
`schemas/request-return.json`.
+** `escalate_to_human`, for verified customers, stores a ticket in the
`tickets` table, where it stays `OPEN`.
+ Handing it over to a ticketing system is out of scope.
+* The `camel-quarkus-mcp-server` extension publishes the tools tagged
`support` at `/mcp`:
+** `list_pending_returns` lists the returns that wait for approval, with their
order, items and customer.
+** `decide_return` approves or rejects a pending return. Deciding again
changes nothing.
+
+image::return-flow.svg["Return flow: the model calls request_return,
VerifiedCustomerPolicy lets only verified customers through, the route checks
the return rules and approves a return of up to 50 EUR right away, a larger one
waits until the support staff call decide_return over MCP"]
+
+Paying the refund is out of scope: a real system would hand the approved
return over to a payment system, for example
+via Kafka.
+
+The endpoint options of a tool route describe the tool to the model
(`description`, `parameter.*` or `argSchema`, and
+MCP hints such as `readOnlyHint`), and its steps hold the business rules. The
model only chooses a tool and its
+arguments. In particular, it cannot:
+
+* Choose the customer. `ChatResource` hands the authenticated user to the
routes in the `customerId` exchange property,
+ and the SQL statements filter by it.
+* Act for a customer who may not. `VerifiedCustomerPolicy`, the
`authorizationPolicy` of the write tools, only lets
+ verified customers call them. It decides on the exchange properties set from
the authenticated user, never on the
+ arguments, and a denied call never runs the route: the model only learns
that it is not authorized.
+* Run away. A customer has one message in progress at most (another one gets
HTTP 429), and the model gets at most 5
+ rounds of tool calls per message (`maxToolCallingRoundTrips`). Then the
customer gets HTTP 502, although the tool
+ calls made so far stay done. A failing tool only tells the model `Tool
execution failed`, and a tool it does not
+ have tells it that the tool is not available.
+* Feed the assistant of the support staff with text written by customers,
which could carry instructions to it. The
+ reason of a return is a code, and the items are named after the catalog.
+
+Each tool has a kill switch: `POST /admin/tools/{tool}/disable` stops the
route of
+the tool, which removes it from the chat agent and from the MCP server, until
`POST /admin/tools/{tool}/enable`.
+
+== Prerequisites
Review Comment:
The example already works with any OpenAI-compatible server through the
`SUPPORT_DESK_LLM_*` variables, but that's one sentence and easy to miss. Could
you add a short "Using another LLM provider" subsection covering:
- an example of setting the three variables for a hosted provider
- that the model must support tool calling
- that providers without an OpenAI-compatible API need their LangChain4j
module and a change to the builder in `SupportAgentConfiguration`
- that with a hosted provider, order data and customer messages are sent to
that provider
No need to make the code itself provider-agnostic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]