ADR 0020: product-master MCP client (read-only) and the master-data gaps report
Status
Accepted (2026-10-07). Follows the shape of ADR 0013 (the previous upstream added to this agent) and applies ADR 0018's slug classification unchanged. Number 0019 is left to the in-flight network-inventory-planning ADR (PR #119).
Context
product-master is the fleet's owner of product master data: the
description, the handling classification (hazmat, fragile,
temperature-sensitive, oversized, high-value; DOT hazard class; temperature
class) and the physical profile (declared vs measured unit dimensions,
product-master ADR 0002). Its own ADR 0005 publishes a read-only MCP
server: cmd/mcp, Streamable HTTP on :8090 at / and /mcp, four tools,
every one annotated readOnlyHint:
| Tool | Arguments | Result |
|---|---|---|
get_product | sku | sku, description, version, classification (absent when unclassified), physical_profile |
list_products | optional limit (1..500), cursor, handling_tag, classified | items[], next_cursor (absent on the last page) |
get_product_classification | sku | handling_tags, temperature_class, dot_hazard_class, classification_source, version |
get_physical_profile | sku | declared, measured (+ measured_at, device_id), effective, effective_source, discrepancy, version |
Writes (register, classify, declare dimensions, record a measurement) are REST-only there, because their events feed other contexts' local copies.
This agent is the fleet's read-side Customer. Two operational questions
nobody answers today are "which products still have no classification?"
(every consumer of ProductClassified then handles them as untagged) and
"which products' declared dimensions are contradicted by a measurement?"
(slotting, cartonisation and travel use the effective, measured value, but
the declaration is still wrong upstream).
Decision
- Client.
internal/adapters/outbound/mcpclient/product_master.goimplementsports.ProductMasterClient(internal/ports/clients_product_master.go): exactly the four tools above, field-for-field DTO mirrors, zero/nil list arguments omitted so product-master's own defaults apply. Same resilience as every sibling client: per-call timeout, fresh session per call, no retry, no breaker. - Configuration.
PRODUCT_MASTER_MCP_ENDPOINT(chart:upstreams.productMaster.endpoint; in clusterhttp://product-master-mcp.warehouse-systems.svc.cluster.local:8090/mcp). The name follows this repo's*_MCP_ENDPOINTconvention and warehouse-infra'supstreams.<ctx>.endpoint→ env mapping, not thePRODUCT_MASTER_MCP_URLspelling used in the migration brief. Unset = disabled, fail-open: no client is built, the agent boots exactly as before,GET /master-data-gapsanswers 503 andfind_master_data_gapsis not registered. The startup log line carriesproduct_master_endpoint_configured. - Contract pinning (consumer side).
mcpclient/testdata/product_master_tools.golden.jsonis a byte-identical copy of product-master's own published registry golden (internal/adapters/inbound/mcp/testdata/tool_registry.golden.json, product-mastera0a303e). Tests fail when the golden is not exactly the four tools or any is notreadOnlyHint; when a port DTO json tag is not a published output property or a required output property is not mirrored; and the client's wire tests run against a stand-in server that registers the four tools with the golden's input and output schemas, so the SDK rejects any misspelt argument key (additionalProperties: false) and any canned result that drifts from the published shape. Refresh the golden withgit -C ../product-master show origin/develop:internal/adapters/inbound/mcp/testdata/tool_registry.golden.json. - Write-verb guard.
zerowrite.TestMCPClientsCallOnlyReadToolsnow also rejectsclassify_andrecord_(product-master's REST-only write verbs, should they ever be published), andzerowrite.TestProductMasterClientCallsOnlyPinnedToolspinsproduct_master.goto exactly the four tool names, so a non-prefixed new verb cannot slip through either.TestNoDirectDependencyOnBoundedContextslistsgithub.com/claudioed/product-master. - One decision-support use case: master-data gaps.
usecases.MasterDataGapspages throughlist_products(500 per page, at most 10 pages = 5,000 products per request) and hands the products to the pure rulepolicy.FindMasterDataGaps, which reports two kinds:unclassified: product-master returned no classification;dimension-discrepancy: product-master's owndiscrepancyflag is set; both dimension sets (andmeasured_at/device_id) are echoed. The agent never recomputes the tolerance. Only two caller inputs exist, both optional:kind(validated; an unknown value is rejected, never defaulted) andcursor(resume). It invents nothing: no threshold, no default classification, no guessed dimension.kind=unclassifiedis pushed down asclassified=false. A scan that hits the page bound sayscomplete: falseand returnsnextCursor; it never presents a partial catalogue as complete. Exposed asGET /master-data-gaps?kind=&cursor=(400 for an unknown kind or a cursor product-master rejects with a validation slug, 502 when product-master fails, 503 when not configured) and the read-only MCP toolfind_master_data_gaps.
- Not fail-open inside the use case. Unlike ADR 0013's outlook (a section of a bigger brief), this report is product-master's data and nothing else: an unreachable product-master or a failing page is an error, not an empty report.
get_product, get_product_classification and get_physical_profile are
wired, contract-tested, and not yet consumed by a use case; they are the
per-SKU drill-down for a future LLM tool allow-list entry
(product-master/<tool>) or another correlation.
Consequences
- The agent can answer "what master data is missing or contradictory" with evidence and a one-line rationale per gap, read-only.
- A product-master tool-surface change (ADR 0005 amendment) shows up here as a failing contract test the moment the golden is refreshed, naming the broken assumption, instead of as a silent decode of zero values.
- warehouse-infra needs one line to turn it on in the cluster:
productMaster = { endpoint = local.mcp_endpoint["product-master"] }interraform/ops-agent.tf(and product-master inlocal.mcp_services). That is a separate warehouse-infra change; until then the feature is off. - Repeated full scans cost up to 10
list_productscalls per request; the page bound keeps a single request bounded, and the result says when more remain.
Addendum (Phase 5.4): unconsumed tools removed
get_product, get_product_classification and get_physical_profile were
removed from the client and the port (no use case called them); the client now
implements only list_products. testdata/product_master_tools.golden.json
stays a verbatim copy of product-master's full registry, so the DTO contract
test still covers list_products, and a test pins that the client calls only
that one tool. The server still publishes all four.
Addendum: registry grew from four to eight tools (mastercase programme)
product-master's registry now publishes eight tools: the four above plus
get_pack_levels and resolve_gtin (reads, readOnlyHint) and
declare_pack_level and retire_pack_level (pack-level writes,
readOnlyHint: false; product-master ADR 0011). testdata/product_master_tools.golden.json
is again a byte-identical copy of that registry (product-master cf18289).
- The contract tests pin all eight names, require
readOnlyHint: trueon the six reads andfalseon the two writes (a flipped annotation is drift), andTestProductMaster_PinnedToolCountMatchesRegistryfails when the number of tools in the golden differs from the pinned count. - Agent behaviour is unchanged: the client still calls only
list_products. The write tools are pinned so their schemas are tracked, never so they can be called; the stand-in server traps any call to them, andzerowritenow also rejects theretire_verb prefix (declare_was already rejected). - Read "four tools, every one annotated
readOnlyHint" and "exactly the four tools" in the sections above as the original surface; the pinned set is now the eight listed here.