Skip to main content
Glama

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

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "properties": {}, "type": "object" }

Implementation Reference

  • 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), }, ], }; }
  • 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), }, ], }; } );
  • 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);

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