Quarkus shows layered security for LangChain4j agents and MCP tools
A first-party engineering session combined guardrails, per-user authorization, token exchange and step-up MFA—and was explicit about the integration gaps that remain.
Quarkus developers have demonstrated a layered approach to securing AI agents built with Quarkus LangChain4j, combining model-facing guardrails with identity controls enforced at the MCP server and downstream API.
In a Quarkus Insights engineering session streamed Nov. 16, the team used a conference assistant spanning three Quarkus services: a chat application, an MCP server and a REST API protected by Keycloak. The example was deliberately more ambitious than prompt filtering alone. It treated the agent as an application acting for a real user, with permissions and audit records that should survive calls across the service chain.
Guardrails are one layer, not the boundary
The demo placed checks at three points: input guardrails before a request reached the model, tool guardrails before an action ran, and output guardrails before a response returned to the user. Examples included restricting an email tool to the signed-in user's address and blocking responses that exposed a canary string embedded in the system prompt.
The presenters also stressed the limitation: phrase matching and hardened prompts do not enforce authorization. A new attack can bypass known patterns, and a model may still attempt a privileged tool call. The reliable boundary remains the service receiving that call, where roles, resource ownership and authentication level can be checked independently of the model.
That distinction showed up in the live example. An attendee asked the agent to cancel a conference session; the model accepted the request, but the MCP-backed service rejected it because stronger authentication was required.
Preserve the user's identity across MCP
For remote MCP over streamable HTTP, the session recommended OAuth 2.1 with short-lived, per-user tokens rather than a shared API key. The MCP server exchanged the token it received for one addressed to the downstream API, allowing that API to authorize and audit the original user instead of seeing only an all-powerful service identity.
The same chain supported step-up authentication. When the agent requested attendee email data, the service returned an insufficient-authentication response and the application required MFA before retrying. Keycloak policy could define the stronger authentication level and its lifetime, while the application could impose a shorter maximum.
The rough edges matter
This was a pattern demonstration, not a claim that the stack is finished. The presenters said some delegation behavior still required Keycloak preview features, while preserving the initiating identity and authentication context across token exchange needed manually propagated trusted headers in the sample. Step-up handling also required application code because MCP clients do not consistently turn an insufficient-authentication response into an MFA flow.
Tool input and output guardrails are currently implemented in Quarkus LangChain4j, with work underway to move that capability upstream into LangChain4j and then consume the upstream implementation from Quarkus. The practical takeaway is therefore twofold: Java teams can assemble the security layers now, but they should treat identity propagation and step-up flows as integration work that still needs close testing—not as automatic properties of adding MCP to an agent.
sources
comments · 0