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, or10:30:05.250for 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).
| Parameter | Type | Required | Meaning |
|---|---|---|---|
subjectFilter | string | no | Only subjects matching this pattern |
window | time | no | Start of the history window; it ends now. Default -24h |
limit | integer, 1 to 500 | no | Subjects 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.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
subjects | array of patterns, up to 50 | no | Only these subjects. Default all |
from | time | no | Start of the window. Default: one hour before to |
to | time | no | End of the window. Default now |
text | string | no | Only messages whose payload text or subject contains this, in any letter case |
regex | string | no | Only messages whose payload text matches this RE2 regular expression |
where | array of conditions | no | See Conditions |
group | string | no | What to group by: $source (the subject, default), $size, or a path of the message such as payload.status |
bucket | string | no | Also a count per time bucket for each group: 10s, 1m, 15m, 1h. At most 2000 buckets over the window |
gaps | integer, 0 to 50 | no | Largest gaps listed per group. Default 5 |
value | string | no | A numeric path (payload.<field> or $size) to get its minimum, maximum, mean and percentiles |
limit | integer, 1 to 2000 | no | Groups 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.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
subjects | array of patterns, up to 50 | no | Only these subjects. Default all |
from | time | no | Start of the window. Default: one hour before to |
to | time | no | End of the window. Default now |
around | time or cursor | no | Instead of from and to: the window is this moment plus and minus windowMs. Typical: the end of a gap found by nats-stats |
windowMs | integer, 1 to 3600000 | no | Half the width of the around window. Default 1000 |
text | string | no | As in nats-stats |
regex | string | no | As in nats-stats |
where | array of conditions | no | See Conditions |
order | desc or asc | no | desc (default) newest first; asc oldest first. around is always asc |
limit | integer, 1 to 500 | no | Messages per call. Default 50 |
cursor | string | no | The cursor of a previous answer, to get the next page. Pass the same filters |
fields | array of paths, up to 30 | no | Show only these paths of each message, such as payload.status or headers.Nats-Origin-IP, instead of the payload |
maxChars | integer, 20 to 20000 | no | Length of the payload preview per message. Default 400 |
format | lines or json | no | lines (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.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
subjects | array of patterns, up to 50 | no | Only these subjects. Default all |
text | string | no | As in nats-stats |
regex | string | no | As in nats-stats |
where | array of conditions | no | See Conditions |
seconds | number, 1 to 30 | no | How long to watch. Default 5 |
maxMessages | integer, 1 to 1000 | no | Stop after this many messages. Default 100 |
fields | array of paths, up to 30 | no | As in nats-query |
maxChars | integer, 20 to 20000 | no | As in nats-query |
Conditions
where takes up to 20 conditions, which must all hold:
| Field | Type | Required | Meaning |
|---|---|---|---|
path | string | yes | payload.<field> (the payload parsed as JSON, for example payload.meta.count), headers.<Name>, $size, $source or $text |
op | eq, neq, contains, ncontains, exists, gt or lt | yes | gt and lt compare numbers |
value | string, number or boolean | no | Not 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.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
match | string | no | Only series matching these patterns, separated by commas, such as cpu.*,container.*.cpu. Default all |
limit | integer, 1 to 2000 | no | Series 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.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
series | array of patterns, up to 50 | no | Default all (>) |
from | time | no | Start of the window. Default: one hour before to |
to | time | no | End of the window. Default now |
around | time | no | Instead of from and to: this moment plus and minus windowMs |
windowMs | integer, 1000 to 21600000 | no | Half the width of the around window. Default 30000 |
above | number | no | A 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 |
sort | max, p99, p95, avg, above or name | no | Order within each unit group. Default max. above needs a threshold |
limit | integer, 1 to 500 | no | Series 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.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
series | array of patterns, up to 50 | no | Default: cpu.total, cpu.iowait, load.1, mem.available, swap.used, gpu.util, gpu.mem.used (series the machine does not have are left out) |
from | time | no | Start of the window. Default: one hour before to |
to | time | no | End of the window. Default now |
around | time | no | Instead of from and to: this moment plus and minus windowMs |
windowMs | integer, 1000 to 21600000 | no | Half the width of the around window. Default 30000 |
step | string | no | auto (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 |
agg | array of avg, min, max, last | no | Aggregation per bucket. Default avg; max shows short spikes an average hides |
maxPoints | integer, 10 to 5000 | no | Points per series. Default 120 |
layout | auto, lines or table | no | Default auto: a table for around or for up to 40 points, when it has at most 12 columns (series times aggregations); lines otherwise |