Every chapter, in order.
Read top to bottom the first time; each pattern chapter also stands on its own.
Part 0 Foundations
The two stacks, why an agent-facing API differs from a human-facing one, and how to read the catalog that follows.
- 0 Prerequisites and the two stacks The tools, exact pins and two local stacks every example in this catalog runs on: the application stack a request and a tool call travel through, and the observability stack that watches them.
- 1 Why agent-facing APIs are different Designing an API for an agent or a large language model is a systematically different engineering job from designing one for a human or a browser, measured on one real task against two contracts.
- 2 How to read this catalog The anatomy every pattern page shares, the forces every pattern trades against, the taxonomy that groups them, the field vocabulary they assume, and the principles and anti-patterns named once and invoked throughout.
Part 1 Build: synchronous APIs
Build the request/response surface: REST and GraphQL endpoints shaped so an agent can call them as MCP tools.
- 3 Intent Endpoint (over CRUD) One intent-named endpoint performs a whole business operation atomically, where a chatty sequence of CRUD calls leaves a window of partial state an agent can observe and act on incorrectly.
- 4 Search over Pagination A typed-filter search call returns exactly the matching orders directly, measured against a raw pagination sweep that must scan page after page to find the same records.
- 5 Batch Operation and Count Flag An id-keyed batch endpoint resolves many identifiers in one call with explicit misses, and a count endpoint answers how many with a bare number, each measured against the one-at-a-time and fetch-everything alternatives they replace.
- 6 Idempotency and Safe Retries A required Idempotency-Key header, enforced by a server-side Idempotent Consumer, replays the first response byte for byte on a repeat key and rejects the same key reused with a different body, where an unguarded retry places a second order.
- 7 Strict Self-Describing Contract (OpenAPI 3.1) A precise OpenAPI 3.1 document, generated from the code and kept in sync with it, is the contract an agent actually reads before calling a tool.
- 8 Semantic Metadata and llms.txt + Dual-Use Portal A machine-readable llms.txt and a shared portal serve a browsing human and a reading agent from the same source, instead of two surfaces drifting apart.
- 9 Token-Efficient Response / Agent BFF A backend-for-frontend layer shapes a response for the token budget an agent actually has, instead of returning a human-facing payload unchanged.
- 10 Instructive Error (RFC 9457) An RFC 9457 problem response names what was wrong and what to try next, instead of a bare status code an agent cannot act on.
- 11 Propose/Preview/Commit A preview step lets an agent see the effect of a write before committing it, so an irreversible action is never the first thing that happens.
- 12 MCP-First Single CDI Bean One CDI bean serves REST, GraphQL and an MCP tool from the same business logic, so the three surfaces never drift apart.
Part 2 Build: MCP packaging
Build the tool surface itself: packaging an API as MCP tools, progressive discovery, and securing what an agent can call.
- 13 Package an API as MCP Tools quarkus-mcp-server packages an existing API's operations as registered MCP tools, resources and prompts.
- 14 Domain-Split Toolset and Progressive Discovery Splitting a large toolset by domain and discovering it progressively keeps an agent's tool list small enough to pick from accurately.
- 15 Reshape not Wrap: Heterogeneous Protocols A gRPC service sits behind the same agent-facing facade as a REST or GraphQL one, reshaped for the caller instead of wrapped unchanged.
- 16 Securing and Gating MCP Tools An MCP tool surface is scoped and gated the same way any other credentialed API is, not left open because the caller happens to be a model.
Part 3 Build: asynchronous APIs
Build the event-driven surface: waking an agent on a Kafka event, coordinating several agents, and gating the ones that need a human.
- 17 Event-Triggered Agent Wakeup A Kafka event wakes an agent to act on its own schedule, instead of the agent polling an endpoint to find out whether anything changed.
- 18 Multi-Agent Choreography Several agents coordinate through events on a shared topic, each reacting to what the others produced, instead of one agent orchestrating every step directly.
- 19 Human-in-the-Loop Gate An explicit gate holds an irreversible action for human approval, with the mechanism chosen to match how long that approval might take.
- 20 Long-Running Agent Workflow A long-running workflow with compensating steps carries an agent-triggered process safely across minutes or days, not just one request.
- 21 Replayable Agent Memory / Event-Sourced Audit An event-sourced log gives an agent a replayable memory of what happened, and a human an audit trail of what the agent did.
Part 4 Consume
Consume what Part 1 to 3 built: calling an MCP server and its async side from Claude Code and from a langchain4j agent.
- 22 Consuming an MCP Server from Claude Code Claude Code registers an MCP server, discovers its tools, and calls them the same way any other MCP-aware harness would.
- 23 Building a Claude Code Skill A packaged skill teaches Claude Code how to drive a specific API correctly, instead of relying on the model to rediscover the right sequence each time.
- 24 langchain4j Agent as a Programmatic Consumer A langchain4j AiService calls the same registered tools programmatically, without a human approving each step.
- 25 Consuming the Async Side A consumer reacts to the same Kafka events an agent-facing producer emits, closing the loop on the asynchronous patterns.
- 26 The Prompt-plus-Contract Loop and Decision-Rule Review A reviewed decision rule, not just a reviewed prompt, is what actually governs whether an agent's action is allowed to happen.
Part 5 Test and automate
Prove the contract holds: manifest conformance, agent-behaviour evals, scripted non-interactive runs, and async and human-in-the-loop test flows.
- 27 Contract and Manifest Conformance A conformance check confirms a running service still matches its published contract and tool manifest, not just that it starts.
- 28 Agent-Behaviour Eval with Deterministic Replay A recorded, replayable transcript turns an agent's behavior on a task into a deterministic, repeatable check.
- 29 Scripted Non-Interactive Consumption A scripted, non-interactive run exercises the same tool contract a human would drive by hand, with its own negative witness.
- 30 Testing Async Flows and the Human-in-the-Loop Gate An async flow and its human-in-the-loop gate are tested the same way any other contract is: by observing the effect, not the exit code.
Part 6 Ship
Publish the tool surface and gate its drift in CI before an agent ever calls it in production.
- 31 Publish the Tool Surface An MCP image, a stdio jar and a published llms.txt ship together as one versioned release of the tool surface.
- 32 CI for Agent-Facing APIs A contract-drift check and a schema-compatibility gate in CI catch a breaking change before an agent ever calls it in production.
Part 7 Run in production
Run agent-facing APIs in production: observability, auditing AI-using code, identity and traffic guardrails, Kubernetes, and the final project.
- 33 Observability for Agent Traffic Traces, metrics and logs for agent traffic carry the OpenTelemetry GenAI conventions, including token and cost, not just a request's latency.
- 34 Auditing AI-Using Code An inward audit of a service's own langchain4j code, not just the APIs it exposes, confirms what it is actually allowed to call out to.
- 35 Identity and Authorization Guardrails Keycloak OIDC, PKCE, client credentials and token exchange carry an agent's delegated identity through a call, with a step-up challenge where the action warrants one.
- 36 Traffic and Resource Guardrails Rate limits, topic ACLs, schema enforcement and quotas bound what an agent-facing surface can be made to do under load or abuse.
- 37 Running on Kubernetes with Strimzi The final project runs on Kubernetes with Strimzi-managed Kafka, the same domain the whole catalog builds on.
- 38 Final Project: the Focused Multi-Domain Data Mesh A focused data mesh built from the shipping domain's own services closes the lifecycle, governed by Dehghani's four data mesh principles.
Appendices Appendices
Reference material: llms.txt in depth, OpenShift Local, a streaming comparison, the pattern map and glossary, building a consuming skill end to end, deterministic decisioning behind an agent tool, and structured outputs for typed agent I/O.
- A llms.txt in Depth A deeper, standalone treatment of llms.txt: its syntax, its placement, and how a model actually reads it.
- B OpenShift Local (CRC) The final project's data products run again on OpenShift Local, the same neutral code demonstrated on a different platform.
- C Streaming Comparison (WebSockets, Webhooks, gRPC) WebSockets, webhooks and gRPC are compared side by side as alternatives to the request/response and event-driven patterns built elsewhere in the catalog.
- D Pattern Map and Glossary A pattern map, a glossary and a cross-stack transfer table index every pattern against its Python/FastAPI and Strawberry GraphQL equivalent.
- E Building the Consuming Skill in Claude Code, End to End A Claude Code skill for driving this catalog's own services is assembled end to end, from its first prompt to its packaged form.
- F Deterministic Decisioning Behind Agent Tools A rules or DMN engine behind a tool makes a business decision deterministic, the concrete answer to trusting a model's own reasoning to enforce it.
- G Structured Outputs: Typed, Consistent Agent I/O Grammar-constrained decoding types the one boundary the catalog had not typed yet, the model's own generation, so a typed call returns a fixed shape on every run.