ADR 0008: 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. node-topology had none. The service already has the read
use cases behind its REST adapter (GetNode, ListNodes, ListLanes,
ResolveServiceArea, GetRegion, ListRegions — the Open Host Service reads
of ADR 0003), 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/healthz. It is a second deployable besidecmd/api; the Helm chart gets an mcp Deployment and Service (default off) and an optional gateway HTTPRoute at/api/mcp/node-topology. - Six read tools over the existing queries, nothing else — one per read GET
of apis/openapi.yaml.
get_node(nodeId),list_nodes(type?, regionId?, status?),list_lanes(origin?, destination?),resolve_service_area(postalPrefix),get_region(regionId)andlist_regions(). Arguments and results are lowerCamelCase like the REST contract (list_regionsreturns its array under aregionskey so a tool's structured content is always an object); typed errors carry the REST problem slug (not-found,validation-failed) as the prefix of the tool error. Registering a node, declaring a profile revision, the lifecycle transitions, opening/closing lanes, assigning service areas and defining regions stay REST-only. - Read-only is structural. The adapter's
Depsholds the six read use cases and nothing that can write;cmd/mcpimports no event sink, no outbox writer, no Kafka adapter and never dials Kafka (this service consumes no topic anyway): the relay runs incmd/apionly.TestToolSurfacepins the exact tool set (budget 6), the read-only annotations and the absence of write verbs in tool names;TestToolRegistryGoldenpins the whole advertised registry; 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 carry,omitemptyso the SDK publishes them as optional (internal/architecture/mcp_optional_inputs_test.go). - 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). 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 (withMIGRATIONS_DATABASE_URLfor a direct DSN behind PgBouncer), wrapped in the samebootretrybudget ascmd/api, so it can start against a fresh database beforecmd/apihas.MCP_ADDR(default:8090),LOG_LEVEL,SERVICE_VERSIONandENVIRONMENTcomplete the environment.
Consequences
- Agents can answer "which nodes are ACTIVE in region X", "what profile does this fulfilment centre hold", "which station serves postal prefix 013" 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).
- Writes stay REST operations with the
Idempotency-Keymiddleware and the transactional outbox; the MCP surface cannot reach them at all.