Skip to main content
Glama
aiterm-mcp
by kitepon

pty_read

Read PTY session output incrementally, reduce token usage via control-character and repetition trimming, wait for command completion, and recover final assistant messages from completed agent turns.

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
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. 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"
      +}
  2. 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"
      +  }
      +]
  3. 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"
      +}
  4. 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"
      +  }
      +]
  5. 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"
      +}
  6. 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"
      +}
  7. 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で切れた時の回収用"
  8. Addedv0.22.0

TDQS

A3.5/5.0
Behavior3/5

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

No annotations exist, so the description carries the burden, and it does disclose real behavior: the reduction pipeline (control-char stripping, repetition compression, head+tail folding with restore hints and meta) and that empty turns are not errors but return empty text with answer_empty:true. It omits whether reading advances a cursor that affects subsequent calls, and never states the read is side-effect free.

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 reduction modes, then the agent_transcript special case and its empty-answer edge case. Dense but mostly earning its place; the agent_transcript explanation partially duplicates the schema's own wording, which is the only real waste.

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 15 parameters, a nested remote object, and an output schema present, the description sensibly focuses on the non-obvious semantics (incremental reads, token reduction, transcript retrieval) rather than restating every parameter. Adequate for correct invocation, though the multi-mode surface (remote/wait/until/screen) gets no narrative framing.

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 93%, so the baseline is 3 and the schema already defines raw, rtk, full, wait, until, lines, screen, remote, input_id, operation_id, etc. The description reinforces only agent_transcript and the incremental default, adding little meaning beyond the schema's own text.

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?

States a specific verb (read) and resource (session output) plus the default incremental-from-last-position behavior, and carves out a distinct agent_transcript mode. It never names or contrasts with close siblings such as pty_observe, so an agent must guess how plain screen observation differs from this reduced/incremental read.

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?

Gives one concrete when-to-use cue — agent_transcript is 'for recovering long answers truncated in the screen tail' — and implies default incremental reads. It offers no exclusions (when not to use raw/screen/rtk), no prerequisites, and no explicit alternative tool, leaving mode selection largely to the schema descriptions.

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