ADR 0009: A read-only MCP server (authority L1, complete surface)
Status
Accepted (2026-11-14). Adds the MCP surface the fleet's Agentic Standard v2 (AS-9)
asks of a storefront context that has an A2A agent (ADR 0006)
and no MCP server. Amends the sentence of ADR 0006 "shopping-cart has no cmd/mcp
and no MCP adapter": it now has both. The tool set of that ADR (two read skills) is
unchanged.
Context
Every other bounded context of the fleet that exposes an HTTP API also ships an MCP
server so that agents (warehouse-ops-agent first) can read its data without a
bespoke REST client (the fleet's ADR 0008 in warehouse-docs: one MCP server per bounded context, an additive
inbound adapter, the official MCP Go SDK, Streamable HTTP only, a separate cmd/mcp
binary). shopping-cart had an A2A agent and a REST API but no MCP server.
The Agentic Standard v2 also asks every MCP server for an authority level on every
tool (AS-1), a surface beyond tools, at least one resource and one prompt (AS-3), and
a stateless Streamable HTTP handler (AS-4). A cart is customer data (a shopperId
reference, quantities, a delivery postal prefix, ADR 0001/0006), so the surface may
not be wider than the REST GETs.
Decision
-
A driving adapter and a separate binary.
internal/adapters/inbound/mcpis built on the official MCP Go SDK (github.com/modelcontextprotocol/go-sdkv1.8.0) and served over Streamable HTTP only (no stdio, no SSE) bycmd/mcp, mounted at/mcpand/with an openGET /healthz. It is a third deployable besidecmd/apiandcmd/a2a, shipped in the SAME image as/app/mcp. The Helm chart gains anmcpcomponent (default OFF) with an optional gateway HTTPRoute at/api/mcp/shopping-cart. -
Two read tools, one per read GET of
apis/openapi.yaml. Each tool is a thin wrapper over a use case that already backs a REST GET and an A2A skill, with the same wire shape as REST (views.Cart.LastChangedAt, which REST withholds, is not mapped). All are authority L1 (tool metadatacom.warehouse/authority) and annotated read-only, idempotent and closed-world:Tool Input Authority Use case REST counterpart A2A skill get_cartcartIdL1 GetCartGET /carts/{cartId}get_cartlist_shopper_cartsshopperId,state?,limit?L1 ListCarts(first page)GET /carts?shopperId=&state=&limit=list_shopper_cartslist_shopper_cartsanswers ONE page, newest first (limit1 to 100, default 20), withhasMorewhen older carts exist. It takes no cursor: the MCP surface is narrower than REST, never wider. A guest cart is reachable throughget_cartonly. -
One resource, one prompt (AS-3).
warehouse://shopping-cart/carts/{cartId}(resource template,application/json): the cart document of ONE cart, the sameGetCartuse case as the tool, a scoped read model and never a table dump.review_cart(prompt, one required argumentcartId): this context's operator procedure: read the cart, interpret the estimate (a labelled, non-binding estimate) and the checkout readiness, and name what nothing here can do. It names tools and never calls them.
-
Stateless transport (AS-4). The handler is built with
&mcp.StreamableHTTPOptions{Stateless: true}: noMcp-Session-Idis issued, the server answers the 2026-07-28 per-request handshake (server/discover) and a legacyinitializestill answers 200 (stateless_test.go). -
Read-only is structural. The adapter's
Depsholdsusecases.GetCartandusecases.ListCartsand nothing else;cmd/mcpwires only the cart repository and the three read-model repositories the estimate needs, plus the clock. No unit of work, outbox, inbox, id generator, delivery-promise quoter or Kafka client exists in the binary, so a read can neither write nor call another context. A cart MUTATION (create, add, set or remove a line, destination, quoting, selecting a delivery, merge, accepting requoted offers) is NOT exposed and stays REST. Quoting is not a tool:POST /carts/{cartId}/delivery-quotescalls delivery-promise and is a write.TestToolSurfacepins the exact set (budget 2), the read-only annotations and the absence of write verbs in tool names;TestWriteSeamSensorFailsOnWriteSeamsfails the build when the adapter names a write use case or a transactional seam;TestToolRegistryGoldenpins the whole advertised registry,_metaincluded. -
Authority declarations.
authority.gocarries the fleet's pinned const ladder; everymcp.Toolliteral setsMeta: authorityMeta(authorityL1). Both A2A skills of ADR 0006 gain the tagauthority:L1(the only change to the Agent Card; the fleet agent catalogue is regenerated from it). The unusedauthorityL2..L4constants of the fleet's pinned shape are not declared here: nothing in this context recommends or writes over MCP, and the sensor (internal/architecture/mcp_authority_fitness_test.go) reads only the key, the helper and the level a tool uses. -
Errors. Typed errors carry the REST problem slug as the prefix of the tool error:
not-found(unknown cart, an over-long or NUL-carryingcartId),validation-failed(emptycartId,shopperIdmissing or invalid,statenot one of OPEN, CHECKED_OUT, ABANDONED, MERGED,limitout of range). Anything else is logged and answered asinternal-errorwith no detail. -
No auth, no sibling calls. Unauthenticated like every fleet endpoint (reverted 2026-09-11); access control is the in-cluster ClusterIP boundary.
TestNoAuthMiddlewareReintroducedcovers the adapter. The server reads this context's own tables only. -
Observability.
cmd/mcpbrings up the same fleet telemetry ascmd/api(ADR 0005) under the service nameshopping-cart-mcp, with the same middleware order: RequestID, otelchi, the request-duration histogram, RequestLogger, Recoverer. No new metric is added. -
Boot.
DATABASE_URLis mandatory (no in-memory mode); the binary runs the idempotent embedded migrations on start (MIGRATIONS_DATABASE_URLfor a direct DSN), wrapped in thebootretrybudgetcmd/apiuses.MCP_ADDR(default:8090),CART_CURRENCY,LOG_LEVEL,SERVICE_VERSIONandENVIRONMENTcomplete the environment. -
Fitness.
TestMCPAdapterDependencyRule(nothing butcmd/mcpimports the adapter, and it imports noinbound/http),TestMCPOptionalToolInputsCarryOmitemptyand the authority and surface sensors ofmcp_authority_fitness_test.go.
Consequences
- An agent can answer "what does this cart hold, what would it cost, is it ready for checkout" and "which carts does this shopper have" without REST glue, with the same data as REST, and cannot change anything.
- Adding a tool is a reviewed act: the tool budget, the curated list and the golden
file change together. A write tool would be a new ADR (L3,
initiated_byattribution) and would reopen the question of an unauthenticated surface. - One more Deployment per release when
mcp.enabledis set; warehouse-infra turns it on and supplies the gatewayparentRefs. - Left out on purpose (no existing read use case backs them): a tool that lists
carts without a shopper (REST offers none, ADR 0002 A15), a cursor on
list_shopper_carts, and a quote tool (a write to delivery-promise).