ADR 0005: MCP server adoption (read-only, unauthenticated, additive)
Status
Accepted (2026-10-07).
Amended by ADR 0010: the
"in-memory when DATABASE_URL is unset" fallback below no longer exists;
cmd/mcp exits at boot without DATABASE_URL.
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 records the
same decision for that context). product-master owns SKU master data that
agents ask about constantly ("is this SKU hazmat?", "what does it weigh?"),
while every change to that data must leave as a versioned CloudEvent through
the transactional outbox (ADR 0004) so the local copies in inventory-storage,
wes-work-planning and fulfillment-execution stay consistent.
Decision
cmd/mcpis a second composition root, independent ofcmd/api: it wires the SAME read use cases (usecases.GetProduct,usecases.ListProducts) to the SAME product repository (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: 4 tools, each backed by an existing read use
case and returning the REST body with snake_case names:
get_product,list_products(filtershandling_tag,classified; cursor pagination),get_product_classificationandget_physical_profile. Errors are tool results (isError: true) whose text starts with the REST problem slug (product-not-found,product-classification-not-found,invalid-sku,malformed-request); anything untyped is logged and reported as a genericinternal-error. - No write tool. Registering, classifying, declaring dimensions and
recording measurements stay REST-only: those are the operations whose
events downstream contexts consume, and 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,classify,declare,record,update,delete,set,create), if a tool is not annotated read-only, or if the surface exceeds the 4-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 and never dials Kafka: it reads the same Postgres databasecmd/apiwrites and has noEVENT_PUBLISHER,KAFKA_BROKERSor consumer group. 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/product-master) 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 product questions without a REST client, and can never change product master data 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 product 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.
Alternatives considered and rejected
- Mirror every REST operation as a tool (read + write): rejected; see point 3. Writes stay where the outbox, 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.