Skip to main content
Glama
aiterm-mcp
by kitepon

pty_read

Read terminal session output incrementally with token reduction, raw/full views, wait/until completion checks, and agent transcript recovery when answers are cut off.

Instructions

セッションの出力をトークン削減して読む(既定は前回読取位置からの増分)。削減: 制御文字除去 / 反復圧縮 / head+tail 折りたたみ+復元ヒント+メタ併記。agent_transcript:true は agent session の直近完了ターンの最終 assistant メッセージを公開されたharness記録から平文で返す。回答が空で終わったターンは誤りにせず、空のtextとanswer_empty:trueを返す。長い回答が screen tail で切れた時の回収用。

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>"
    },
    "name": "pty_read"
  }
}

Input Schema

NameRequiredDescriptionDefault
rawNo削減せず生テキスト
rtkNo直前コマンド別の自前 reducer(git/grep/pytest 等)で縮約
fullNo増分でなく全文
waitNo完了まで待つ(dead / mark sentinel 自動検出 / until / 出力静止∧シェル復帰 / timeout)
linesNo末尾 N 行のみ
untilNoこの文字列が出たら完了とみなす(既定はリテラル部分一致。`$ ` や `[..]` もそのまま探せる)
remoteNo別端末のAitermで実行する時のSSH接続情報。hostだけならssh_configの接続名として使う。Aitermは接続情報を保存・管理しない。passphraseは会話記録に残るため、ssh-agentかpassphrase_env(環境変数名)を推奨する。
screenNo描画済みスクリーン(TUI 向け)
timeoutNowait の最大待ち秒数
input_idNoClaudeのpty_send dispatch receiptのinput_id。agent_transcript:true時だけ指定し、その入力の番の回答を読む。後の番が動いていても拒否しない。未完了はAITERM_TRANSCRIPT_INPUT_PENDING、後の番の結果で置換済みはAITERM_TRANSCRIPT_INPUT_REPLACED
input_refNo差し込みが始めた番の回答を読むID。もう1つの同じ意味の引数と同じ値で、両方を渡す時は同じ値にする。agent_transcript:true時だけ指定する
line_rangeNo全文からの行範囲 "A:B"
session_idYes
until_regexNountil を正規表現として扱う(既定 false=リテラル部分一致。メタ文字を使いたい時のみ true)
operation_idNoClaude operationの期待ID。agent_transcript:true時だけ指定し、古い別operationの結果を拒否する
agent_transcriptNoagent session の直近完了ターンの最終 assistant メッセージを返す。Claudeはlaunch相関付きStop hook result、他harnessは通常transcript/session historyを使う。長い回答がscreen tailで切れた時の回収用

Output Schema

