list_sessions
View active PHP debug sessions and their current status to monitor ongoing debugging processes.
Instructions
List all active PHP debug sessions with their current state
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {},
"type": "object"
}
Implementation Reference
- src/tools/session.ts:19-64 (handler)The core handler function for the 'list_sessions' tool. It fetches all active sessions from the SessionManager, determines the active session, maps session data including status, current position, and metadata, then returns a standardized MCP response with JSON-formatted text content or an empty message if no sessions.const sessions = sessionManager.getAllSessions(); const activeId = sessionManager.getActiveSessionId(); const sessionData = sessions.map((s) => { const state = s.getState(); return { id: s.id, active: s.id === activeId, status: state.status, file: s.initPacket?.fileUri || 'unknown', currentFile: state.filename, currentLine: state.lineno, ideKey: s.initPacket?.ideKey || 'unknown', language: s.initPacket?.language || 'PHP', startTime: state.startTime.toISOString(), }; }); if (sessionData.length === 0) { return { content: [ { type: 'text', text: JSON.stringify( { sessions: [], message: 'No active debug sessions. Start a PHP script with Xdebug enabled to begin debugging.', }, null, 2 ), }, ], }; } return { content: [ { type: 'text', text: JSON.stringify({ sessions: sessionData, count: sessionData.length }, null, 2), }, ], }; }
- src/tools/session.ts:15-65 (registration)Direct registration of the 'list_sessions' tool using server.tool(), specifying the tool name, description, empty input schema ({}), and the inline handler function.'list_sessions', 'List all active PHP debug sessions with their current state', {}, async () => { const sessions = sessionManager.getAllSessions(); const activeId = sessionManager.getActiveSessionId(); const sessionData = sessions.map((s) => { const state = s.getState(); return { id: s.id, active: s.id === activeId, status: state.status, file: s.initPacket?.fileUri || 'unknown', currentFile: state.filename, currentLine: state.lineno, ideKey: s.initPacket?.ideKey || 'unknown', language: s.initPacket?.language || 'PHP', startTime: state.startTime.toISOString(), }; }); if (sessionData.length === 0) { return { content: [ { type: 'text', text: JSON.stringify( { sessions: [], message: 'No active debug sessions. Start a PHP script with Xdebug enabled to begin debugging.', }, null, 2 ), }, ], }; } return { content: [ { type: 'text', text: JSON.stringify({ sessions: sessionData, count: sessionData.length }, null, 2), }, ], }; } );
- src/tools/index.ts:55-55 (registration)Higher-level registration call to registerSessionTools within registerAllTools, which includes the list_sessions tool.registerSessionTools(server, ctx.sessionManager);
- src/index.ts:91-91 (registration)Top-level call to registerAllTools on the main MCP server, which chains to session tools registration including list_sessions.registerAllTools(mcpServer, toolsContext);