An OpenAPI 3.1 document tells HTTP clients, SDK generators, API hubs, and AI assistants exactly which paths exist, what JSON payloads they accept, and what responses to expect. When your application uses agent-ready, Ferrite generates both /.well-known/api-catalog (aliased at /openapi.json) and RFC 9457 application/problem+json error replies from the same Surface declaration that powers your /mcp endpoint.
Declare operations in Surface
Add each callable HTTP operation to Surface.routes[].operations. Every declared operation becomes a typed OpenAPI path item whose operationId matches Operation.name:
use crate::agent_ready::surface::Operation;
use ferrite_app::serde_json::json;
let create_booking = Operation {
name: "create_booking".into(),
method: "POST".into(),
path: "/api/bookings".into(),
description: "Create a class reservation. Requires a signed-in bearer token; returns 409 when full.".into(),
input_schema: Some(json!({
"type": "object",
"properties": {
"class_id": { "type": "string", "minLength": 1 },
"seats": { "type": "integer", "minimum": 1, "maximum": 4 }
},
"required": ["class_id"],
"additionalProperties": false
})),
output_schema: Some(json!({
"type": "object",
"properties": {
"booking_id": { "type": "string" },
"status": { "type": "string" }
},
"required": ["booking_id", "status"]
})),
read_only: false,
idempotent: true,
price_micros: 0,
};
What agent-ready generates
| Endpoint | Purpose |
|---|---|
GET /.well-known/api-catalog | OpenAPI 3.1 JSON catalogue generated from all declared Surface operations |
GET /openapi.json | Direct alias serving the same OpenAPI 3.1 document |
GET /poppy/openapi.json | Exposure-filtered OpenAPI 3.1 view served when Personal Agent Protocol is enabled, excluding InternalOnly operations |
Each generated operation entry carries:
operationIdset toOperation.name.requestBodyor query parameters derived frominput_schema, plus response schema fromoutput_schemawhen provided.- An
idempotency-keyheader parameter onPOSToperations, annotated as retry-safe only whenidempotentistrue. read_onlyandidempotenttraits matching the tool annotations published on/mcp.- An RFC 9457
application/problem+jsonerror response schema. x-price-usd-microsmetadata and a402Payment Required response wheneverprice_micros > 0(see x402 agent payments).
Ferrite’s App Hub and Code Mode can also index operations from an application’s OpenAPI catalogue when an application exposes HTTP operations without a primary /mcp endpoint.
Return RFC 9457 structured errors
Assistants recover cleanly from conflicts, invalid inputs, and authorization refusals when failures arrive as predictable JSON instead of plain text or HTML error pages. Use agent_ready::problem to return application/problem+json with a stable type URI, HTTP status, short title, and actionable detail:
{
"type": "https://yoga.ferrite.cloud/problems/class-full",
"title": "Class is full",
"status": 409,
"detail": "Saturday 08:30 has 0 seats left. Call list_classes to check the 10:00 session."
}
Never place stack traces, internal hostnames, SQL or store keys, or secret names inside detail. State what failed and which declared operation or input change resolves it.
Explicit boundaries and limits
- No auto-generated
securitySchemesor rate-limit schemas.agent-readydoes not infer authentication headers or rate-limit headers from your handler code. Document required authentication, scopes, and throttling behavior in each operation’sdescription, or enable Personal Agent Protocol for scope-annotated Poppy discovery. - Machine-readable JSON only. Ferrite does not bundle Swagger UI or Scalar UI. Serve
/openapi.jsondirectly to clients, generators, and agent hubs, and document workflows for humans and models in your pages andllms.txt. - Declaration vs runtime truth.
agent-readyemits what yourSurfacedeclares; it does not enforceread_only,idempotent, oroutput_schemaat runtime. Only setidempotent: trueon aPOSToperation when your handler deduplicates repeatedidempotency-keyrequests atomically.
Verify locally
ferrite dev
curl -s http://127.0.0.1:8787/.well-known/api-catalog | jq '.openapi, (.paths | keys)'
curl -s http://127.0.0.1:8787/openapi.json | jq '.info'
Confirm that .openapi starts with 3.1, every declared operation appears under .paths, and refused requests return Content-Type: application/problem+json.
Next steps
- Pair HTTP schemas with browser-context tools in WebMCP.
- Expose the same operations over stateless MCP in MCP Servers.
- Gate priced OpenAPI operations with x402 agent payments.