list_sessions
View active terminal sessions to monitor process status, identify blocked REPLs, and verify session activity before sending commands.
Instructions
List all active terminal sessions.
Shows session status including:
- PID: Process identifier
- Blocked: Whether session is waiting for input
- Runtime: How long the session has been running
DEBUGGING REPLs:
- "Blocked: true" often means REPL is waiting for input
- Use this to verify sessions are running before sending input
- Long runtime with blocked status may indicate stuck process
This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Core handler function that lists all active terminal sessions (real and virtual Node.js sessions) using terminalManager and formats the output.export async function listSessions(): Promise<ServerResult> { const sessions = terminalManager.listActiveSessions(); // Include virtual Node.js sessions const virtualSessions = Array.from(virtualNodeSessions.entries()).map(([pid, session]) => ({ pid, type: 'node:local', timeout_ms: session.timeout_ms })); const realSessionsText = sessions.map(s => `PID: ${s.pid}, Blocked: ${s.isBlocked}, Runtime: ${Math.round(s.runtime / 1000)}s` ); const virtualSessionsText = virtualSessions.map(s => `PID: ${s.pid} (node:local), Timeout: ${s.timeout_ms}ms` ); const allSessions = [...realSessionsText, ...virtualSessionsText]; return { content: [{ type: "text", text: allSessions.length === 0 ? 'No active sessions' : allSessions.join('\n') }], }; }
- src/handlers/terminal-handlers.ts:53-55 (handler)MCP wrapper handler for 'list_sessions' tool that delegates to the core listSessions implementation.export async function handleListSessions(): Promise<ServerResult> { return listSessions(); }
- src/tools/schemas.ts:40-40 (schema)Zod input schema for list_sessions tool (no arguments required).export const ListSessionsArgsSchema = z.object({});
- src/server.ts:923-943 (registration)Tool registration in ListTools handler: defines name, description, inputSchema for 'list_sessions'.name: "list_sessions", description: ` List all active terminal sessions. Shows session status including: - PID: Process identifier - Blocked: Whether session is waiting for input - Runtime: How long the session has been running DEBUGGING REPLs: - "Blocked: true" often means REPL is waiting for input - Use this to verify sessions are running before sending input - Long runtime with blocked status may indicate stuck process ${CMD_PREFIX_DESCRIPTION}`, inputSchema: zodToJsonSchema(ListSessionsArgsSchema), annotations: { title: "List Terminal Sessions", readOnlyHint: true, }, },
- src/server.ts:1258-1260 (registration)Dispatch in CallTool handler: routes 'list_sessions' calls to handlers.handleListSessions().case "list_sessions": result = await handlers.handleListSessions(); break;