list-terminals
Retrieve a list of all active iTerm2 terminal sessions with their current information and status for session management.
Instructions
List all active terminals and their information
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list-terminals"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:247-261 (handler)The handler function for the 'list-terminals' tool. It retrieves active terminals from the global 'terminals' Map, computes the count and list of IDs, and returns a formatted text response with this information.
async () => { const activeTerminals = Array.from(terminals.entries()).map(([id]) => id); const count = terminals.size; return { content: [ { type: "text", text: `Number of active terminals: ${count}\nActive terminal IDs: ${ activeTerminals.join(", ") || "None" }`, }, ], }; } - index.js:243-262 (registration)Registration of the 'list-terminals' tool with McpServer.tool(). Includes name, description, empty schema, and inline handler function.
server.tool( "list-terminals", "List all active terminals and their information", {}, async () => { const activeTerminals = Array.from(terminals.entries()).map(([id]) => id); const count = terminals.size; return { content: [ { type: "text", text: `Number of active terminals: ${count}\nActive terminal IDs: ${ activeTerminals.join(", ") || "None" }`, }, ], }; } ); - index.js:10-10 (helper)Global Map storing active terminals, used by the 'list-terminals' handler to list them.
const terminals = new Map();