NameRequiredDescriptionDefault
modeYes
textYes
schemaYes
vendorYes
harnessYes
turn_idYes
raw_charsYes
session_idYes
answer_emptyNoagent_transcriptで、完了したturnの回答が空だった時だけtrue(textは空文字列)。回答を読めなかった時は誤りを返す。terminalではnull

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv0.70.146
    • removedInput schema / properties / line_range / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedInput schema / properties / line_range / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedInput schema / properties / until / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedInput schema / properties / until / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / answer_empty / anyOf
      Removed value: -[
      -  {
      -    "type": "boolean"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / answer_empty / type
      Added value: +[
      +  "boolean",
      +  "null"
      +]
    • removedOutput schema / properties / turn_id / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / turn_id / type
      Added value: +[
      +  "string",
      +  "null"
      +]
  2. Changed1 schema field changedv0.70.127
    • changedOutput schema / properties / harness / anyOf
      Previous value: -[
      -  {
      -    "enum": [
      -      "claude-code",
      -      "claude-machine",
      -      "codex-cli",
      -      "grok-cli",
      -      "cursor-cli",
      -      "antigravity-cli"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "enum": [
      +      "claude-code",
      +      "claude-machine",
      +      "codex-cli",
      +      "codex-machine",
      +      "grok-cli",
      +      "grok-machine",
      +      "cursor-cli",
      +      "cursor-machine",
      +      "antigravity-cli",
      +      "antigravity-machine"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  3. Changed3 schema fields changedv0.70.112
    • addedInput schema / properties / input_ref
      Added value: +{
      +  "anyOf": [
      +    {
      +      "pattern": "^[0-9a-f]{16}$",
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "差し込みが始めた番の回答を読むID。もう1つの同じ意味の引数と同じ値で、両方を渡す時は同じ値にする。agent_transcript:true時だけ指定する"
      +}
    • addedInput schema / properties / remote / properties / ssh
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "Pinned ssh: {known_hosts_file, host_key_alias?, identity_agent | identity_file, strict_host_key?: true} (absolute paths). Strict host checking against that file with that one identity, no user ssh config. Not combinable with identity_file, ssh_options, passphrase or passphrase_env. Needs Aiterm 0.70.101 on the other computer.",
      +  "properties": {
      +    "host_key_alias": {
      +      "pattern": "^(?!-)[A-Za-z0-9._%:\\[\\]-]{1,255}$",
      +      "type": "string"
      +    },
      +    "identity_agent": {
      +      "pattern": "^(\\/|[A-Za-z]:[\\\\/])[^\\s\"'`]*$",
      +      "type": "string"
      +    },
      +    "identity_file": {
      +      "pattern": "^(\\/|[A-Za-z]:[\\\\/])[^\\s\"'`]*$",
      +      "type": "string"
      +    },
      +    "known_hosts_file": {
      +      "pattern": "^(\\/|[A-Za-z]:[\\\\/])[^\\s\"'`]*$",
      +      "type": "string"
      +    },
      +    "strict_host_key": {
      +      "const": true,
      +      "type": "boolean"
      +    }
      +  },
      +  "required": [
      +    "known_hosts_file"
      +  ],
      +  "type": "object"
      +}
    • removedInput schema / properties / steer_id
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "pattern": "^[0-9a-f]{16}$",
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "description": "Claudeの差し込みが始めた番の回答を読むID。agent_transcript:true時だけ指定する。後の番が動いていても拒否しない。未完了はAITERM_TRANSCRIPT_INPUT_PENDING、置換済みはAITERM_TRANSCRIPT_INPUT_REPLACED、動いていた番が取った差し込みはAITERM_TRANSCRIPT_STEER_SAME_TURN、控え無しはSTEER_NOT_FOUND。operation_id・input_idと併用不可"
      -}
  4. Changed1 schema field changedv0.70.91
    • changedOutput schema / properties / harness / anyOf
      Previous value: -[
      -  {
      -    "enum": [
      -      "claude-code",
      -      "codex-cli",
      -      "grok-cli",
      -      "cursor-cli",
      -      "antigravity-cli"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "enum": [
      +      "claude-code",
      +      "claude-machine",
      +      "codex-cli",
      +      "grok-cli",
      +      "cursor-cli",
      +      "antigravity-cli"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  5. Changed1 schema field changedv0.70.81
    • addedInput schema / properties / steer_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "pattern": "^[0-9a-f]{16}$",
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Claudeの差し込みが始めた番の回答を読むID。agent_transcript:true時だけ指定する。後の番が動いていても拒否しない。未完了はAITERM_TRANSCRIPT_INPUT_PENDING、置換済みはAITERM_TRANSCRIPT_INPUT_REPLACED、動いていた番が取った差し込みはAITERM_TRANSCRIPT_STEER_SAME_TURN、控え無しはSTEER_NOT_FOUND。operation_id・input_idと併用不可"
      +}
  6. Changed1 schema field changedv0.70.3
    • addedInput schema / properties / input_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "pattern": "^[a-f0-9]{32}$",
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Claudeのpty_send dispatch receiptのinput_id。agent_transcript:true時だけ指定し、その入力の番の回答を読む。後の番が動いていても拒否しない。未完了はAITERM_TRANSCRIPT_INPUT_PENDING、後の番の結果で置換済みはAITERM_TRANSCRIPT_INPUT_REPLACED"
      +}
  7. Changed2 schema fields changedv0.62.2
    • changedOutput schema / properties / harness / anyOf
      Previous value: -[
      -  {
      -    "enum": [
      -      "claude-code",
      -      "codex-cli",
      -      "grok-cli",
      -      "cursor-cli"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "enum": [
      +      "claude-code",
      +      "codex-cli",
      +      "grok-cli",
      +      "cursor-cli",
      +      "antigravity-cli"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedOutput schema / properties / vendor / anyOf
      Previous value: -[
      -  {
      -    "enum": [
      -      "claude",
      -      "codex",
      -      "grok",
      -      "cursor"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "enum": [
      +      "claude",
      +      "codex",
      +      "grok",
      +      "cursor",
      +      "antigravity"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  8. Changed1 schema field changedv0.60.1
    • addedOutput schema / properties / answer_empty
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "agent_transcriptで、完了したturnの回答が空だった時だけtrue(textは空文字列)。回答を読めなかった時は誤りを返す。terminalではnull"
      +}
  9. Changed1 schema field changedv0.45.0
    • changedOutput schema / properties / vendor / anyOf
      Previous value: -[
      -  {
      -    "enum": [
      -      "claude",
      -      "codex",
      -      "grok",
      -      "composer",
      -      "cursor"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "enum": [
      +      "claude",
      +      "codex",
      +      "grok",
      +      "cursor"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  10. Changed1 schema field changedv0.39.1
    • addedInput schema / properties / remote
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "別端末のAitermで実行する時のSSH接続情報。hostだけならssh_configの接続名として使う。Aitermは接続情報を保存・管理しない。passphraseは会話記録に残るため、ssh-agentかpassphrase_env(環境変数名)を推奨する。",
      +  "properties": {
      +    "host": {
      +      "pattern": "^(?!-)[A-Za-z0-9._%:\\[\\]-]{1,255}$",
      +      "type": "string"
      +    },
      +    "identity_file": {
      +      "minLength": 1,
      +      "type": "string"
      +    },
      +    "passphrase": {
      +      "minLength": 1,
      +      "type": "string"
      +    },
      +    "passphrase_env": {
      +      "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
      +      "type": "string"
      +    },
      +    "port": {
      +      "maximum": 65535,
      +      "minimum": 1,
      +      "type": "integer"
      +    },
      +    "ssh_options": {
      +      "items": {
      +        "pattern": "^[A-Za-z][A-Za-z0-9]*=[^\\r\\n]*$",
      +        "type": "string"
      +      },
      +      "maxItems": 32,
      +      "type": "array"
      +    },
      +    "user": {
      +      "pattern": "^(?!-)[A-Za-z0-9._@\\\\-]{1,128}$",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "host"
      +  ],
      +  "type": "object"
      +}
  11. Changed1 schema field changedv0.29.21
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "harness": {
      +      "anyOf": [
      +        {
      +          "enum": [
      +            "claude-code",
      +            "codex-cli",
      +            "grok-cli",
      +            "cursor-cli"
      +          ],
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "mode": {
      +      "enum": [
      +        "terminal",
      +        "agent_transcript"
      +      ],
      +      "type": "string"
      +    },
      +    "raw_chars": {
      +      "anyOf": [
      +        {
      +          "maximum": 9007199254740991,
      +          "minimum": 0,
      +          "type": "integer"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "schema": {
      +      "const": "aiterm.pty-read-result.v1",
      +      "type": "string"
      +    },
      +    "session_id": {
      +      "type": "string"
      +    },
      +    "text": {
      +      "type": "string"
      +    },
      +    "turn_id": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "vendor": {
      +      "anyOf": [
      +        {
      +          "enum": [
      +            "claude",
      +            "codex",
      +            "grok",
      +            "composer",
      +            "cursor"
      +          ],
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    }
      +  },
      +  "required": [
      +    "schema",
      +    "mode",
      +    "session_id",
      +    "text",
      +    "vendor",
      +    "turn_id",
      +    "harness",
      +    "raw_chars"
      +  ],
      +  "type": "object"
      +}
  12. Changed1 schema field changedv0.28.0
    • changedInput schema / properties / agent_transcript / description
      Previous value: -"agent session の直近完了ターンの最終 assistant メッセージを返す。Claudeはlaunch相関付きStop hook result、他vendorは通常transcriptを使う。長い回答がscreen tailで切れた時の回収用"New value: +"agent session の直近完了ターンの最終 assistant メッセージを返す。Claudeはlaunch相関付きStop hook result、他harnessは通常transcript/session historyを使う。長い回答がscreen tailで切れた時の回収用"
  13. Addedv0.22.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It does disclose genuinely useful behavior: reads are incremental from the last read position by default, reduction techniques applied, and that empty answers return empty text plus answer_empty:true rather than an error. It does not cover whether the read cursor advances on full/screen reads, permission or auth needs, or failure modes beyond the empty-answer case.

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?

Front-loaded with the core purpose and default behavior, then the reduction details, then the agent_transcript special case and its edge case. Dense but every sentence carries information; only the reduction-technique enumeration is slightly heavy.

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?

For a 16-parameter tool with a nested remote object and an output schema, the description covers the two non-obvious modes (reduced incremental reads and agent_transcript) plus the empty-answer edge case. Remote/SSH, wait semantics and return shape are delegated to the schema and output schema, which is reasonable at 94% coverage.

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 description coverage is 94%, so the schema already explains raw, rtk, full, wait, screen, input_id, operation_id and the rest. The description adds the key framing that the default is incremental from the previous read position, which contextualizes the `full` flag, but it does not add syntax or meaning for the 16 parameters beyond that. Baseline 3 is appropriate.

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?

The description gives a specific verb and resource (reading session output) and adds two distinct modes: token-reduced incremental reads by default, and agent_transcript for the final assistant message of the last completed turn. It clearly signals its niche ('recovery when a long answer is cut off at the screen tail'), which separates it from a screen-scrape sibling, though it never names pty_observe or stream_read explicitly.

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

Usage Guidelines3/5

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

Usage context is implied through the mode descriptions: default incremental read, agent_transcript for agent turn results, and the screen-tail recovery scenario. However, no explicit when-to-use/when-not guidance relative to alternatives such as pty_observe or stream_read is given, so the agent must infer the routing.

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