list_sessions
Retrieve all active sessions in the orchestration layer to track ongoing tasks and manage workflow states.
Instructions
List sessions
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| random_string | Yes |
Implementation Reference
- src/tools/terminal_tools.js:315-344 (handler)The main handler function for the list_sessions tool. Iterates over the in-memory sessions map and returns an array of session objects with sessionId, pid, command, shell, status, startTime, and duration.
function listSessions() { try { const activeSessions = []; for (const [id, session] of sessions) { activeSessions.push({ sessionId: id, pid: session.pid, command: session.command, shell: session.shell, status: session.status, startTime: new Date(session.startTime).toISOString(), duration: session.endTime ? session.endTime - session.startTime : Date.now() - session.startTime }); } return { success: true, sessions: activeSessions, count: activeSessions.length }; } catch (error) { logger.error(`Error listing sessions: ${error.message}`); return { success: false, message: error.message }; } } - src/mcp/server.js:100-100 (schema)Input schema definition for the list_sessions tool. Declares name, description, and an inputSchema requiring a random_string parameter.
{ name:'list_sessions', description:'List sessions', inputSchema:{ type:'object', properties:{ random_string:{type:'string'} }, required:['random_string'] } }, - src/mcp/server.js:262-262 (registration)Dispatch/call site where the list_sessions tool name is matched and the terminalTools.listSessions() function is invoked.
case 'list_sessions': data = terminalTools.listSessions(); break; - src/tools/terminal_tools.js:459-468 (registration)Module exports - listSessions is exported as part of the terminalTools module, making it available to server.js.
module.exports = { getConfig, setConfigValue, executeCommand, readOutput, forceTerminate, listSessions, listProcesses, killProcess }; - Test helper that generates example arguments for the list_sessions tool.
case 'list_sessions': return { random_string:'x' };