Skip to main content
Glama

sample_messages

Inspect recent ROS 2 messages from a topic to debug or analyze data. Read-only, supports live and mock modes.

Instructions

ROS 2 graph only; on a DDS-only setup use list_endpoints (topics and wiring) or peek_dds_samples on DCPSPublication / DCPSSubscription (raw discovery records). Peek up to count recent ROS 2 messages from topic. count defaults to 5 and is silently clamped to 50. Returns a SampleResult {topic, count, samples, mode_effective, note} where count is the actual number of samples returned (may be 0) and mode_effective is live or mock. Live mode runs ros2 topic echo --csv --once with a short timeout, so the result is empty when no publisher is active and at most one message comes back. Arrays: by default ros2 topic echo cuts arrays at 128 elements (a 541-beam LaserScan loses beams 128 and up); the cut is listed under _truncated_after_columns in the sample payload and in note (cut strings and bytes are listed under _truncated_columns). Raise max_array_length (up to 65536, or null for no cut) to read more, or set arrays_summary_only to see only the non-array fields. A message over the 1 MiB size cap (TOPICFORGE_MAX_SAMPLE_BYTES) is dropped and note says so. samples[i].timestamp_ns is the message's header.stamp (publish time) when the message is Header-stamped, and 0 for headerless types (e.g. std_msgs/String). The live parser exposes fields as positional CSV columns under samples[i].payload keys col_0, col_1, ..., with the verbatim CSV row under the reserved _raw_text key. Mock mode returns structured samples for the fictional demo robot. Raises an MCP error when no ros2 CLI is available. Read-only; never publishes. Distinct from peek_dds_samples, which reads the raw DDS layer.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoMaximum number of recent messages to return. Defaults to 5; silently clamped to 50 (the hard cap that keeps tool output bounded; read it from `health_check.max_sample_count`). Negative values raise an error. The returned `SampleResult.count` reflects the actual number of samples produced: it can be lower than the request (empty topic, timeout, mock fixture shorter than requested).
topicYesFully qualified ROS2 topic name starting with `/`, e.g. `/cmd_vel` or `/camera/image_raw`. Each `/`-separated segment must start with a letter or underscore and contain only letters, digits, and underscores; everything else (whitespace, quotes, shell metacharacters, `//`, trailing `/`) is rejected before reaching the `ros2` CLI.
max_array_lengthNoLongest array, string or bytes value to return in full, 1..65536; longer ones are cut. A cut array is listed in the sample's `_truncated_after_columns` (index of the last kept column); a cut string or bytes value is kept as its first N characters plus `...` and listed in `_truncated_columns`. Defaults to 128, the `ros2 topic echo` default, which cuts a 541-beam `LaserScan` after 128 ranges. Pass null to return everything in full (large for images and point clouds; a message over the server's size cap, 1 MiB by default, is dropped with a note, and a very large message may not print within the echo timeout).
arrays_summary_onlyNoWhen true, array fields are replaced by a short type and length summary instead of their elements. Use it to inspect the non-array fields of large messages (images, scans, point clouds). Defaults to false.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
noteNoWhy `samples` is empty or limited, when the cause is not obvious (for example payload decoding is disabled for DDS user topics). `None` when there is nothing to add.
countYesNumber of samples actually returned. May be 0 (no publisher active in live mode, or empty mock fixture), less than the requested count (topic yielded fewer messages within the timeout), or capped by the the silent maximum of 50: request `count > 50` and you will receive at most 50 without warning.
topicYesTopic the samples were taken from, echoed from the request.
samplesYesThe sampled messages, ordered as received from the backend.
mode_effectiveYesRuntime mode the adapter served this response in: `live` (real ROS2 introspection) or `mock` (deterministic fixtures). Lets a caller tell a real graph from a demo one without calling `health_check`.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.6

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so: read-only/never publishes, live mode runs `ros2 topic echo --csv --once` so results are empty with no active publisher and capped at one message, 1 MiB size cap drops messages with a note, array cut at 128 with `_truncated_after_columns`/`_truncated_columns` markers, and an MCP error is raised when no `ros2` CLI exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Dense but front-loaded: the DDS-only routing caveat leads, then the core action, then behavior. Every sentence carries information, though the parameter-behavior detail makes it longer than strictly necessary for selection.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex sampling tool with an output schema, the description covers failure modes, mode_effective semantics, timestamp provenance, CSV positional-column payload shape, and truncation markers. Nothing an agent needs to invoke it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real semantics: `count` clamping to 50 and the fact that returned `count` may be lower than requested, and how `max_array_length`/`arrays_summary_only` change truncation behavior. It reinforces rather than merely repeats the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource+scope: 'Peek up to `count` recent ROS 2 messages from `topic`', and explicitly delimits itself from `peek_dds_samples` ('Distinct from `peek_dds_samples`, which reads the raw DDS layer'). An agent can select it without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Opens with the routing condition: ROS 2 graph only; on a DDS-only setup use `list_endpoints` or `peek_dds_samples` on `DCPSPublication`/`DCPSSubscription`. It names the alternatives and the precise condition that selects them.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.