Skip to main content
Glama
aiterm-mcp
by kitepon

pty_send

Sends text or commands to PTY and agent sessions, routing messages to active turns or dispatching new work and returning a receipt for completion tracking.

Instructions

セッションへテキストを送る。通常PTYへは送信のみ(出力は pty_read で取得)。agent session(launcher起動)への送信はこのtoolだけで行い、子の状態はAitermが送る時点で見て振り分ける。子のturnが実行中なら各harness標準の操作で現在のturnへ差し込み(mode=agent_steer)、完了は差し込み後の作業の終わりに元の依頼への1回だけ届く。新しいevent_cursorと配送は作らない。それ以外は新しいturnとしてdispatchし(mode=agent_dispatch)、TUI の ready gate と submit 分離を通して即返り、receipt の event_cursor を返す。dispatch した子は投げっぱなしでよい=親はここで待たない。Codex親とClaude Code親にはAitermが回答本文を自動配送する。parent_deliveryがある場合はwait起動も通常の回答回収も不要。親は作業を続けるかターンを終える。Cursor親にはparent_deliveryとwait_processが付く。作業を続ければ次のツール返りに回答が差し込まれ、ターンを終える前にwait_processを背景で起動するとidle中の完了でも起きられる。ポーリングとpty_read(agent_transcript:true)は不要。その他の親では、完了通知をreceiptの wait_process.executable と wait_process.args をそのまま親のターンを塞がない別プロセスAPIへ渡して受け、PowerShell 7のStart-Processだけは windows_start_process_argument_list を単一文字列として渡す。exit を完了通知として扱う(exit 0=done / 3=timeout(既定600秒・未完了) / 4=closed / 7=error(harnessの記録でturnがAPIエラー等で打ち切られた。結果は無い)。receiptのoutcomeが正で、done以外は未完了。ポーリング不要)。wait_command は人間向け互換表示でありprocess境界へ使わない。foreground実行で親のターンを塞がない。自動配送以外の結果回収は pty_read(agent_transcript:true)、Claude の durable turn は claude_turn を使う。require_agent:true はagent登録が無いsessionへ打鍵せず、AGENT_SESSION_REQUIREDで未送信を返す。preface はagent sessionへの送信で本文の前に置く1行。Claude Codeの席では貼り付けの印なしで入れ、本文だけを貼る(前置きが貼り付けの包みの外へ出る)。他のharnessでは前置き・空行・本文を1つで貼る。force:true は非Claude agent sessionへの手動介入用の素送信。aiterm相関付きClaudeの承認UIはclaude_approvalを使う。

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

Input Schema

NameRequiredDescriptionDefault
rawNo送信前サニタイズを無効化
rtkNo既知コマンドを rtk 形へ委譲して送る(rtk 不在なら素通し)
markNo完了 sentinel(終了コード付き)で包む。pty_read(wait:true) が until 無しでも自動検出して完了確定する(POSIX shell と PowerShell に対応。SSH先の現在の標準PS promptも自動判定。PowerShell の rc は成功0/失敗1。fish/csh/tcsh は未対応として送信前に拒否)。 enter:false と併用すると sentinel が実行されず完了検出が発火しない(送信後に pty_key("Enter") で実行される)。
textYes送る文字列(コマンド/prompt)。UTF-8で最大64KiB
enterNo末尾で Enter を送る(agent dispatch では常に submit)
forceNo非Claude agent sessionでは自動dispatchせず素送信する。aiterm相関付きClaudeのactive turnには使えない
imageNo添付する画像ファイルの絶対パス(png/jpg/jpeg/gif/webp)。agent session への dispatch だけで使え、harness別の添付手順はaitermが吸収する。通常PTY送信やforce送信では指定できない
remoteNo別端末のAitermで実行する時のSSH接続情報。hostだけならssh_configの接続名として使う。Aitermは接続情報を保存・管理しない。passphraseは会話記録に残るため、ssh-agentかpassphrase_env(環境変数名)を推奨する。
prefaceNoagent session への送信(forceなし)で、本文の前に置く1行。送る文は「preface・空行・text」の並びになる。Claude Codeの席ではprefaceを貼り付けの印なしで入れ、textだけを貼る。Codex/Grok/Cursor/Antigravityの席では1つで貼る。1行・200字以内・制御文字なしで、行頭が記号や空白でなく、@ を含まない文。外れた時と通常PTY送信・force送信・remote付きでは、打鍵前に拒否する
session_idYes
require_agentNoagent登録が無いsessionは打鍵前に拒否する。force:trueとは併用できない

