close_session
Terminate an active Xdebug debugging session to end PHP application debugging and release debugger resources.
Instructions
Close and terminate a debug session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | No | Session ID to close (uses active session if not specified) |
Implementation Reference
- src/tools/session.ts:178-211 (handler)Executes the close_session tool: resolves session by ID or active, closes it via sessionManager, returns JSON success or error message.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', }), }, ], }; } const closedId = session.id; sessionManager.closeSession(closedId); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Session "${closedId}" closed`, }), }, ], }; }
- src/tools/session.ts:172-177 (schema)Zod input schema: optional session_id string.{ session_id: z .string() .optional() .describe('Session ID to close (uses active session if not specified)'), },
- src/tools/session.ts:168-212 (registration)Registers the close_session tool using server.tool() with name, description, schema, and handler.// Close a session server.tool( 'close_session', 'Close and terminate a debug session', { session_id: z .string() .optional() .describe('Session ID to close (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', }), }, ], }; } const closedId = session.id; sessionManager.closeSession(closedId); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Session "${closedId}" closed`, }), }, ], }; } );
- src/session/manager.ts:125-133 (helper)SessionManager.closeSession(id): closes the session by calling session.close() and returns boolean success.closeSession(id: string): boolean { const session = this.sessions.get(id); if (session) { session.close(); // The 'close' event handler will remove it from the map return true; } return false; }