Skip to main content
Glama

export_session

Export debug session reports in JSON or HTML format to document PHP application debugging sessions for analysis and sharing.

Instructions

Export the current debug session as a report

Input Schema

NameRequiredDescriptionDefault
formatNoExport formatjson
session_idNoSession ID

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "format": { "default": "json", "description": "Export format", "enum": [ "json", "html" ], "type": "string" }, "session_id": { "description": "Session ID", "type": "string" } }, "type": "object" }

Implementation Reference

  • The main handler function for the 'export_session' tool. It resolves the debug session, evaluates current watch expressions, captures a snapshot using SessionExporter, exports the session as JSON or HTML, and returns the report content in the MCP response format.
    async ({ format, session_id }) => { const session = ctx.sessionManager.resolveSession(session_id); if (!session) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No active session' }) }], }; } // Capture final snapshot const watchResults = await ctx.watchManager.evaluateAll(session); await ctx.sessionExporter.captureSnapshot(session, { watchValues: watchResults, }); const exported = format === 'html' ? ctx.sessionExporter.exportAsHtml(session) : ctx.sessionExporter.exportAsJson(session); return { content: [ { type: 'text', text: format === 'html' ? JSON.stringify({ format: 'html', content: exported, note: 'Save this content to a .html file to view the report', }) : exported, }, ], }; }
  • Zod input schema for the 'export_session' tool, validating the format parameter (json or html, default json) and optional session_id.
    { format: z.enum(['json', 'html']).default('json').describe('Export format'), session_id: z.string().optional().describe('Session ID'), },
  • Registration of the 'export_session' tool on the MCP server, specifying the tool name, description, input schema, and handler function reference.
    server.tool( 'export_session', 'Export the current debug session as a report', { format: z.enum(['json', 'html']).default('json').describe('Export format'), session_id: z.string().optional().describe('Session ID'), },
  • Key helper methods in SessionExporter class: exportAsJson serializes the session data to formatted JSON, exportAsHtml generates a complete HTML report. Both use private buildExportedSession and generateHtmlReport.
    exportAsJson(session: DebugSession): string { const exported = this.buildExportedSession(session); return JSON.stringify(exported, null, 2); } /** * Export session as HTML report */ exportAsHtml(session: DebugSession): string { const exported = this.buildExportedSession(session); return this.generateHtmlReport(exported); }

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