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
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Export format | json |
| session_id | No | Session 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
- src/tools/advanced.ts:658-692 (handler)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, }, ], }; }
- src/tools/advanced.ts:654-657 (schema)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'), },
- src/tools/advanced.ts:651-657 (registration)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); }