Skip to content

NATS and metrics tools of the Flows MCP server ​

The 7 tools that read what happens around the flows: the messages on the controller's NATS server, recorded and live, and the resource usage of the machine over time. All of them are read-only. How to connect, and how results and errors come back, is in Flows MCP server.

They read from pilot, the controller module that records the NATS traffic and samples the resource usage of the host and its containers. They are registered unless the MCP server module is configured without pilot. When pilot does not answer, they say so; it may still be starting, so retry after a moment.

To find the cause of a delay or a timeout: nats-overview, then nats-stats on the suspicious subjects to spot gaps and rate changes, then nats-query around the moment to read the sequence of messages, and metrics-stats and metrics-query around the same moment to see whether the machine was saturated. nats-watch shows what flows right now.

Shared rules:

  • Times can be given as RFC 3339 with an offset (2026-09-23T10:30:00+02:00), epoch milliseconds, a time relative to now (now, -15m, -2h, -1d, 2h ago) or a local time of the controller (2026-09-23 10:30, or 10:30:05.250 for today). Answers print controller-local times with milliseconds and state the time zone once. The zone is the one pilot reports, or the one configured for the module, or the controller's.
  • Patterns. Subjects and series names are dotted: * matches one token and > the rest, as in NATS (app.*.status, app.>, container.*.cpu). Tokens are split on . only.
  • Size. Every answer is capped at 30 000 characters; a note says what was left out. Narrow the window or the subjects, or page with the cursor.

NATS ​

The message time ts is the moment the NATS server received the message, when the message carries it, otherwise the moment pilot received it. Payloads are not interpreted: the previews are compacted to one line (JSON without spaces, binary data as hex) and cut at maxChars.

nats-overview ​

Start here for anything about NATS. One call returns the pilot version, the state of its NATS connection, the state of the recording (mode, written and dropped messages, excluded subjects, retention), the time span of the recorded history, the controller's time zone, and a table of subjects: from the history over window (count, rate per second, typical and maximum interval between messages, largest gap, last seen) and from the live traffic (rate over the last 10 seconds, total since pilot started).

ParameterTypeRequiredMeaning
subjectFilterstringnoOnly subjects matching this pattern
windowtimenoStart of the history window; it ends now. Default -24h
limitinteger, 1 to 500noSubjects listed, busiest first. Default 50

On an older pilot without statistics of its own, the history columns are counts over the whole recorded history, and window does not apply; the answer says so.

nats-stats ​

Statistics of the recorded traffic over a window, without listing the messages: the fastest way to find delays and anomalies. Per group (by default, per subject): count, bytes, rate per second, the interval between messages (minimum, p50, p90, p99, maximum, mean), and the largest gaps, each with the time it ended, to pass as around to nats-query.

ParameterTypeRequiredMeaning
subjectsarray of patterns, up to 50noOnly these subjects. Default all
fromtimenoStart of the window. Default: one hour before to
totimenoEnd of the window. Default now
textstringnoOnly messages whose payload text or subject contains this, in any letter case
regexstringnoOnly messages whose payload text matches this RE2 regular expression
wherearray of conditionsnoSee Conditions
groupstringnoWhat to group by: $source (the subject, default), $size, or a path of the message such as payload.status
bucketstringnoAlso a count per time bucket for each group: 10s, 1m, 15m, 1h. At most 2000 buckets over the window
gapsinteger, 0 to 50noLargest gaps listed per group. Default 5
valuestringnoA numeric path (payload.<field> or $size) to get its minimum, maximum, mean and percentiles
limitinteger, 1 to 2000noGroups returned, largest count first. Default 50

How to read it: a p99 far above the p50, or a maximum gap far above the p50, is jitter or a stall; a bucket with a count of 0 is an outage. On an older pilot without statistics of its own, the server computes them from the recorded messages within a time and size budget, and marks the result as partial when the budget runs out: narrow the window then.

nats-query ​

The recorded messages as a compact sequence: one line per message with the local time, the subject, the size, Δ (milliseconds since the previous message of the result, so a delay reads directly), with around also @ (milliseconds from the anchor), and then the payload or only the fields chosen.

ParameterTypeRequiredMeaning
subjectsarray of patterns, up to 50noOnly these subjects. Default all
fromtimenoStart of the window. Default: one hour before to
totimenoEnd of the window. Default now
aroundtime or cursornoInstead of from and to: the window is this moment plus and minus windowMs. Typical: the end of a gap found by nats-stats
windowMsinteger, 1 to 3600000noHalf the width of the around window. Default 1000
textstringnoAs in nats-stats
regexstringnoAs in nats-stats
wherearray of conditionsnoSee Conditions
orderdesc or ascnodesc (default) newest first; asc oldest first. around is always asc
limitinteger, 1 to 500noMessages per call. Default 50
cursorstringnoThe cursor of a previous answer, to get the next page. Pass the same filters
fieldsarray of paths, up to 30noShow only these paths of each message, such as payload.status or headers.Nats-Origin-IP, instead of the payload
maxCharsinteger, 20 to 20000noLength of the payload preview per message. Default 400
formatlines or jsonnolines (default) or one JSON object per message, with the payload parsed

