Skip to main content
Glama

session_read

Read-onlyIdempotent

Read incremental output and terminal state from an owned session without sending input or stopping the process; use cursor offsets and wait_ms to poll for new output or completion.

Instructions

Read incremental output and terminal state for an owned session. This does not send input or stop the process. Start with cursor=0, then use the returned next_cursor on each read; cursors are byte offsets, not character counts. wait_ms is 0-20000 (default 0): return immediately for new output or a terminal state, otherwise wait up to that many milliseconds. Empty output with done=false is only a polling timeout; continue polling. If older output was dropped from the 1 MiB buffer, truncated=true and reading resumes at the earliest retained byte; a cursor beyond available output is an error. done=true means a terminal result or a closed connection; only then are exit_code, timed_out, canceled and optional error included. A disconnect error is not proof of a remote command's success or confirmed cancellation. Use session_stop to terminate and session_write to supply input. Finished records expire after 30 minutes and server restarts invalidate them.

Input Schema

NameRequiredDescriptionDefault
cursorNoByte cursor, initially 0
wait_msNoWait up to this many milliseconds for output
session_idYesSession identifier
client_tokenYesTarget client connection token, required with management access (including stdio and no-password mode). Device-scoped bearer access implicitly selects its own token.

Output Schema

NameRequiredDescriptionDefault
doneYesWhether the session has reached a terminal state. When false, keep polling session_read.
errorNoOptional execution or connection error. A disconnect does not prove the remote process completed successfully.
outputYesCombined terminal output from the requested cursor; may contain echoed input.
canceledNoTrue only when the target reported cancellation; a disconnect alone does not confirm cancellation.
exit_codeNoReported process exit code: 0 means success; -1 means execution failed, was interrupted, or the device disconnected before a normal exit report.
timed_outNoTrue if the target reported that the process execution timeout elapsed.
truncatedYesTrue if output exceeded the 1 MiB retention limit. Commands discard excess captured output; sessions discard older buffered bytes.
session_idYesIdentifier of the owned session; retain it for subsequent read, write and stop calls.
next_cursorYesOutput byte offset to pass as cursor on the next session_read.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.3.1-stdio.2
    • changedInput schema / properties / client_token / description
      Previous value: -"Target client connection token (required when authenticated with the management key)"New value: +"Target client connection token, required with management access (including stdio and no-password mode). Device-scoped bearer access implicitly selects its own token."
    • changedOutput schema / additionalProperties
      Previous value: -trueNew value: +false
    • addedOutput schema / properties
      Added value: +{
      +  "canceled": {
      +    "description": "True only when the target reported cancellation; a disconnect alone does not confirm cancellation.",
      +    "type": [
      +      "null",
      +      "boolean"
      +    ]
      +  },
      +  "done": {
      +    "description": "Whether the session has reached a terminal state. When false, keep polling session_read.",
      +    "type": "boolean"
      +  },
      +  "error": {
      +    "description": "Optional execution or connection error. A disconnect does not prove the remote process completed successfully.",
      +    "type": "string"
      +  },
      +  "exit_code": {
      +    "description": "Reported process exit code: 0 means success; -1 means execution failed, was interrupted, or the device disconnected before a normal exit report.",
      +    "type": [
      +      "null",
      +      "integer"
      +    ]
      +  },
      +  "next_cursor": {
      +    "description": "Output byte offset to pass as cursor on the next session_read.",
      +    "type": "integer"
      +  },
      +  "output": {
      +    "description": "Combined terminal output from the requested cursor; may contain echoed input.",
      +    "type": "string"
      +  },
      +  "session_id": {
      +    "description": "Identifier of the owned session; retain it for subsequent read, write and stop calls.",
      +    "type": "string"
      +  },
      +  "timed_out": {
      +    "description": "True if the target reported that the process execution timeout elapsed.",
      +    "type": [
      +      "null",
      +      "boolean"
      +    ]
      +  },
      +  "truncated": {
      +    "description": "True if output exceeded the 1 MiB retention limit. Commands discard excess captured output; sessions discard older buffered bytes.",
      +    "type": "boolean"
      +  }
      +}
    • addedOutput schema / required
      Added value: +[
      +  "session_id",
      +  "output",
      +  "next_cursor",
      +  "truncated",
      +  "done"
      +]
  2. First observedv0.3.1-stdio.1

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, and the description adds behavior well beyond them: 1 MiB buffer truncation with truncated=true, cursors as byte offsets, out-of-range cursor is an error, done=true gating which fields appear, and that a disconnect error is not proof of success or confirmed cancellation. Lifecycle constraints (30-minute expiry, restart invalidation) are also disclosed.

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 essentially waste-free, and front-loaded with the purpose and the negative boundary before the cursor/wait mechanics. It is a long single paragraph, so the polling, truncation, and expiry rules run together; light structuring would make it easier to scan, but no sentence is filler.

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?

An output schema exists, so return values need not be enumerated, yet the description still explains when exit_code/timed_out/canceled/error appear. For a 4-parameter, stateful read tool with cursor and timeout subtleties, everything needed to call it correctly and interpret edge cases is present.

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 genuinely adds meaning: cursor is a byte offset not a character count, must start at 0 and be chained from next_cursor, and an over-range cursor errors. wait_ms gains the 0-20000 range, default 0, and the semantic distinction between immediate return and waiting for new output or a terminal state.

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 and resource ('Read incremental output and terminal state for an owned session') and immediately draws the boundary against siblings: 'This does not send input or stop the process.' An agent can distinguish it from session_write and session_stop without inspecting any 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?

Explicit invocation protocol: 'Start with cursor=0, then use the returned next_cursor on each read', plus the polling rule ('Empty output with done=false is only a polling timeout; continue polling'). It also names the alternatives and when to use them: 'Use session_stop to terminate and session_write to supply input.'

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