mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-02 01:20:23 +08:00
feat: add PNG/SVG export to MCP server (#687)
* feat: add PNG/SVG export support to MCP server export_diagram tool Previously export_diagram only supported .drawio XML files. This adds PNG and SVG export by leveraging the existing browser sync mechanism: the MCP tool sets an exportFormat flag on the session state, the browser detects it via polling and triggers an iframe export, then POSTs the result back as exportData which the tool reads and writes to disk. * fix: address PR review feedback for export feature - Validate exportData is a string in POST /api/state - Update lastUpdated in setExportFormat to prevent session expiry - Gate export postMessage on isReady to avoid lost messages - Remove unused fmt variable - Fix double extension when path has a different supported extension * fix: resolve high severity npm audit vulnerabilities Run npm audit fix to update @aws-sdk and @smithy transitive dependencies that had high severity advisories, which was failing the CI security audit step. * fix: address second round of PR review feedback - Add 8s timeout for pendingMcpExport to prevent permanent blocking - Move export trigger after version update in poll() to export latest diagram - Return 404 when session not found for exportData POST - Sync browser state before .drawio export to avoid stale XML - Handle URL-encoded SVG data URIs in addition to base64 * fix: address third round of PR review feedback - Sync browser state before PNG/SVG export (not just drawio) - Add 10MB body size limit on POST /api/state - Validate export response format matches request to prevent race conditions * refactor: remove over-engineered defensive code from export feature Strip unnecessary validation/guards added from Copilot review that don't make sense for a localhost-only MCP server: body size limit, type validation, 404 for missing session, lastUpdated refresh, URL-encoded SVG handling. Also deduplicate requestSync call. * refactor: keep original drawio export path unchanged Don't restructure the existing drawio logic - just add png/svg as a separate branch after it. * refactor: remove redundant helper functions, inline state access Remove setExportFormat/getExportData/clearExportData wrappers that were each called once. Access state fields directly via getState(). * chore: bump mcp-server version to 0.1.16
This commit is contained in:
3122
package-lock.json
generated
3122
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user