set_active_session
Select a specific debug session as the active session for PHP debugging operations in Xdebug MCP Server.
Instructions
Set which debug session should be the active/default session for subsequent commands
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | Session ID to set as active |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"session_id": {
"description": "Session ID to set as active",
"type": "string"
}
},
"required": [
"session_id"
],
"type": "object"
}
Implementation Reference
- src/tools/session.ts:131-166 (registration)Registration of the set_active_session MCP tool, including input schema (session_id: string), description, and inline asynchronous handler that delegates to SessionManager.setActiveSession and formats the response.server.tool( 'set_active_session', 'Set which debug session should be the active/default session for subsequent commands', { session_id: z.string().describe('Session ID to set as active'), }, async ({ session_id }) => { const success = sessionManager.setActiveSession(session_id); if (!success) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'Session not found', session_id, }), }, ], }; } return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Session "${session_id}" is now active`, }), }, ], }; } );
- src/tools/session.ts:137-165 (handler)Inline handler function for set_active_session tool: validates session_id, calls sessionManager.setActiveSession, returns JSON-formatted success or error message in MCP content format.async ({ session_id }) => { const success = sessionManager.setActiveSession(session_id); if (!success) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'Session not found', session_id, }), }, ], }; } return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Session "${session_id}" is now active`, }), }, ], }; }
- src/tools/session.ts:134-136 (schema)Zod input schema for the tool: requires session_id as string.{ session_id: z.string().describe('Session ID to set as active'), },
- src/session/manager.ts:102-108 (helper)Helper method in SessionManager that implements the core logic of setting the active session by ID, returning true if session exists.setActiveSession(id: string): boolean { if (this.sessions.has(id)) { this.activeSessionId = id; return true; } return false; }