Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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), }, ], }; }
  • 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), }, ], }; } );
  • Higher-level registration call to registerSessionTools (which includes list_sessions) during registerAllTools.
    registerSessionTools(server, ctx.sessionManager);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kpanuragh/xdebug-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server