When more messages match, the header gives a cursor for the next page; the window and the order travel inside it.

nats-watch ​

The live traffic: what flows on NATS right now, for up to seconds or until maxMessages, with the same filters as nats-query and the same line format. It includes request and reply traffic on _INBOX subjects, which is never recorded. The call blocks for the whole time, so keep seconds small.

ParameterTypeRequiredMeaning
subjectsarray of patterns, up to 50noOnly these subjects. Default all
textstringnoAs in nats-stats
regexstringnoAs in nats-stats
wherearray of conditionsnoSee Conditions
secondsnumber, 1 to 30noHow long to watch. Default 5
maxMessagesinteger, 1 to 1000noStop after this many messages. Default 100
fieldsarray of paths, up to 30noAs in nats-query
maxCharsinteger, 20 to 20000noAs in nats-query

Conditions ​

where takes up to 20 conditions, which must all hold:

FieldTypeRequiredMeaning
pathstringyespayload.<field> (the payload parsed as JSON, for example payload.meta.count), headers.<Name>, $size, $source or $text
opeq, neq, contains, ncontains, exists, gt or ltyesgt and lt compare numbers
valuestring, number or booleannoNot needed with exists

Example: [{"path": "payload.status", "op": "eq", "value": "ok"}, {"path": "$size", "op": "gt", "value": 1000}].

Metrics ​

The resource history of the controller: host CPU (total, I/O wait, per core), load, memory, swap, GPU use, memory and temperature, temperature sensors, disks, network and running tasks; the same per container (container.<name>.cpu, container.<name>.mem…), the processes outside containers, and the busiest processes. The series names are the ones pilot found on that machine: read them with metrics-overview before querying. The metrics tools need pilot 1.3.0 or later; with an older pilot they answer that it has no metrics history.

Recent windows are answered from the raw samples; windows older than the raw samples kept come from 1-minute summaries, and the answer says which.

metrics-overview ​

Start here. Returns the pilot version, the sampling intervals of the host and of the containers, how far back the raw samples and the 1-minute summaries go, which sources exist on the controller (host, GPU, containers), the time zone, and the list of series grouped (host, one line per container, processes outside containers) with their last value and unit.

ParameterTypeRequiredMeaning
matchstringnoOnly series matching these patterns, separated by commas, such as cpu.*,container.*.cpu. Default all
limitinteger, 1 to 2000noSeries listed. Default 400

metrics-stats ​

A summary of each series over a window: minimum, average, p50, p95, p99, maximum and when the maximum happened, and the number of samples. With above, also how long and when the series was above that threshold. Grouped by unit (percent, temperature, bytes, bytes per second, other). Exact on raw samples; marked approximate when it comes from the 1-minute summaries.

ParameterTypeRequiredMeaning
seriesarray of patterns, up to 50noDefault all (>)
fromtimenoStart of the window. Default: one hour before to
totimenoEnd of the window. Default now
aroundtimenoInstead of from and to: this moment plus and minus windowMs
windowMsinteger, 1000 to 21600000noHalf the width of the around window. Default 30000
abovenumbernoA threshold in the base unit of the series: % for percentages, bytes for memory, bytes per second for rates, °C. Use it with series of one unit
sortmax, p99, p95, avg, above or namenoOrder within each unit group. Default max. above needs a threshold
limitinteger, 1 to 500noSeries listed per unit group. Default 20

How to read it: a p99 or maximum near 100 % on CPU or GPU, swap growing, available memory near zero, or a container whose maximum falls on the moment of the problem, is the likely cause.

metrics-query ​

The values of series over time. For a long window, one block per series: a summary (peak and its time, low, last) and a line of numbers per aggregation, in a unit given once. For around and short windows, a table: one row per local time, with its offset from the anchor, one column per series, and the anchor row marked.

ParameterTypeRequiredMeaning
seriesarray of patterns, up to 50noDefault: cpu.total, cpu.iowait, load.1, mem.available, swap.used, gpu.util, gpu.mem.used (series the machine does not have are left out)
fromtimenoStart of the window. Default: one hour before to
totimenoEnd of the window. Default now
aroundtimenoInstead of from and to: this moment plus and minus windowMs
windowMsinteger, 1000 to 21600000noHalf the width of the around window. Default 30000
stepstringnoauto (default): raw samples when they fit in maxPoints, otherwise time buckets; or a bucket length from 1 second to 24 hours, such as 1s, 10s, 1m, 15m
aggarray of avg, min, max, lastnoAggregation per bucket. Default avg; max shows short spikes an average hides
maxPointsinteger, 10 to 5000noPoints per series. Default 120
layoutauto, lines or tablenoDefault auto: a table for around or for up to 40 points, when it has at most 12 columns (series times aggregations); lines otherwise