list_sessions
View active PHP debug sessions and their current status to monitor ongoing debugging processes in Xdebug.
Instructions
List all active PHP debug sessions with their current state
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/session.ts:18-64 (handler)Handler function that lists all active PHP debug sessions, including their state, current position, and active status. Returns formatted JSON content or a no-sessions message.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/session.ts:14-65 (registration)Registration of the 'list_sessions' tool using McpServer.tool(), with description and empty input schema (no parameters), inline handler.server.tool( '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 (which includes list_sessions) during registerAllTools.registerSessionTools(server, ctx.sessionManager);