ADR 0009: A read-only MCP server with authority levels and a complete surface
Status
Accepted (2026-11-14). Follows the fleet Agentic Standard v2 (AS-1 authority,
AS-3 complete surface, AS-4 stateless transport; warehouse-docs
docs/architecture/agentic-standard.md) and the fleet decision of one MCP server per
bounded context (warehouse-docs ADR 0008). Builds on ADR 0007 (the
A2A adapter, whose two read skills this server mirrors) and
ADR 0005 (observability).
Context
pricing has a REST API and an A2A agent (ADR 0007) but no MCP server, so an agent that wants this
context's tools has to speak REST or delegate over A2A. The Agentic Standard v2 (AS-9) asks the
storefront contexts that have an A2A agent but no MCP server to gain one. The fleet rules for it:
one MCP server per bounded context, an additive inbound adapter over the existing use cases, the
official MCP Go SDK, Streamable HTTP only, a separate cmd/mcp binary, no authentication of any kind
(auth is reverted fleet-wide, TestNoAuthMiddlewareReintroduced pins that for the REST side), and an
MCP surface never wider than what the context already exposes.
Decision
-
A third driving adapter, a separate binary.
internal/adapters/inbound/mcpis built on the official MCP Go SDK (github.com/modelcontextprotocol/go-sdk) and served over Streamable HTTP only (no stdio, no SSE) bycmd/mcp, mounted at/mcpand/with an openGET /healthz, port 8090 (MCP_ADDR). It ships in the same image as/app/mcp. The Helm chart gets anmcp.*component (<release>-mcpDeployment and Service, default off) and an optional gateway route/api/mcp/pricing. -
Read-only charter: two tools, one per read the A2A agent already offers. Each tool is a thin wrapper over a query use case that already backs a REST
GET, and returns the fields thatGETreturns (the same field sets ADR 0007 pins for the A2A answers).Tool Input Authority Backing use case REST counterpart A2A counterpart get_item_pricecatalogItemId(required)L1 GetItemPriceGET /item-prices/{catalogItemId}skill item_priceget_price_quotequoteId(required)L1 GetPriceQuoteGET /price-quotes/{quoteId}skill quote_statusget_item_priceanswers "what does this item sell for right now": state, list price, the effective price at this instant and every sale window.get_price_quoteanswers "what did this quote price and is it still valid":ISSUEDorEXPIREDat this instant (derived fromexpiresAtas the REST read does), lines, delivery charge per group, tax, total and the versions used. An unknown id, an id longer than the REST path bound of 128 bytes, or one carrying U+0000 isnot-found(the same classification as REST and the A2A agent; a NUL must never reach PostgreSQL), any other error is logged and reported asinternal-errorwithout its message. Tool errors areisErrorresults whose text starts with the REST problem slug. -
Authority (AS-1). Every tool declares
Meta: authorityMeta(authorityL1)undercom.warehouse/authorityand is annotated read-only, idempotent and closed-world. There is no L2 (nothing recommends) and no L3/L4 (nothing writes), so the adapter declares only theauthorityL1constant.internal/architecture/mcp_authority_fitness_test.gofails the build when a tool misses its declaration, when a level contradicts the read/write annotations, or when the server offers no resource or no prompt. -
Complete surface (AS-3). Exactly one resource and one prompt join the tools, both read-only:
warehouse://pricing/item-prices/{catalogItemId}(resource template,application/json): the current price of ONE item, the sameGetItemPriceuse case as the tool, never a table dump.explain_item_price(prompt, one required argumentcatalogItemId): this context's operator procedure to read an item's price, interpret list versus effective price and sale windows, read a quote that references the item, and know what to hand to a human. It names tools and never calls them.
-
Stateless transport (AS-4). The Streamable HTTP handler is built with
&mcp.StreamableHTTPOptions{Stateless: true}: noMcp-Session-Idis issued and the server answers the 2026-07-28 revision's per-request handshake while a legacyinitializestill answers 200. -
Read-only is structural. The adapter holds
Reads, an interface of exactly the two query use cases;cmd/mcpwires only the item-price and quote repositories and the clock into the two queries, never a unit of work, outbox, inbox, Kafka or policy loop, and reads no Kafka variable.TestToolSurfacepins the tool set, the read-only annotations and the absence of write verbs;TestWriteSeamSensorFailsOnWriteSeamsfails the build if the adapter names a write use case or a transactional seam;TestToolRegistryGoldenpins the whole advertised registry including_meta;TestMCPAdapterDependencyRule(already infitness_test.go) keeps the adapter inward-only and imported by nothing;TestMCPOptionalToolInputsCarryOmitemptykeeps optional inputs optional (this surface has none today). The integration test proves the binary reads whatcmd/api's use cases wrote in a real Postgres. -
Observability.
cmd/mcphas the sametelemetry.goshape ascmd/apiandcmd/a2a(fleet OTel standard, ADR 0005):service.namepricing-mcp, the same request-logger and otelchi middleware order. No new metric is introduced. -
No auth, no sibling calls. The server reads this context's own tables only and has no auth layer; access control is the in-cluster ClusterIP boundary, as for REST and A2A.
-
Boot.
DATABASE_URLis mandatory; the binary runs the idempotent embedded migrations on start (direct DSNMIGRATIONS_DATABASE_URLwhen given) under the samebootretrybudget as the other binaries.
Left out on purpose
GET /item-prices(the bootstrap list),GET /delivery-charge-schedules/currentandGET /tax-tables/current: REST reads that ADR 0007 already declined as agent goals (projection rebuild input and quote inputs). They stay REST-only; adding one as a tool is a reviewed amendment of this ADR (golden, tool list and tests move together).IssuePriceQuotemints and holds a quote: a state change. It would be an L3 tool and needs its own ADR (withinitiated_byattribution and an integration test proving the outbox row). Not exposed. The price-setting, sale and policy publication operations stay REST-only too.
Consequences
- Agents can read a price and a quote with typed tools, one resource and one prompt, without REST glue.
- A third deployable (
/app/mcp, port 8090) in the same image and anmcp.*chart block, default off: nothing changes in a running cluster until the infra switch-on. - The MCP server holds a Postgres pool of its own (
postgres.MaxConns= 10); a deployment that scales it should size Postgres connections for api, a2a and mcp replicas together. - Adding any tool is a reviewed act: the curated list, the golden file and the tests change together.