Added Repair Diagram Function to SDK Using Backend AI and Credit Management #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new Repair Diagram function to the MermaidChart SDK. The SDK is designed to communicate directly with the MermaidChart backend for internal usage, and this change exposes the existing backend AI repair functionality in a structured and reusable way.
The new function calls the existing AI repair endpoint and relies entirely on backend-managed AI credit handling. User AI credits are validated and consumed on the server side, ensuring secure and consistent credit usage without any client-side logic.
This functionality is required for the MCP server, where a new repair tool will be available after user authentication. The tool uses this SDK function to repair broken Mermaid diagrams and consumes the authenticated user’s AI credits accordingly.
With this addition, the SDK now supports the complete diagram management lifecycle, including:
The implementation follows existing SDK patterns, maintains full backward compatibility, and aligns with current MCP tools for diagram management.