Skip to main content

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. node-performance had none: its two reads (GetScorecard, ListScorecardsByGrade) were reachable only over REST. The service already has the read use cases behind its REST adapter, so an MCP adapter is another driving adapter over them, not new domain.

Decision​

  • A second driving adapter, a separate binary. internal/adapters/inbound/mcp is built on the official MCP Go SDK (github.com/modelcontextprotocol/go-sdk v1.8.0) and served over Streamable HTTP only (no stdio, no SSE) by cmd/mcp, mounted at /mcp and / with an open /healthz. It is a second deployable beside cmd/api; the Helm chart gets an mcp Deployment, Service and (off by default) Gateway API HTTPRoute, all behind mcp.enabled.
  • Two read tools over the existing queries, nothing else. get_scorecard(nodeId) and list_scorecards_by_grade(grade, window?, limit?, after?) — one per read operation of apis/openapi.yaml. 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. Observations are recorded by cmd/api's consumers and grades are computed by its recompute scheduler; neither is reachable from here.
  • Read-only is structural. The adapter's Deps holds the two read use cases (the same interfaces the REST adapter calls) and nothing that can write; the adapter and cmd/mcp import no outbox, no event sink, no Kafka adapter and no scheduler. cmd/mcp never dials Kafka and never runs the consumers or the relay. internal/architecture's TestMCPAdapterDependencyRule pins the imports (and that nothing else may depend on the adapter); TestToolSurface pins the exact tool set (budget 2), the read-only annotations and the absence of write verbs in tool names; TestToolRegistryGolden pins the whole advertised registry; the integration test proves the binary reads what the write path persisted in a real Postgres and adds no outbox row.
  • 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; TestNoAuthMiddlewareReintroduced). Access control is the in-cluster ClusterIP boundary.
  • Boot. DATABASE_URL is mandatory (no in-memory mode); like cmd/api, the binary runs the idempotent embedded migrations on start (with MIGRATIONS_DATABASE_URL for a direct DSN behind PgBouncer) so it can start against a fresh database before cmd/api has. MCP_ADDR (default :8090), LOG_LEVEL, SERVICE_VERSION and ENVIRONMENT complete the environment; the Postgres dial is wrapped in the shared boot retry.

Consequences​

  • Agents can answer "which nodes currently hold grade D", "how did N-0042's 30-day window move" without REST glue, over the same queries the REST adapter serves.
  • 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).
  • Grading stays with the service itself: the write path (consumers, scheduler, transactional outbox) never moves behind the MCP surface.