sessions
List active shell sessions to monitor ongoing processes in a sandboxed bash server.
Instructions
List all active shell sessions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- packages/bash-mcp/src/index.ts:101-110 (handler)Handler function for the 'sessions' tool. Returns a JSON string with an array of all active session IDs from the sessions map.
async () => { return { content: [ { type: 'text', text: JSON.stringify({ sessions: Array.from(sessions.keys()) }), }, ], }; }, - Schema definition for the 'sessions' tool (no input parameters, only description).
{ description: 'List all active shell sessions.', }, - packages/bash-mcp/src/index.ts:96-111 (registration)Registration of the 'sessions' tool via server.registerTool().
server.registerTool( 'sessions', { description: 'List all active shell sessions.', }, async () => { return { content: [ { type: 'text', text: JSON.stringify({ sessions: Array.from(sessions.keys()) }), }, ], }; }, ); - packages/bash-mcp/src/index.ts:9-21 (helper)Helper function getSession() that manages the sessions map, creating new Bash instances as needed.
function getSession(sessionId: string): Bash { if (!sessions.has(sessionId)) { sessions.set( sessionId, new Bash({ runtime: new WasmRuntime(), hostWorkspace: `.capsule/sessions/${sessionId}`, }), ); } return sessions.get(sessionId)!; } - packages/bash-mcp/src/index.ts:7-7 (helper)The sessions map (Map<string, Bash>) that stores all active shell sessions.
const sessions = new Map<string, Bash>();