Skip to main content

API overview

cmd/api serves the REST routes below on HTTP_ADDR (default :8080); cmd/a2a serves the A2A agent on A2A_ADDR (default :8093); cmd/mcp serves the MCP server on MCP_ADDR (default :8090). The contracts are apis/openapi.yaml and apis/asyncapi.yaml, pinned by ADR 0001 and ADR 0002. The service is a read side: it has no write route (hence no Idempotency-Key) and publishes no event. Everything is unauthenticated, by fleet decision (TestNoAuthMiddlewareReintroduced).

Source: internal/adapters/inbound/http/server.go, internal/adapters/inbound/http/handlers.go, cmd/a2a/router.go, internal/adapters/inbound/a2a/, cmd/mcp/router.go, internal/adapters/inbound/mcp/.

Interfaces​

InterfaceSource of truthNotes
RESTapis/openapi.yaml (OpenAPI 3.0.3, version 1.0.0)The pages under REST in the sidebar are generated from the spec with npm run gen-api-docs; do not edit them by hand. The spec names one server, http://localhost:8080. Through Kong in the kind cluster the routes are under /api/product-discovery (prefix stripped)
Eventsapis/asyncapi.yaml (AsyncAPI 3.0.0, version 1.0.0)The service consumes eleven event types and publishes none; see the event catalogue and Domain events
MCPADR 0009, internal/adapters/inbound/mcp, cmd/mcp, MCP toolsStreamable HTTP, stateless, on /mcp and /, port 8090 (through Kong /api/mcp/product-discovery, rewritten to /mcp). Two read-only tools, both authority L1: search_products and get_product; one resource and one prompt
A2AADR 0007, internal/adapters/inbound/a2a, cmd/a2aJSON-RPC 2.0 on / and /a2a, Agent Card at /.well-known/agent-card.json, port 8093 (through Kong /api/a2a/product-discovery, rewritten to /). Two read-only skills, no write skill: search_products and get_product

Endpoints​

TagEndpointOperation idSuccessErrors
ProductsGET /productssearchProducts200 {items, facets, categorySuggestions, nextCursor}422 validation-failed; 400 invalid-limit, invalid-cursor, unknown-query-parameter, malformed-request (NUL in the query)
ProductsGET /products/{catalogItemId}getProduct200 the product view404 not-found (unknown, stub or over-long id)
CategoriesGET /categorieslistCategories200 {version, categories[]}, empty at version 0none
HealthGET /healthznot in the spec200 {"status":"ok"} always while the process runsnone
HealthGET /readyznot in the spec200 {"status":"ready"}503 {"status":"not_ready"} while draining; 503 dependency-unavailable (detail not ready: postgres or kafka)
A2APOST / and POST /a2a on cmd/a2anot in the specthe skill answer in a reply messageproblems travel in the reply envelope
A2AGET /.well-known/agent-card.json, GET /healthz on cmd/a2anot in the specthe Agent Card / {"status":"ok"}none
MCPPOST /mcp and POST / on cmd/mcp, GET /healthznot in the specthe tool, resource or prompt resulttool errors in-band (isError) with the REST slugs

GET /products parameters​

ParameterTypeRule
qstringFree text; at most 200 characters after whitespace is collapsed. Empty means browse
categoryIdstringThe category and all its descendants; an id outside the tree matches nothing
inStockbooleanExactly true or false
priceMin, priceMaxintegerEffective price in minor units, not negative, priceMin at most priceMax. Only priced rows match
sortstringrelevance (default), price-asc, price-desc, title
cursorstringThe opaque nextCursor of the previous page; bound to the same sort and the same kind of query. Invalid or repeated: 400 invalid-cursor
limitinteger1 to 500, default 100. Out of range, empty, or repeated: 400 invalid-limit

Any other query parameter, including the retired after, offset and nextToken, is 400 unknown-query-parameter.

Response shape: items holds the hits (nextCursor is absent on the last page); each hit has catalogItemId, title, effectivePrice (amountMinor, currency), primaryMedia, categoryId, categoryPath, inStock, purchasable. facets always holds three entries in the order category, price-band and in-stock; empty buckets are dropped; price-band values are labels such as <2500, 2500-4999, 25000+ (edges from PRICE_BAND_EDGES). categorySuggestions (up to 5) appears for text queries. nextCursor is absent on the last page.

A2A agent​

cmd/a2a is a message-only, read-only agent built on the official a2a-go SDK (ADR 0007). Streaming is not advertised and the Agent Card declares no security scheme (the surface is unauthenticated). The same read use cases back REST and A2A, so answers match; cmd/a2a's parity test compares both surfaces.

SkillArgumentsBacked byAnswer
search_productsthe query parameters of GET /products under the same names: q, categoryId, inStock, priceMin, priceMax, sort, after, limit, all optionalQueries.SearchProductsdata.search with hits, facets, categorySuggestions, next
get_productcatalogItemId (required)Queries.GetProductdata.product, the product view

A request is a JSON-RPC 2.0 SendMessage call (header A2A-Version: 1.0) on / or /a2a whose message's first part is a Data part (or a Text part holding the same JSON):

{"skill": "search_products", "arguments": {"q": "kettle", "inStock": true, "sort": "price-asc", "limit": 5}}

The reply is an agent message with a Data part holding the envelope {skill, data} or {skill, problem} and a Text part with a one-line summary. Decoding is strict: an unknown field is refused, not ignored. A problem is a business answer, never a JSON-RPC error, and uses the REST slugs: malformed-request (400: no parts, no skill, unknown skill or field, NUL character, trailing data), not-found (404), validation-failed (422) and internal-error (500). The Agent Card carries the version (SERVICE_VERSION) and advertises A2A_AGENT_URL, so that URL must be dialable by clients.

Conventions in the contract​

  • Errors are RFC 9457 application/problem+json with type /problems/<slug>, title, status, detail and instance. This surface uses malformed-request, not-found, validation-failed, internal-error and (readiness only) dependency-unavailable; a NUL in the URL path answers resource-not-found (404). The slugs and their causes are on Troubleshooting.
  • Money is {amountMinor, currency}: minor units of an ISO-style three-letter currency.
  • Paging is keyset-based: limit and the opaque cursor/nextCursor pair. A cursor is bound to a sort and to a matching mode (browse, full-text or trigram) and is refused with 400 invalid-cursor otherwise. The A2A search_products tool keeps its own schema (after, hits, next, in-band 422).
  • Visibility. A stub row (the item master has not announced the item) is invisible. GET /products/{id} returns every other row, even a discontinued or unpurchasable one; search lists only active items with published content, flagged with purchasable and inStock.
  • Auth: none.
  • Idempotency: the service has no POST or PATCH, so no Idempotency-Key is read; every route is a GET. GET /categories is exempt from paging (x-pagination-exempt: view).

Spec versus code​

  • apis/openapi.yaml lists the 400 malformed-request and the NUL-path 404 resource-not-found answers on no operation; the router returns them (internal/adapters/inbound/http/nul.go).
  • /healthz, /readyz, the A2A endpoints and the MCP endpoints are not in the OpenAPI document.
  • The OpenAPI Problem.type description says "slug, for example validation-failed"; the service emits the path form /problems/validation-failed.