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
| Interface | Source of truth | Notes |
|---|---|---|
| REST | apis/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) |
| Events | apis/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 |
| MCP | ADR 0009, internal/adapters/inbound/mcp, cmd/mcp, MCP tools | Streamable 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 |
| A2A | ADR 0007, internal/adapters/inbound/a2a, cmd/a2a | JSON-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
| Tag | Endpoint | Operation id | Success | Errors |
|---|---|---|---|---|
| Products | GET /products | searchProducts | 200 {items, facets, categorySuggestions, nextCursor} | 422 validation-failed; 400 invalid-limit, invalid-cursor, unknown-query-parameter, malformed-request (NUL in the query) |
| Products | GET /products/{catalogItemId} | getProduct | 200 the product view | 404 not-found (unknown, stub or over-long id) |
| Categories | GET /categories | listCategories | 200 {version, categories[]}, empty at version 0 | none |
| Health | GET /healthz | not in the spec | 200 {"status":"ok"} always while the process runs | none |
| Health | GET /readyz | not in the spec | 200 {"status":"ready"} | 503 {"status":"not_ready"} while draining; 503 dependency-unavailable (detail not ready: postgres or kafka) |
| A2A | POST / and POST /a2a on cmd/a2a | not in the spec | the skill answer in a reply message | problems travel in the reply envelope |
| A2A | GET /.well-known/agent-card.json, GET /healthz on cmd/a2a | not in the spec | the Agent Card / {"status":"ok"} | none |
| MCP | POST /mcp and POST / on cmd/mcp, GET /healthz | not in the spec | the tool, resource or prompt result | tool errors in-band (isError) with the REST slugs |
GET /products parameters
| Parameter | Type | Rule |
|---|---|---|
q | string | Free text; at most 200 characters after whitespace is collapsed. Empty means browse |
categoryId | string | The category and all its descendants; an id outside the tree matches nothing |
inStock | boolean | Exactly true or false |
priceMin, priceMax | integer | Effective price in minor units, not negative, priceMin at most priceMax. Only priced rows match |
sort | string | relevance (default), price-asc, price-desc, title |
cursor | string | The opaque nextCursor of the previous page; bound to the same sort and the same kind of query. Invalid or repeated: 400 invalid-cursor |
limit | integer | 1 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.
| Skill | Arguments | Backed by | Answer |
|---|---|---|---|
search_products | the query parameters of GET /products under the same names: q, categoryId, inStock, priceMin, priceMax, sort, after, limit, all optional | Queries.SearchProducts | data.search with hits, facets, categorySuggestions, next |
get_product | catalogItemId (required) | Queries.GetProduct | data.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+jsonwithtype/problems/<slug>,title,status,detailandinstance. This surface usesmalformed-request,not-found,validation-failed,internal-errorand (readiness only)dependency-unavailable; a NUL in the URL path answersresource-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:
limitand the opaquecursor/nextCursorpair. A cursor is bound to a sort and to a matching mode (browse, full-text or trigram) and is refused with400 invalid-cursorotherwise. The A2Asearch_productstool 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 withpurchasableandinStock. - Auth: none.
- Idempotency: the service has no
POSTorPATCH, so noIdempotency-Keyis read; every route is aGET.GET /categoriesis exempt from paging (x-pagination-exempt: view).
Spec versus code
apis/openapi.yamllists the400 malformed-requestand the NUL-path404 resource-not-foundanswers 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.typedescription says "slug, for example validation-failed"; the service emits the path form/problems/validation-failed.