ADR 0005: MCP server adoption (read-only, unauthenticated, additive)
Status
Accepted (2026-10-08). The in-memory repositories without DATABASE_URL and the permissive dock-door mode are superseded by ADR 0011.
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 (warehouse-planning ADR 0008 and
product-master ADR 0005 record the same decision for those contexts).
inbound-receiving owns the inbound dock workflow (ASNs, dock appointments,
receipts and their discrepancies) that agents ask about constantly ("is the
8:00 truck at door 3 checked in?", "which receipts closed short today?"), while
every change to that data must leave as a versioned CloudEvent through the
transactional outbox (ADR 0004) so the downstream contexts stay consistent.
Decision
cmd/mcpis a second composition root, independent ofcmd/api: it wires the SAME read use cases (usecases.GetAsn,ListAsns,GetAppointment,ListAppointments,GetReceipt,ListReceipts,ListDocks) to the SAME repositories (in-memory whenDATABASE_URLis unset, Postgres otherwise) 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: 7 tools, each backed by an existing read use
case and returning the REST body with snake_case names:
get_asn,list_asns(filterstate),get_appointment,list_appointments(filtersdoor,state,from,to),get_receipt,list_receipts(filtersasn_number,state) andlist_docks(no arguments; the inbound dock doors of the local copy of ADR 0003 and the mode it runs in). 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 (asn-not-found,appointment-not-found,receipt-not-found,invalid-asn-number,invalid-appointment-id,invalid-receipt-id,invalid-door-code,invalid-query); anything untyped is logged and reported as a genericinternal-error. - No write tool. Registering and cancelling ASNs, booking, checking in
and cancelling appointments, and opening, receiving into and closing
receipts stay REST-only: those are the operations whose events other
contexts consume, whose idempotency is keyed by the
Idempotency-Keyheader, and whose version guard is theIf-Matchheader; an agent-initiated write path would be a second front door to the outbox with no reviewed use.cmd/mcpwires no write use case at all, so it cannot insert into the outbox.internal/adapters/inbound/mcp/governance_test.gofails the build if any advertised tool name contains a write verb (register,book,check,cancel,open,receive,close,create,update,delete,set), if a tool is not annotated read-only, or if the surface exceeds the 7-tool budget; the tool-registry golden (testdata/tool_registry.golden.json) pins names, descriptions, annotations and input/output schemas byte for byte. - 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. cmd/mcpnever starts the outbox relay, never runs the local-copy consumers and never dials Kafka: it reads the same Postgres databasecmd/apiwrites and has noEVENT_PUBLISHER,KAFKA_BROKERSor consumer group. The one mode-like variable it reads isDOCK_DOOR_MODE, only solist_docksreports the samemodeasGET /docks(permissive or kafka); it starts nothing. It runs the idempotent embedded migrations on boot (throughMIGRATIONS_DATABASE_URLwhen set, likecmd/api), so it can start against a fresh database; golang-migrate's advisory lock makes concurrent starts safe.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 (charts/inbound-receiving) renders anmcpDeployment + 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 answer inbound-dock questions without a REST client, and can never change an ASN, appointment or receipt, or emit an event, by doing so.
- Adding a tool (or any write tool) is a reviewed act: a new ADR or an
amendment of this one, the golden updated with
-update, and the budget ingovernance_test.goraised in the same change. - Two binaries now read the inbound tables; the mcp one holds no write
credentials beyond what the shared
DATABASE_URLgrants. A read-only database role for it is possible later without code changes. list_receiptsandget_receiptshow discrepancies as the receipt stands (same as the REST body): provisional while the receipt is Open, final once Closed.
Alternatives considered and rejected
- Mirror every REST operation as a tool (read + write): rejected; see point 3. Writes stay where the outbox, the idempotency keys, the version guard and the API contract are reviewed.
- Bundle MCP into
cmd/api's HTTP server: couples the two surfaces' scaling and failure domains; the fleet convention is two deployables. - Bearer-token auth on MCP only: rejected fleet-wide in the 2026-09-11 revert.