Skip to main content
Glama
aiterm-mcp
by kitepon

pty_close

Close a PTY session and discard its logs and read position, or hibernate the agent seat to preserve the conversation and resume it later with agent_launch.

Instructions

セッションを閉じ、ログ/読取位置を破棄する。同じsession_idへの再試行は安全で、closed/already_closedのstructured receiptを返す。hibernate:trueはClaude・Codexのagent席を今すぐ休止し(idle時計と同じ手順)、会話と再開情報を残してhibernatedを返す。次のagent_launch(session_name)が同じ会話へ再開する。turn・子process・子への配送が動いている間はAGENT_BUSYで断る(終わってから呼び直す)。Claudeの席が利用上限でturnを終えている時(最後の入力の後の会話記録がrate_limited)は、上限の待ち画面のままでも休止できる。他の理由で休止できない時はAGENT_HIBERNATE_UNAVAILABLE、席は触らない。

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_close"
  }
}

Input Schema

NameRequiredDescriptionDefault
remoteNo別端末のAitermで実行する時のSSH接続情報。hostだけならssh_configの接続名として使う。Aitermは接続情報を保存・管理しない。passphraseは会話記録に残るため、ssh-agentかpassphrase_env(環境変数名)を推奨する。
hibernateNotrueで閉じずに休止する(会話と再開情報を残す)。既定false
session_idYes

Output Schema

NameRequiredDescriptionDefault
schemaYes
outcomeYes
session_idYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.70.3
    • addedInput schema / properties / hibernate
      Added value: +{
      +  "description": "trueで閉じずに休止する(会話と再開情報を残す)。既定false",
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / outcome / enum
      Previous value: -[
      -  "closed",
      -  "already_closed"
      -]New value: +[
      +  "closed",
      +  "already_closed",
      +  "hibernated"
      +]
  2. 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"
      +}
  3. Addedv0.22.0

TDQS

A4.7/5.0
Behavior5/5

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

アノテーションが無いので記述が全てを担うが、冪等性(同じ session_id への再試行は安全、closed/already_closed を返す)、破棄されるもの、休止時に残るもの、AGENT_BUSY・AGENT_HIBERNATE_UNAVAILABLE という失敗時の挙動(席は触らない)まで開示している。不可逆な破棄を伴う操作として十分な情報量がある。

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?

冒頭で「閉じる/破棄する」を述べ、以降を冪等性→休止→拒否条件→例外の順に積んでいて前段に要点がある。ただし AGENT_BUSY と rate_limited の記述が密で、やや読み解きに負荷がかかる。

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?

出力スキーマがあるため戻り値の詳細説明は不要で、スキーマ側が remote のSSH情報を十分に説明している。一方、AGENT_BUSY の条件が「閉じる」操作全般にかかるのか休止時のみかが読み取りにくく、通常クローズ時に実行中の子プロセスがどうなるかは不明瞭。

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?

hibernate はスキーマにも説明があるが、記述側が「idle時計と同じ手順」「会話と再開情報を残す」「次の agent_launch で再開」と意味を大きく補強している。session_id は記述でもスキーマでも未説明だが、名称から自明。remote はスキーマの説明が充実しており、カバレッジ67%を踏まえると妥当。

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?

「セッションを閉じ、ログ/読取位置を破棄する」と具体的な動作を述べ、hibernate:true の別モードも明示している。pty_open、pty_list など他のセッション系ツールと混同しないよう、破棄対象(ログと読取位置)まで特定している。

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?

いつ休止を使うか(agent席を残したい時)、いつ断られるか(turn・子process・配送中は AGENT_BUSY、終わってから再呼び出し)、再開手段(次の agent_launch で同じ会話)まで明示している。rate_limited 時の特例も示され、判断材料が揃っている。

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