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/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, Service and (off by default) Gateway API HTTPRoute, all behindmcp.enabled. - Two read tools over the existing queries, nothing else.
get_scorecard(nodeId)andlist_scorecards_by_grade(grade, window?, limit?, after?)— one per read operation ofapis/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 bycmd/api's consumers and grades are computed by its recompute scheduler; neither is reachable from here. - Read-only is structural. The adapter's
Depsholds the two read use cases (the same interfaces the REST adapter calls) and nothing that can write; the adapter andcmd/mcpimport no outbox, no event sink, no Kafka adapter and no scheduler.cmd/mcpnever dials Kafka and never runs the consumers or the relay.internal/architecture'sTestMCPAdapterDependencyRulepins the imports (and that nothing else may depend on the adapter);TestToolSurfacepins the exact tool set (budget 2), 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 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_URLis mandatory (no in-memory mode); likecmd/api, the binary runs the idempotent embedded migrations on start (withMIGRATIONS_DATABASE_URLfor a direct DSN behind PgBouncer) so it can start against a fresh database beforecmd/apihas.MCP_ADDR(default:8090),LOG_LEVEL,SERVICE_VERSIONandENVIRONMENTcomplete 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.