Skip to main content
Glama

get_session_state

Retrieve the current state of a PHP debugging session, including execution position and status details, to monitor and control debugging processes.

Instructions

Get detailed state of a specific debug session including current position and status

Input Schema

NameRequiredDescriptionDefault
session_idNoSession ID (uses active session if not specified)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "session_id": { "description": "Session ID (uses active session if not specified)", "type": "string" } }, "type": "object" }

Implementation Reference

  • The core handler function that executes the 'get_session_state' tool logic: resolves the session (active or by ID), fetches its state and init packet, and returns formatted JSON details or error if session not found.
    async ({ session_id }) => { const session = sessionManager.resolveSession(session_id); if (!session) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'No session found', message: session_id ? `Session "${session_id}" not found` : 'No active debug session. Start a PHP script with Xdebug enabled.', }), }, ], }; } const state = session.getState(); const initPacket = session.initPacket; return { content: [ { type: 'text', text: JSON.stringify( { id: session.id, status: state.status, currentFile: state.filename, currentLine: state.lineno, startTime: state.startTime.toISOString(), init: initPacket ? { fileUri: initPacket.fileUri, ideKey: initPacket.ideKey, language: initPacket.language, protocolVersion: initPacket.protocolVersion, engine: initPacket.engine, } : null, isConnected: session.isConnected, }, null, 2 ), }, ], }; }
  • Zod input schema defining the optional 'session_id' parameter for the tool.
    session_id: z .string() .optional() .describe('Session ID (uses active session if not specified)'), },
  • The server.tool() registration call that defines the tool name, description, input schema, and attaches the handler function within registerSessionTools.
    server.tool( 'get_session_state', 'Get detailed state of a specific debug session including current position and status', { session_id: z .string() .optional() .describe('Session ID (uses active session if not specified)'), }, async ({ session_id }) => { const session = sessionManager.resolveSession(session_id); if (!session) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'No session found', message: session_id ? `Session "${session_id}" not found` : 'No active debug session. Start a PHP script with Xdebug enabled.', }), }, ], }; } const state = session.getState(); const initPacket = session.initPacket; return { content: [ { type: 'text', text: JSON.stringify( { id: session.id, status: state.status, currentFile: state.filename, currentLine: state.lineno, startTime: state.startTime.toISOString(), init: initPacket ? { fileUri: initPacket.fileUri, ideKey: initPacket.ideKey, language: initPacket.language, protocolVersion: initPacket.protocolVersion, engine: initPacket.engine, } : null, isConnected: session.isConnected, }, null, 2 ), }, ], }; } );

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