ADR 0007: MCP server adoption (read-only, unauthenticated, additive)
Status
Accepted (2026-10-18).
Context
The fleet exposes every bounded context to warehouse-ops-agent (and any other
MCP client) through a second, independent deployable binary that serves the
Model Context Protocol over Streamable HTTP, alongside the REST API and never
bundled into the same process (the same decision is recorded in
slotting-optimization ADR 0005, product-master ADR 0005 and inbound-receiving
ADR 0005). pick-face-replenishment owns the min/max replenishment policies and
the replenishment requests that move stock from a reserve bin to a forward pick
face (ADR 0002). Agents ask about them constantly ("which pick faces are below
minimum?", "why was repl-... cancelled?"), while every change must leave as a
versioned CloudEvent through the transactional outbox (ADR 0004), guarded by
If-Match and Idempotency-Key (rule 8 of the service guide).
Decision
cmd/mcpis a second composition root, independent ofcmd/api: it wires the SAME read use cases (ListPolicies,GetPolicy,ListPickFaces,ListRequests,GetRequest) to the SAME Postgres repositories through a dedicated inbound adapter (internal/adapters/inbound/mcp) instead of the REST router. It is built on the official SDK (github.com/modelcontextprotocol/go-sdk), Streamable HTTP only (no stdio, no SSE), listens onMCP_ADDR(default:8090), serves the MCP endpoint at both/and/mcp, and answersGET /healthzfor the probes.- The surface is read-only: 5 tools, each backed by an existing read use
case and returning the REST body with snake_case names:
list_policies(site_id,sku,limit,cursor),get_policy(site_id,sku),list_pick_faces(site_idrequired;statusBELOW_MIN, OK, NO_SOURCE or NO_POLICY;limit,cursor),list_replenishments(site_id,sku,stateRequested, Completed or Cancelled;limit,cursor) andget_replenishment(request_id). Arguments are snake_case like every sibling MCP server, where REST uses camelCase (siteId). Lists page with the opaque cursor of the REST API (limit1..500, default 100,next_cursorabsent on the last page). Errors are tool results (isError: true) whose text starts with the REST problem slug (policy-not-found,replenishment-not-found,invalid-site-id,invalid-sku,invalid-request-id,invalid-state,invalid-status,invalid-limit,invalid-cursor); anything untyped is logged and reported as a genericinternal-error. - No write tool. Declaring or removing a policy, requesting and cancelling
a replenishment and the site evaluation stay REST-only: those are the
operations whose events other contexts consume, whose idempotency is keyed
by
Idempotency-Keyand whose version guard isIf-Match; an agent write path would be a second front door to the outbox. Read-only is pinned three ways:internal/adapters/inbound/mcp/governance_test.gofails the build on a write-verb tool name, a tool that is not annotated read-only or a surface above the 5-tool budget, and pins the registry golden byte for byte;internal/architecture'sTestMCPSurfaceIsReadOnlyfails when the adapter orcmd/mcpreferences any write use case, imports the outbox, the event sink, Kafka, the ports package or the in-memory doubles, builds an outbox repository, unit of work or idempotency store, or gives its detector an event sink, id generator or clock (TestEveryUseCaseIsClassifiedReadOrWritekeeps that list from going stale); and the integration test proves a series of reads leaves theoutbox_eventstable unchanged. - No authentication of any kind, matching the fleet-wide decision
(reverted 2026-09-11) that REST and MCP are both unauthenticated; access
control is the in-cluster
ClusterIPboundary.TestNoAuthMiddlewareReintroducedfails CI if auth middleware appears. - Postgres only, no Kafka. Like
cmd/api(ADR 0006) the binary has no in-memory mode: withoutDATABASE_URLit refuses to boot, naming the variable. It never starts the outbox relay, never runs the local-copy consumers and never dials Kafka (noKAFKA_BROKERS,*_MODEor consumer group). It reads the same databasecmd/apiwrites, solist_pick_facesanswers from the event-fed local copies (ADR 0003), never from a live call to a sibling. It runs the idempotent embedded migrations on boot (throughMIGRATIONS_DATABASE_URLwhen set), so it can start against a fresh database; golang-migrate's advisory lock makes concurrent starts safe. It readsFORWARD_ZONE_CODESandRESERVE_ZONE_CODESexactly ascmd/apidoes. TestMCPAdapterDependencyRulekeeps the adapter additive: it depends only on the application and domain layers, and nothing else imports it.- Packaging: the image (
Dockerfile) builds everycmd/*binary, so/app/mcpships next to/app/api; the chart renders anmcpDeployment and ClusterIP Service (componentmcp) only whenmcp.enabled=true(default false), and the chart selector test proves each Service selects exactly one Deployment. No HPA for mcp: the SDK keeps per-process session state.
Consequences
- An agent can read policies, pick-face status and requests without any REST client; it cannot change anything. The REST contract stays the only write path.
- The tool registry is a reviewed contract: adding or changing a tool changes
the golden and, for a new tool, the budget in
governance_test.goand this ADR. - The MCP pod needs a Postgres DSN and nothing else; it can run when Kafka is down.