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
| Tool | Annotations | Input (required unless marked optional) | Output | Use case |
|---|---|---|---|---|
get_backlog_telemetry | readOnlyHint: false, destructiveHint: true, idempotentHint: false (publishes BacklogThresholdBreached, ADR-0037) | pathId (string, non-empty) | {pathId, backlogDepth, wip, mode, overAlarmThreshold} | SampleBacklog |
get_rebalance_recommendation | readOnlyHint: false, destructiveHint: true, idempotentHint: false (publishes PathThrottled / LaborReassignmentFlagged, ADR-0037) | pathId | {pathId, action, backlogDepth, wip}; action is NoActionNeeded, ThrottleUpstream or ReassignLabor | RebalanceDecision |
release_next_work | readOnlyHint: false, destructiveHint: true, idempotentHint: false | pathId | {workUnitId, cpt, ref} of the released unit | ReleaseNextWork |
get_release_throughput_report | readOnlyHint: true, idempotentHint: false | from, 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_reportexists only whenREPORTS_BASE_URLis 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
fromandtoare required by the report tool's schema (gap fix D16):pathIdandgranularitycarryomitempty, so a call without them validates and means "all paths, hourly".TestReportTool_OnlyTheWindowIsRequiredpins the schema, and the architecture fitness testTestMCPOptionalToolInputsCarryOmitemptyfails on any tool input described as optional whosejsontag lacksomitempty.fromandtomust be non-empty. - The two telemetry tools publish events, so they are not read-only
(ADR-0037):
get_backlog_telemetry(and the resource below) runSampleBacklog, which publishesBacklogThresholdBreachedwhen the pool is over its alarm threshold — the same asGET /paths/{pathId}/telemetry.get_rebalance_recommendationpublishesPathThrottled/LaborReassignmentFlaggedon aThrottleUpstream/ReassignLaboranswer. Both are annotatedreadOnlyHint: false,destructiveHint: true(governance charter §4.2: a non-read-only tool is destructive) andidempotentHint: 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_workapplies the release policy: earliest CPT first, rejected when the path has no pool, the pool is empty or aReleaseFedpool 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).WorkReleasedgoes through the same publisher contract as REST (outbox rows in Postgres, drained to Kafka by thecmd/wesrelay), and thewes.work_units.releasedcounter is incremented.- An empty
pathIdis 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 attributemcp.tool.name.
Resource template
| URI template | MIME type | Content |
|---|---|---|
telemetry://{pathId}/backlog | application/json | the same JSON as get_backlog_telemetry for that path |
A URI that does not match telemetry://<one segment>/backlog is rejected.
Prompt
| Prompt | Purpose |
|---|---|
balance_flow | standard 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=truedeploys<release>-mcp(Service port 8090, probes on/healthz).mcp.eventPublisher(empty = inheritconfig.eventPublisher) andmcp.reportsBaseUrl(empty = this release's reports Service whenanalytics.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.