mtconnect_sample
Fetch recent MTConnect observations from an endpoint as a bounded snapshot or incremental stream, and resume exactly from a prior sequence when needed.
Instructions
[READ][risk=low] Recent observations — a bounded snapshot OR a bounded incremental long-poll stream. Both modes are read-only and can NEVER run unbounded.
Modes:
- snapshot (default): one /sample page of up to `count` observations. Pass
`from_sequence` for a single incremental page starting at that sequence.
- stream: set `max_samples` and/or `duration_s` to poll the agent
repeatedly, advancing by the header's nextSequence each round, until a
bound is hit. Feed the returned `next_sequence` back as `from_sequence`
to resume exactly where you stopped.
Args:
endpoint: Endpoint name from config.
count: Max observations per /sample page (1..500, capped server-side).
from_sequence: Start sequence for an incremental pull (use next_sequence
from mtconnect_current or a prior call). None = the most recent `count`.
interval_ms: Poll spacing between rounds in stream mode (0..10000; 0 =
back-to-back). Client-side spacing — NOT the agent's server-push interval.
max_samples: Total observation budget across rounds; >0 selects stream mode
(capped at 2000). 0 = snapshot.
duration_s: Wall-clock budget in seconds; >0 selects stream mode (capped 120).
Returns dict (snapshot): {endpoint, mode:'snapshot', requested_count,
from_sequence, next_sequence, first_sequence, last_sequence,
observation_count, observations:[{data_item_id, type, name, timestamp,
sequence, value}]}.
Returns dict (stream): {endpoint, mode:'stream', from_sequence, next_sequence,
observation_count, poll_count, stopped_reason, interval_ms, max_samples,
observations:[...]}.
Example (snapshot): mtconnect_sample(endpoint="vmc1", count=200).
Example (stream): mtconnect_sample(endpoint="vmc1", from_sequence=1500,
interval_ms=1000, max_samples=500, duration_s=30).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | ||
| endpoint | No | ||
| duration_s | No | ||
| interval_ms | No | ||
| max_samples | No | ||
| from_sequence | No |