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
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | No | Session 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
- src/tools/session.ts:77-127 (handler)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 ), }, ], }; }
- src/tools/session.ts:72-76 (schema)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)'), },
- src/tools/session.ts:68-128 (registration)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 ), }, ], }; } );