ADR 0007: a read-only MCP server
Status
Accepted (2026-10-24).
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. offer-availability had none. The service already has the
read use cases behind its REST adapter (BrowseCatalog, GetCatalogItem,
ListListings, GetInventoryFeed), so an MCP adapter is another driving
adapter over them, not new domain.
Decision
- A second driving adapter, 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 open/healthzonMCP_ADDR(default:8090). It is a second deployable besidecmd/api; the Helm chart gets an mcp Deployment, Service and (off by default) Kong HTTPRoute rewriting/api/mcp/offer-availabilityto/mcp. - Four read tools over the existing queries, nothing else.
browse_catalog(limit?, after?),get_catalog_item(catalogItemId),list_listings(nodeId?, catalogItemId?, limit?, after?)andget_inventory_feed(feedId): every GET ofapis/openapi.yaml, grouped one tool per read use case. Arguments and results are lowerCamelCase like the REST contract; typed errors carry the REST problem slug (not-found,validation-failed) as the prefix of the tool error. Creating an item, discontinuing one, creating a listing and applying a feed stay REST-only. - Read-only is structural. The adapter's
Depsholds the four read use cases and nothing that can write; the adapter andcmd/mcpimport no event sink, no outbox, no Kafka adapter, no consumer and no janitor.cmd/mcpnever dials Kafka and never starts the relay: those stay incmd/api.TestMCPAdapterDependencyRule(internal/architecture) pins the imports and that nothing else depends on the adapter;TestToolSurfacepins the exact tool set (budget 4), the read-only annotations and the absence of write verbs in tool names;TestToolRegistryGoldenpins the whole advertised registry (input AND output schemas, byte for byte); the integration test proves the binary reads whatcmd/api's use cases wrote in a real Postgres and adds no outbox row. Optional tool inputs are published as optional (omitemptyon the json tag;TestMCPOptionalToolInputsCarryOmitempty). - No sibling calls, no auth. The server reads this context's own tables
only, calls no other context over REST or MCP, and has no auth layer (the
fleet-wide revert of 2026-09-11;
TestNoAuthMiddlewareReintroducedscans every inbound tree, this one included). Access control is the in-cluster ClusterIP boundary. - Boot.
DATABASE_URLis mandatory (no in-memory mode); the binary runs the idempotent embedded migrations on start, exactly likecmd/api(withMIGRATIONS_DATABASE_URLfor a direct DSN behind PgBouncer), wrapping the migrations and the first ping ininternal/bootretry, so it can start against a fresh database beforecmd/apihas. Graceful shutdown drains the HTTP server on SIGINT/SIGTERM.
Consequences
- Agents can answer "which nodes can ship item X, what availability do they report, and what happened to feed Y" without REST glue.
- Adding a tool is a reviewed act: the tool budget, the curated list and the golden file all change together (an amendment of this ADR).
- The write side stays exactly where it was: REST with
Idempotency-Key, the transactional outbox and the consumers of ADR 0005.