Skip to main content
Glama

session_read

Read-onlyIdempotent

Read session output from a byte cursor. Pass command_id to reject reads after a newer command starts. Use status to check completion and drain has_more even after idle or closed.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "session_id": "<session_id>",
      "control_token": "<control_token>"
    },
    "name": "session_read"
  }
}

Input Schema

NameRequiredDescriptionDefault
cursorNoOutput byte offset, initially 0; subsequent reads accept the previous next_cursor.
wait_msNoWait up to this many milliseconds for output
client_idNoDevice ID from list_client. Required with multi-device tokens for execute_command, session_read, session_control, and p2p_transfer_start.
max_bytesNoMaximum output bytes per read. The response preserves UTF-8 character boundaries.
command_idNoOptional command identifier returned by execution; pins reads to that command. New clients generate eight alphanumeric characters; older longer IDs remain accepted.
session_idYesClient-local session identifier. Multi-device calls also require client_id.
control_tokenYesControl credential in token:key format, required with management access (including stdio and no-password mode). Scoped control bearer access implicitly selects its own token.

Output Schema

NameRequiredDescriptionDefault
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.
statusYesrunning: terminal busy or stop pending; idle: command ended and shell reusable; closed: client confirmed shell termination. Transport errors do not imply termination.
has_moreYesWhether more retained output is available after next_cursor.
exit_codeNoexecute/read/list: the latest completed command exit code, preserved when its shell later ends. stop: the confirmed shell termination code. 0 means success; -1 denotes execution failure. Transport errors never invent a code.
truncatedNoPresent only as true when the requested cursor predates the oldest retained output. The latest 1 MiB is retained; pagination alone does not truncate.
command_idYesIdentifier of the latest command. New clients generate eight case-sensitive alphanumeric characters; older clients may return longer IDs.
session_idYesClient-local session identifier. Multi-device read/control also require client_id.
next_cursorYesByte offset after the returned output. Pass it as cursor in the next session_read.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedInput schema / properties / client_id / description
      Previous value: -"Six lowercase letters or digits from list_client. Required for execute_command, session_read and session_control on multi-device tokens, including existing sessions. Session-list filtering is optional."New value: +"Device ID from list_client. Required with multi-device tokens for execute_command, session_read, session_control, and p2p_transfer_start."
    • changedInput schema / properties / max_bytes / description
      Previous value: -"Maximum output bytes per read, 4–65536; default 16384. May return fewer bytes to preserve UTF-8 boundaries. Continue with next_cursor while has_more=true."New value: +"Maximum output bytes per read. The response preserves UTF-8 character boundaries."
    • changedOutput schema / properties / has_more / description
      Previous value: -"Whether retained output remains after next_cursor; continue reading even after idle or closed."New value: +"Whether more retained output is available after next_cursor."
    • changedOutput schema / properties / next_cursor / description
      Previous value: -"Byte offset immediately after the returned output. Pass it as cursor for the next session_read. Continue while has_more=true, including after status becomes idle or closed."New value: +"Byte offset after the returned output. Pass it as cursor in the next session_read."
  2. Changed3 schema fields changed
    • removedInput schema / properties / client_token
      Removed value: -{
      -  "description": "Control credential in token:key format, required with management access (including stdio and no-password mode). Scoped control bearer access implicitly selects its own token.",
      -  "minLength": 1,
      -  "type": "string"
      -}
    • addedInput schema / properties / control_token
      Added value: +{
      +  "description": "Control credential in token:key format, required with management access (including stdio and no-password mode). Scoped control bearer access implicitly selects its own token.",
      +  "minLength": 1,
      +  "type": "string"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "session_id",
      -  "client_token"
      -]New value: +[
      +  "session_id",
      +  "control_token"
      +]
  3. Changed2 schema fields changed
    • changedInput schema / properties / command_id / description
      Previous value: -"Optional command identity returned by execute_command; rejects a snapshot if the session has advanced to another command."New value: +"Optional command identifier returned by execution; pins reads to that command. New clients generate eight alphanumeric characters; older longer IDs remain accepted."
    • changedOutput schema / properties / command_id / description
      Previous value: -"Identity of the latest submitted command."New value: +"Identifier of the latest command. New clients generate eight case-sensitive alphanumeric characters; older clients may return longer IDs."
  4. Changed8 schema fields changed
    • addedInput schema / properties / client_id
      Added value: +{
      +  "description": "Six lowercase letters or digits from list_client. Required for execute_command, session_read and session_control on multi-device tokens, including existing sessions. Session-list filtering is optional.",
      +  "pattern": "^[a-z0-9]{6}$",
      +  "type": "string"
      +}
    • changedInput schema / properties / client_token / description
      Previous value: -"Target client connection token, required with management access (including stdio and no-password mode). Device-scoped bearer access implicitly selects its own token."New value: +"Control credential in token:key format, required with management access (including stdio and no-password mode). Scoped control bearer access implicitly selects its own token."
    • changedInput schema / properties / session_id / description
      Previous value: -"Session identifier"New value: +"Client-local session identifier. Multi-device calls also require client_id."
    • changedOutput schema / properties / exit_code / description
      Previous value: -"Exit code of the latest completed command, or terminal termination if it ended; 0 is success, -1 denotes execution/connection failure. Absent while a command is running."New value: +"execute/read/list: the latest completed command exit code, preserved when its shell later ends. stop: the confirmed shell termination code. 0 means success; -1 denotes execution failure. Transport errors never invent a code."
    • changedOutput schema / properties / has_more / description
      Previous value: -"Whether more retained output remains after next_cursor. May be true even when done=true; continue reading to drain output."New value: +"Whether retained output remains after next_cursor; continue reading even after idle or closed."
    • changedOutput schema / properties / next_cursor / description
      Previous value: -"Byte offset immediately after the returned output. Pass it as cursor for the next session_read, including when done=true and has_more=true."New value: +"Byte offset immediately after the returned output. Pass it as cursor for the next session_read. Continue while has_more=true, including after status becomes idle or closed."
    • changedOutput schema / properties / session_id / description
      Previous value: -"Session identifier used by session_read and session_control."New value: +"Client-local session identifier. Multi-device read/control also require client_id."
    • changedOutput schema / properties / status / description
      Previous value: -"running: terminal busy or stop pending; idle: command ended and reusable; closed: session is no longer usable. A disconnection error means remote process termination is unconfirmed."New value: +"running: terminal busy or stop pending; idle: command ended and shell reusable; closed: client confirmed shell termination. Transport errors do not imply termination."
  5. Changed11 schema fields changed
    • addedInput schema / properties / command_id
      Added value: +{
      +  "description": "Optional command identity returned by execute_command; rejects a snapshot if the session has advanced to another command.",
      +  "type": "string"
      +}
    • addedInput schema / properties / session_id / maxLength
      Added value: +64
    • removedOutput schema / properties / canceled
      Removed value: -{
      -  "description": "True only when the target reported cancellation; a disconnect alone does not confirm cancellation.",
      -  "type": [
      -    "null",
      -    "boolean"
      -  ]
      -}
    • addedOutput schema / properties / command_id
      Added value: +{
      +  "description": "Identity of the latest submitted command.",
      +  "type": "string"
      +}
    • removedOutput schema / properties / done
      Removed value: -{
      -  "description": "True when a terminal result is available or the device connection closed. False means no terminal result is available yet.",
      -  "type": "boolean"
      -}
    • changedOutput schema / properties / exit_code / description
      Previous value: -"Reported process exit code: 0 means success; -1 means execution failed, was interrupted, or the device disconnected before a normal exit report."New value: +"Exit code of the latest completed command, or terminal termination if it ended; 0 is success, -1 denotes execution/connection failure. Absent while a command is running."
    • addedOutput schema / properties / status
      Added value: +{
      +  "description": "running: terminal busy or stop pending; idle: command ended and reusable; closed: session is no longer usable. A disconnection error means remote process termination is unconfirmed.",
      +  "enum": [
      +    "running",
      +    "idle",
      +    "closed"
      +  ],
      +  "type": "string"
      +}
    • removedOutput schema / properties / timed_out
      Removed value: -{
      -  "description": "True if the target reported that the process execution timeout elapsed.",
      -  "type": [
      -    "null",
      -    "boolean"
      -  ]
      -}
    • changedOutput schema / properties / truncated / description
      Previous value: -"True if output exceeded the 1 MiB retention limit. Commands discard excess captured output; sessions discard older buffered bytes."New value: +"Present only as true when the requested cursor predates the oldest retained output. The latest 1 MiB is retained; pagination alone does not truncate."
    • addedOutput schema / properties / truncated / enum
      Added value: +[
      +  true
      +]
    • changedOutput schema / required
      Previous value: -[
      -  "session_id",
      -  "output",
      -  "next_cursor",
      -  "truncated",
      -  "has_more",
      -  "done"
      -]New value: +[
      +  "session_id",
      +  "command_id",
      +  "status",
      +  "output",
      +  "next_cursor",
      +  "has_more"
      +]
  6. Changed5 schema fields changed
    • addedInput schema / properties / max_bytes
      Added value: +{
      +  "default": 16384,
      +  "description": "Maximum output bytes per read, 4–65536; default 16384. May return fewer bytes to preserve UTF-8 boundaries. Continue with next_cursor while has_more=true.",
      +  "maximum": 65536,
      +  "minimum": 4,
      +  "type": [
      +    "null",
      +    "integer"
      +  ]
      +}
    • addedOutput schema / properties / has_more
      Added value: +{
      +  "description": "Whether more retained output remains after next_cursor. May be true even when done=true; continue reading to drain output.",
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / next_cursor / description
      Previous value: -"Output byte offset to pass as cursor on the next session_read."New value: +"Byte offset immediately after the returned output. Pass it as cursor for the next session_read, including when done=true and has_more=true."
    • changedOutput schema / properties / session_id / description
      Previous value: -"Session identifier used by session_read, session_write and session_stop."New value: +"Session identifier used by session_read and session_control."
    • changedOutput schema / required
      Previous value: -[
      -  "session_id",
      -  "output",
      -  "next_cursor",
      -  "truncated",
      -  "done"
      -]New value: +[
      +  "session_id",
      +  "output",
      +  "next_cursor",
      +  "truncated",
      +  "has_more",
      +  "done"
      +]
  7. Changed5 schema fields changed
    • 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."
    • changedInput schema / properties / cursor / description
      Previous value: -"Byte cursor, initially 0"New value: +"Output byte offset, initially 0; subsequent reads accept the previous next_cursor."
    • 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": "True when a terminal result is available or the device connection closed. False means no terminal result is available yet.",
      +    "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": "Session identifier used by session_read, session_write and session_stop.",
      +    "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"
      +]
  8. First observed

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already establish read-only, idempotent, closed-world semantics, yet the description adds genuinely new behavior: reads are pinned and rejected when a newer command supersedes them, and has_more must be drained past idle/closed states. It leaves wait_ms long-polling and max_bytes truncation signaling unmentioned, but the schema covers those.

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?

Three tight sentences, each carrying distinct information, with the core read operation front-loaded. "Drain has_more" is slightly jargon-heavy and assumes the reader connects it to the response field, but nothing is wasted.

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

Completeness4/5

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

With a rich schema, an output schema, and full annotations, the description only needs to cover non-obvious sequencing behavior — cursor advancement, stale-read rejection, and draining after close — and it does. The omission of wait_ms polling semantics is the main residual gap and is partly mitigated by the schema.

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

Parameters3/5

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

Schema coverage is 100%, so cursor, wait_ms, max_bytes, and client_id are already well documented. The only real addition is that command_id causes stale reads to be rejected rather than merely pinning to a command; the rest restates schema-level meaning, so baseline 3 applies.

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

Purpose4/5

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

"Read session output from a byte cursor" gives a specific verb, resource, and access mechanism, which separates it from session_list (enumeration) and session_control (mutation). It stops short of naming a sibling it is not, so the differentiation is inferred from the verb rather than stated.

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

Usage Guidelines4/5

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

It gives actionable conditional guidance: pass command_id to avoid stale reads after a newer command starts, and keep draining while has_more is set even after idle/closed. It does not name an alternative tool or state when this tool should not be used, so it is clear context without explicit exclusions.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources