Skip to main content

MCP tools, resources and prompts

cmd/mcp is a separate binary serving the Model Context Protocol over Streamable HTTP only (github.com/modelcontextprotocol/go-sdk v1.8.0), as an inbound adapter over the same use cases as the REST API (ADR-0008). It listens on MCP_ADDR (default :8090) and mounts the MCP endpoint at both / and /mcp; GET /healthz answers {"status":"ok"} for the probes. The surface is unauthenticated (ADR-0016); keep it in-cluster. Server name wes-work-planning-mcp, version 1.0.0.

The tool list below was captured from a live tools/list against a local build (MCP_ADDR=127.0.0.1:18190, REPORTS_BASE_URL set); the registry is also pinned by internal/adapters/inbound/mcp/testdata/tool_registry.golden.

Tools​

ToolAnnotationsInput (required unless marked optional)OutputUse case
get_backlog_telemetryreadOnlyHint: false, destructiveHint: true, idempotentHint: false (publishes BacklogThresholdBreached, ADR-0037)pathId (string, non-empty){pathId, backlogDepth, wip, mode, overAlarmThreshold}SampleBacklog
get_rebalance_recommendationreadOnlyHint: false, destructiveHint: true, idempotentHint: false (publishes PathThrottled / LaborReassignmentFlagged, ADR-0037)pathId{pathId, action, backlogDepth, wip}; action is NoActionNeeded, ThrottleUpstream or ReassignLaborRebalanceDecision
release_next_workreadOnlyHint: false, destructiveHint: true, idempotentHint: falsepathId{workUnitId, cpt, ref} of the released unitReleaseNextWork
get_release_throughput_reportreadOnlyHint: true, idempotentHint: falsefrom, to (RFC3339, [from, to)); optional pathId, granularity{rows: [{pathId, hourBucket, workReleased, workUnitCompleted, backlogThresholdBreached, pathThrottled, rateDeviationDetected}]} (rateDeviationDetected is reserved, always 0)calls GET /reports/throughput on cmd/wes-reports (apis/openapi-reports.yaml)

Behaviour worth knowing:

  • Registered conditionally: get_release_throughput_report exists only when REPORTS_BASE_URL is set; it never opens the analytical database (ADR-0011). Its HTTP client has a 10 s timeout; a non-2xx from the reports service becomes a tool error.
  • Only from and to are required by the report tool's schema (gap fix D16): pathId and granularity carry omitempty, so a call without them validates and means "all paths, hourly". TestReportTool_OnlyTheWindowIsRequired pins the schema, and the architecture fitness test TestMCPOptionalToolInputsCarryOmitempty fails on any tool input described as optional whose json tag lacks omitempty. from and to must be non-empty.
  • The two telemetry tools publish events, so they are not read-only (ADR-0037): get_backlog_telemetry (and the resource below) run SampleBacklog, which publishes BacklogThresholdBreached when the pool is over its alarm threshold — the same as GET /paths/{pathId}/telemetry. get_rebalance_recommendation publishes PathThrottled / LaborReassignmentFlagged on a ThrottleUpstream / ReassignLabor answer. Both are annotated readOnlyHint: false, destructiveHint: true (governance charter §4.2: a non-read-only tool is destructive) and idempotentHint: false, and their descriptions name the event, so a host that asks for confirmation before a non-read-only call asks here too.
  • release_next_work applies the release policy: earliest CPT first, rejected when the path has no pool, the pool is empty or a ReleaseFed pool is at its WIP limit. The domain error text is returned as the tool error (not found, no pending work in this pool, release-fed pool WIP limit reached). WorkReleased goes through the same publisher contract as REST (outbox rows in Postgres, drained to Kafka by the cmd/wes relay), and the wes.work_units.released counter is incremented.
  • An empty pathId is rejected before any use case runs: invalid pathId "": must be a non-empty process path id.
  • Every call runs inside an OTel span mcp.tool <name> with attribute mcp.tool.name.

Resource template​

URI templateMIME typeContent
telemetry://{pathId}/backlogapplication/jsonthe same JSON as get_backlog_telemetry for that path

A URI that does not match telemetry://<one segment>/backlog is rejected.

Prompt​

PromptPurpose
balance_flowstandard operating procedure: read telemetry, apply the rebalance recommendation, release only on a healthy or under-fed path, and escalate when a path stays over threshold or keeps hitting the WIP limit

Trying it​

The server is plain JSON-RPC over HTTP: initialize, then reuse the returned Mcp-Session-Id header.

# needs the same Postgres (already migrated by cmd/wes) and Kafka as cmd/wes
DATABASE_URL="postgres://wes:***@localhost:5432/wes?sslmode=disable" \
KAFKA_BROKERS=localhost:9092 go run ./cmd/mcp # :8090

curl -si localhost:8090/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
# -> 200, header Mcp-Session-Id: <id>, an SSE "data:" line with the result

curl -s localhost:8090/mcp -H 'Mcp-Session-Id: <id>' \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}' # 202

curl -s localhost:8090/mcp -H 'Mcp-Session-Id: <id>' \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

cmd/mcp has no stores of its own: DATABASE_URL and KAFKA_BROKERS are mandatory (boot errors that name the variable, ADR-0044), and it reads and writes the same Postgres as cmd/wes. get_backlog_telemetry answers not found until the path has a pool in that database.

Deployment notes​

  • Chart: mcp.enabled=true deploys <release>-mcp (Service port 8090, probes on /healthz). mcp.eventPublisher (empty = inherit config.eventPublisher) and mcp.reportsBaseUrl (empty = this release's reports Service when analytics.enabled) feed the container.
  • One replica only: Streamable HTTP sessions live in the process's memory, so the chart deliberately has no HPA for MCP (ADR-0025).
  • Configuration: MCP variables.
  • Governance rules every fleet MCP server follows: MCP governance charter.