Output Schema

NameRequiredDescriptionDefault
modeYes
schemaYes
vendorYes
harnessYes
input_idNo
launch_idYes
session_idYes
event_cursorYes
wait_processYes
submit_residueYes
parent_deliveryNo
pane_input_recoveryNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.63.7
    • addedOutput schema / properties / input_id
      Added value: +{
      +  "pattern": "^[a-f0-9]{32}$",
      +  "type": "string"
      +}
    • addedOutput schema / properties / parent_delivery / properties / child_error_kind
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ]
      +}
    • addedOutput schema / properties / parent_delivery / properties / child_failure
      Added value: +{
      +  "additionalProperties": false,
      +  "properties": {
      +    "boundary": {
      +      "anyOf": [
      +        {
      +          "additionalProperties": false,
      +          "properties": {
      +            "event_cursor": {
      +              "maximum": 9007199254740991,
      +              "minimum": 0,
      +              "type": "integer"
      +            },
      +            "input_id": {
      +              "pattern": "^[a-f0-9]{32}$",
      +              "type": "string"
      +            },
      +            "operation_id": {
      +              "anyOf": [
      +                {
      +                  "type": "string"
      +                },
      +                {
      +                  "type": "null"
      +                }
      +              ]
      +            },
      +            "turn_id": {
      +              "anyOf": [
      +                {
      +                  "type": "string"
      +                },
      +                {
      +                  "type": "null"
      +                }
      +              ]
      +            }
      +          },
      +          "required": [
      +            "event_cursor",
      +            "operation_id",
      +            "turn_id"
      +          ],
      +          "type": "object"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "category": {
      +      "enum": [
      +        "capacity",
      +        "rate_limited",
      +        "transient",
      +        "other"
      +      ],
      +      "type": "string"
      +    },
      +    "execution": {
      +      "enum": [
      +        "not_started",
      +        "started",
      +        "unknown"
      +      ],
      +      "type": "string"
      +    },
      +    "future_effects": {
      +      "const": "unknown",
      +      "type": "string"
      +    },
      +    "terminal": {
      +      "type": "boolean"
      +    }
      +  },
      +  "required": [
      +    "category",
      +    "execution",
      +    "boundary",
      +    "terminal",
      +    "future_effects"
      +  ],
      +  "type": "object"
      +}
    • addedOutput schema / properties / parent_delivery / properties / child_vendor_session_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ]
      +}
  2. Changed3 schema fields changedv0.62.2
    • changedInput schema / properties / preface / description
      Previous value: -"agent session への送信(forceなし)で、本文の前に置く1行。送る文は「preface・空行・text」の並びになる。Claude Codeの席ではprefaceを貼り付けの印なしで入れ、textだけを貼る。Codex/Grok/Cursorの席では1つで貼る。1行・200字以内・制御文字なしで、行頭が記号や空白でなく、@ を含まない文。外れた時と通常PTY送信・force送信・remote付きでは、打鍵前に拒否する"New value: +"agent session への送信(forceなし)で、本文の前に置く1行。送る文は「preface・空行・text」の並びになる。Claude Codeの席ではprefaceを貼り付けの印なしで入れ、textだけを貼る。Codex/Grok/Cursor/Antigravityの席では1つで貼る。1行・200字以内・制御文字なしで、行頭が記号や空白でなく、@ を含まない文。外れた時と通常PTY送信・force送信・remote付きでは、打鍵前に拒否する"
    • 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. Changed2 schema fields changedv0.60.1
    • addedInput schema / properties / preface
      Added value: +{
      +  "description": "agent session への送信(forceなし)で、本文の前に置く1行。送る文は「preface・空行・text」の並びになる。Claude Codeの席ではprefaceを貼り付けの印なしで入れ、textだけを貼る。Codex/Grok/Cursorの席では1つで貼る。1行・200字以内・制御文字なしで、行頭が記号や空白でなく、@ を含まない文。外れた時と通常PTY送信・force送信・remote付きでは、打鍵前に拒否する",
      +  "type": "string"
      +}
    • addedInput schema / properties / require_agent
      Added value: +{
      +  "default": false,
      +  "description": "agent登録が無いsessionは打鍵前に拒否する。force:trueとは併用できない",
      +  "type": "boolean"
      +}
  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. Changed2 schema fields 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"
      +}
    • changedOutput schema / properties / mode / enum
      Previous value: -[
      -  "sent",
      -  "agent_dispatch"
      -]New value: +[
      +  "sent",
      +  "agent_dispatch",
      +  "agent_steer"
      +]
  6. Changed2 schema fields changedv0.35.0
    • changedInput schema / properties / mark / description
      Previous value: -"完了 sentinel(終了コード付き)で包む。pty_read(wait:true) が until 無しでも自動検出して完了確定する(POSIX shell と PowerShell に対応。PowerShell の rc は成功0/失敗1。fish/csh/tcsh は未対応として送信前に拒否)。 enter:false と併用すると sentinel が実行されず完了検出が発火しない(送信後に pty_key(\"Enter\") で実行される)。"New value: +"完了 sentinel(終了コード付き)で包む。pty_read(wait:true) が until 無しでも自動検出して完了確定する(POSIX shell と PowerShell に対応。SSH先の現在の標準PS promptも自動判定。PowerShell の rc は成功0/失敗1。fish/csh/tcsh は未対応として送信前に拒否)。 enter:false と併用すると sentinel が実行されず完了検出が発火しない(送信後に pty_key(\"Enter\") で実行される)。"
    • addedOutput schema / properties / parent_delivery
      Added value: +{
      +  "additionalProperties": false,
      +  "properties": {
      +    "child_outcome": {
      +      "anyOf": [
      +        {
      +          "enum": [
      +            "done",
      +            "closed",
      +            "rate_limited",
      +            "error"
      +          ],
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "child_turn_id": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "delivery_id": {
      +      "type": "string"
      +    },
      +    "error_code": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "queued_submission_id": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "state": {
      +      "enum": [
      +        "waiting",
      +        "ready",
      +        "sending",
      +        "submitted",
      +        "failed",
      +        "unknown"
      +      ],
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "delivery_id",
      +    "state",
      +    "child_outcome",
      +    "child_turn_id",
      +    "queued_submission_id",
      +    "error_code"
      +  ],
      +  "type": "object"
      +}
  7. Changed2 schema fields changedv0.31.2
    • addedInput schema / properties / image
      Added value: +{
      +  "description": "添付する画像ファイルの絶対パス(png/jpg/jpeg/gif/webp)。agent session への dispatch だけで使え、harness別の添付手順はaitermが吸収する。通常PTY送信やforce送信では指定できない",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / pane_input_recovery
      Added value: +{
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
  8. Changed1 schema field changedv0.29.21
    • changedInput schema / properties / force / description
      Previous value: -"破壊的コマンドゲートを越える。非Claude agent sessionではdispatchせず素送信する。aiterm相関付きClaudeのactive turnには使えない"New value: +"非Claude agent sessionでは自動dispatchせず素送信する。aiterm相関付きClaudeのactive turnには使えない"
  9. Changed2 schema fields changedv0.29.8
    • addedOutput schema / properties / wait_process
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": false,
      +      "properties": {
      +        "args": {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        "executable": {
      +          "type": "string"
      +        },
      +        "windows_start_process_argument_list": {
      +          "anyOf": [
      +            {
      +              "type": "string"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ]
      +        }
      +      },
      +      "required": [
      +        "executable",
      +        "args",
      +        "windows_start_process_argument_list"
      +      ],
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ]
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "schema",
      -  "mode",
      -  "session_id",
      -  "event_cursor",
      -  "launch_id",
      -  "vendor",
      -  "harness",
      -  "submit_residue"
      -]New value: +[
      +  "schema",
      +  "mode",
      +  "session_id",
      +  "event_cursor",
      +  "wait_process",
      +  "launch_id",
      +  "vendor",
      +  "harness",
      +  "submit_residue"
      +]
  10. Changed3 schema fields changedv0.28.0
    • addedOutput schema / properties / harness
      Added value: +{
      +  "anyOf": [
      +    {
      +      "enum": [
      +        "claude-code",
      +        "codex-cli",
      +        "grok-cli",
      +        "cursor-cli"
      +      ],
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ]
      +}
    • changedOutput schema / properties / vendor / anyOf
      Previous value: -[
      -  {
      -    "enum": [
      -      "claude",
      -      "codex",
      -      "grok",
      -      "composer"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "enum": [
      +      "claude",
      +      "codex",
      +      "grok",
      +      "composer",
      +      "cursor"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedOutput schema / required
      Previous value: -[
      -  "schema",
      -  "mode",
      -  "session_id",
      -  "event_cursor",
      -  "launch_id",
      -  "vendor",
      -  "submit_residue"
      -]New value: +[
      +  "schema",
      +  "mode",
      +  "session_id",
      +  "event_cursor",
      +  "launch_id",
      +  "vendor",
      +  "harness",
      +  "submit_residue"
      +]
  11. Changed1 schema field changedv0.27.9
    • changedInput schema / properties / mark / description
      Previous value: -"完了 sentinel(終了コード付き)で包む。pty_read(wait:true) が until 無しでも自動検出して完了確定する(ネスト中や非シェル前面でも効く確実な完了検出。手で until を組む必要なし)。 enter:false と併用すると sentinel が実行されず完了検出が発火しない(送信後に pty_key(\"Enter\") で実行される)。"New value: +"完了 sentinel(終了コード付き)で包む。pty_read(wait:true) が until 無しでも自動検出して完了確定する(POSIX shell と PowerShell に対応。PowerShell の rc は成功0/失敗1。fish/csh/tcsh は未対応として送信前に拒否)。 enter:false と併用すると sentinel が実行されず完了検出が発火しない(送信後に pty_key(\"Enter\") で実行される)。"
  12. Addedv0.22.0

TDQS

A4.3/5.0
Behavior3/5

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

There are no annotations, so the description carries the full burden of behavioral disclosure. To its credit, it discloses a great deal: agent_steer vs agent_dispatch mode selection, fire-and-forget dispatch, per-parent delivery mechanisms, wait_process exit-code semantics (0/3/4/7), require_agent rejection with AGENT_SESSION_REQUIRED, and preface paste behavior. A 3 reflects that, while rich, it omits turn-recovery edge cases and makes the parent-delivery paths hard to parse and act on deterministically.

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

Conciseness3/5

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

The purpose is front-loaded in the first sentence, which is good. But the rest is a dense run-on covering mode selection, per-harness parent delivery, wait_process exit codes, preface paste rules, and force behavior with little structural separation, making it hard for an agent to parse the decision logic. Much content is necessary, yet the length and lack of grouping cost readability.

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?

Given 11 parameters, nested remote object, and high behavioral complexity with no annotations, the description covers what an agent needs: mode determination, parent delivery, exit-code completion semantics, rejection conditions, and preface/force caveats. It also explains receipt fields (event_cursor, outcome, wait_process) even though an output schema exists.

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 description coverage is high (91%), so the structured fields already document most parameters. The description still adds useful meaning beyond the schema: force as raw manual intervention, force/require_agent mutual exclusion at send time, how preface is placed across harnesses, and mode selection (agent_steer/agent_dispatch). It does not add much to text/enter/image/raw/rtk beyond what the schema states, keeping it at 4 rather than 5.

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?

It states a concrete verb and resource ('セッションへテキストを送る') and immediately separates this tool's role from siblings: output goes through pty_read, approvals through claude_approval, durable Claude turns through claude_turn, and Enter-only input through pty_key. An agent can identify the tool's exact scope without opening 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?

It gives explicit when-to-use rules and names alternatives: normal PTY is send-only (read via pty_read), agent turns are split into agent_steer vs agent_dispatch based on child state, dispatched children are fire-and-forget, parent delivery varies by parent harness, and claude_approval handles approval UI. It also warns which operations are unnecessary (polling, pty_read with agent_transcript) and which are required (wait_process for some parents).

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