Skip to main content

MCP tools

cmd/mcp is a Model Context Protocol server over Streamable HTTP only (no stdio, no SSE endpoint of its own), served at /mcp and / on MCP_ADDR (default :8090). It drives the same use cases as the REST API. It is unauthenticated like the rest of the fleet (TestNoAuthMiddlewareReintroduced guards it): access control is the in-cluster boundary. The Kong route, when enabled, is /api/mcp/dock-scheduling rewritten to /mcp. The server is disabled by default in the chart (mcp.enabled=false).

Source: internal/adapters/inbound/mcp/tools.go, tools_read.go, tools_write.go, resources.go, prompts.go, authority.go, ADR 0007.

This page is written from the tool registrations in the code, not from a captured tools/list response; the speed rules for this site forbid running the binary. TestMCPSurfaceSensorBites and TestEveryMCPToolDeclaresAuthority in internal/architecture guard the registrations.

Every tool declares an authority level in its _meta under com.warehouse/authority: L1 reads facts and changes nothing; L3 changes state, with a human confirmation held by the client and an attributable change (TestMCPWriteToolsAreAtLeastL3). Calendar settings, closures, operating hours and the no-show sweep are planner or cron operations and stay on REST: they are not tools.

Outputs mirror the REST bodies (camelCase, UTC RFC 3339 times, null for an absent optional value). A failing tool answers with the REST problem slug and detail (for example door-double-booked); infrastructure detail is never echoed.

Read tools (L1, readOnlyHint: true)​

ToolInput fieldsReturns
list_appointmentsall optional: siteId, doorCode, state (BOOKED, CHECKED_IN, COMPLETED, CANCELLED, NO_SHOW), direction (INBOUND, OUTBOUND), carrierScac, atRisk (true lists only at-risk), from, to (RFC 3339; windows overlapping [from, to)), limit (1..500, default 100), cursorA page {items, nextCursor} ordered by window start.
get_appointmentappointmentId (appt-<uuid>, required)One appointment: door, window, carrier, ASNs or CPT/shipment references, state, latest ETA, arrival, atRisk with cause, and the version to pass as expectedVersion.
get_door_availabilitydoorCode, from, to (required; at most 14 days), minutes (optional, 1..240, default the site's slot granularity)freeWindows and busy spans of the door; free windows respect operating hours and closures.
get_dock_calendarsiteId (required)Settings with defaults applied, operating hours (none declared = open 24x7) and active closures.
list_carriersall optional: status (ACTIVE or SUSPENDED), limit (1..500), cursorThe carrier registry ordered by SCAC, paged: scac, name, usdot, mc, status, suspensionReason, suspendedAt, version (ADR 0012).
get_carrierscac (required)One registered carrier and the version to pass as expectedVersion. A SCAC that is not registered is carrier-not-found, which does not mean it cannot book: an unregistered SCAC is accepted.
list_at_risk_appointmentsoptional siteId, limit, cursorBOOKED appointments flagged at risk (cause LATE_ETA or DOOR_REASSIGNED_OVERLAP), paged. Advisory: nothing reschedules automatically.

Write tools (L3, readOnlyHint: false, idempotent)​

Every write tool takes idempotencyKey (required, 1..128 printable ASCII; retry with the same key and arguments to get the stored answer, never a second write) and the optional attribution fields proposalId, approvedBy, agentId (each at most 128 characters), recorded on the write and logged as mcp write. Every answer is {appointment, atRisk, initiatedBy, replayed}: replayed is true when the stored answer of an earlier call was returned; atRisk is meaningful for report_eta only. The three carrier write tools answer {carrier, created, initiatedBy, replayed} instead (created is true for register_carrier only, when this call created the carrier).

ToolAnnotationsInput fieldsEffect
book_appointmentdestructiveHint: false, idempotentHint: truedirection, doorCode, carrier, windowStart, windowEnd, idempotencyKey (required); carrierScac, asnNumbers, cptId, shipmentRefs, expectedSealNumber (optional)Books a door window. INBOUND needs at least one known, not cancelled ASN; OUTBOUND a known cptId or shipmentRefs. Same checks as POST /appointments.
reschedule_appointmentdestructiveHint: true, idempotentHint: trueappointmentId, windowStart, windowEnd, idempotencyKey (required); doorCode (omit to keep the door), expectedVersionMoves a BOOKED appointment; refused with precondition-failed when expectedVersion is stale.
cancel_appointmentdestructiveHint: true, idempotentHint: trueappointmentId, reason (CARRIER_REQUEST or SITE_REQUEST), idempotencyKey (required); expectedVersionCancels a BOOKED or CHECKED_IN appointment and frees the window. Other reasons are set by policies, never by a caller.
register_carrierdestructiveHint: false, idempotentHint: truescac, name, idempotencyKey (required); usdot (1..8 digits), mc (1..8 digits, optional MC or MX prefix), attributionPuts a carrier in the registry, ACTIVE; the same data again answers it with created: false, other data on a registered SCAC is carrier-already-registered (changing a carrier is REST only). Raises CarrierRegistered.
suspend_carrierdestructiveHint: false, idempotentHint: truescac, reason, idempotencyKey (required); expectedVersion, attributionSuspends a carrier: a booking or reschedule naming its SCAC is then refused with carrier-suspended. Appointments it already holds are not cancelled. Raises CarrierSuspended.
reinstate_carrierdestructiveHint: false, idempotentHint: truescac, idempotencyKey (required); expectedVersion, attributionLets a suspended carrier book again. Raises CarrierReinstated.
report_etadestructiveHint: false, idempotentHint: trueappointmentId, etaAt, idempotencyKey (required); source (at most 64 characters, default mcp)Records the carrier's latest ETA on a BOOKED appointment; a late ETA flags it at risk once for this report. Nothing is rescheduled.

An appointment's arrival, check-in and door release are never tools: they are facts applied from the yard.

Resources​

Scoped read models (L1 by nature, JSON), each backed by the same use case as the matching tool:

URI templateContent
dock://sites/{siteId}/calendarOne site's dock calendar.
dock://sites/{siteId}/at-riskThe first page (100) of the site's at-risk appointments.
dock://appointments/{appointmentId}One appointment.

Prompts​

PromptPurpose
plan_dock_bookingProcedure for booking or moving a carrier visit: read the calendar rules, find a free door window, check the ASN is on no other appointment, confirm with a person, book with an idempotency key, read the typed refusals.
triage_at_risk_appointmentsProcedure for at-risk appointments: read the cause, compare the ETA with the window, propose a concrete reschedule, wait for confirmation, escalate when no ETA was reported.

Operating notes​

  • cmd/mcp starts no outbox relay and no consumer. Its writes enqueue outbox rows that the relay of cmd/api (or cmd/relay) drains; keep one running.
  • It needs DATABASE_URL and KAFKA_BROKERS (for /readyz) and applies the embedded migrations at boot. See Configuration.
  • The MCP server is not HPA-scalable: the Streamable HTTP handler keeps per-process session state.
  • Tool calls are wrapped in an mcp.tool <name> span through the global OTel tracer; no provider is installed, so spans are not exported (see Observability).