Skip to main content
Glama

create_mindmap_from_mermaid

Convert Mermaid mindmap text into a MindManager mindmap, enabling structured visualization from code-based descriptions with metadata support.

Instructions

Deserializes a Mermaid mindmap and creates a MindManager mindmap from it (caller must follow the guidance). Args: mermaid (str): Mermaid text describing the desired mindmap with supported topic metadata, e.g. `[Topic] %% {"id": n, "notes": {"text": "Notes"}, "links": [{"text": "label", "url": "https://example.com"}], "references": [{"id_1": i, "id_2": j, "direction": 1}], "image": {"text": "C:\path\to\image.png"}, "icons": [{"text": "StockIcon-36", "is_stock_icon": true, "index": 36}], "tags": ["tag1"]}` Guidance for callers constructing `mermaid`: - Every line must be syntactically correct Mermaid code and contain at least a topic label, e.g. `[Topic]`. - For the root topic just use the label, e.g. `[Central Topic]` - Full syntax supports attaching metadata via JSON after `%%` on the same line, e.g. `[Topic] %% {"id": n, "notes": {"text": "Notes"}, "links": [{"text": "label", "url": "https://example.com"}], "references": [{"id_1": i, "id_2": j, "direction": 1}], "image": {"text": "C:\path\to\image.png"}, "icons": [{"text": "StockIcon-36", "is_stock_icon": true, "index": m}], "tags": ["tag1"]}` - For icons, use `icons`: `[{"text": "StockIcon-<index>", "is_stock_icon": true, "index": <index>}]` where available options for stock icons are: Arrow Down(66), Arrow Left(65), Arrow Right(37), Arrow Up(36), Bomb(51), Book(67), Broken Connection(69), Calendar(8), Camera(41), Cellphone(40), Check(62), Clock(7), Coffee Cup(59), Dollar(15), Email(10), Emergency(49), Euro(16), Exclamation Mark(44), Fax(42), Flag Black(20), Flag Blue(18), Flag Green(19), Flag Orange(21), Flag Purple(23), Flag Red(17), Flag Yellow(22), Folder(71), Glasses(53), Hourglass(48), House(13), Information(70), Judge Hammer(54), Key(52), Letter(9), Lightbulb(58), Magnifying Glass(68), Mailbox(11), Marker 1(25), Marker 2(26), Marker 3(27), Marker 4(28), Marker 5(29), Marker 6(30), Marker 7(31), Meeting(61), Megaphone(12), No Entry(50), Note(63), On Hold(47), Padlock Locked(34), Padlock Unlocked(35), Phone(39), Question Mark(45), Redo(57), Resource 1(32), Resource 2(33), Rocket(55), Rolodex(14), Scales(56), Smiley Angry(5), Smiley Happy(2), Smiley Neutral(3), Smiley Sad(4), Smiley Screaming(6), Stop(43), Thumbs Down(64), Thumbs Up(46), Traffic Lights Red(24), Two End Arrow(38), Two Feet(60). Returns: Dict[str, str]: Status dictionary indicating success or error details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mermaidYes

Implementation Reference

  • Main handler function decorated with @mcp.tool() that implements the core logic: input validation, deserialization via _deserialize_mermaid, mindmap creation in MindManager, and error handling. The function signature and docstring define the tool schema.
    @mcp.tool() async def create_mindmap_from_mermaid( mermaid: str ) -> Dict[str, str]: """ Deserializes a Mermaid mindmap and creates a MindManager mindmap from it (caller must follow the guidance). Args: mermaid (str): Mermaid text describing the desired mindmap with supported topic metadata, e.g. `[Topic] %% {"id": n, "notes": {"text": "Notes"}, "links": [{"text": "label", "url": "https://example.com"}], "references": [{"id_1": i, "id_2": j, "direction": 1}], "image": {"text": "C:\\path\\to\\image.png"}, "icons": [{"text": "StockIcon-36", "is_stock_icon": true, "index": 36}], "tags": ["tag1"]}` Guidance for callers constructing `mermaid`: - Every line must be syntactically correct Mermaid code and contain at least a topic label, e.g. `[Topic]`. - For the root topic just use the label, e.g. `[Central Topic]` - Full syntax supports attaching metadata via JSON after `%%` on the same line, e.g. `[Topic] %% {"id": n, "notes": {"text": "Notes"}, "links": [{"text": "label", "url": "https://example.com"}], "references": [{"id_1": i, "id_2": j, "direction": 1}], "image": {"text": "C:\\path\\to\\image.png"}, "icons": [{"text": "StockIcon-36", "is_stock_icon": true, "index": m}], "tags": ["tag1"]}` - For icons, use `icons`: `[{"text": "StockIcon-<index>", "is_stock_icon": true, "index": <index>}]` where available options for stock icons are: Arrow Down(66), Arrow Left(65), Arrow Right(37), Arrow Up(36), Bomb(51), Book(67), Broken Connection(69), Calendar(8), Camera(41), Cellphone(40), Check(62), Clock(7), Coffee Cup(59), Dollar(15), Email(10), Emergency(49), Euro(16), Exclamation Mark(44), Fax(42), Flag Black(20), Flag Blue(18), Flag Green(19), Flag Orange(21), Flag Purple(23), Flag Red(17), Flag Yellow(22), Folder(71), Glasses(53), Hourglass(48), House(13), Information(70), Judge Hammer(54), Key(52), Letter(9), Lightbulb(58), Magnifying Glass(68), Mailbox(11), Marker 1(25), Marker 2(26), Marker 3(27), Marker 4(28), Marker 5(29), Marker 6(30), Marker 7(31), Meeting(61), Megaphone(12), No Entry(50), Note(63), On Hold(47), Padlock Locked(34), Padlock Unlocked(35), Phone(39), Question Mark(45), Redo(57), Resource 1(32), Resource 2(33), Rocket(55), Rolodex(14), Scales(56), Smiley Angry(5), Smiley Happy(2), Smiley Neutral(3), Smiley Sad(4), Smiley Screaming(6), Stop(43), Thumbs Down(64), Thumbs Up(46), Traffic Lights Red(24), Two End Arrow(38), Two Feet(60). Returns: Dict[str, str]: Status dictionary indicating success or error details. """ if not mermaid or not mermaid.strip(): return {"error": "Invalid Input", "message": "Mermaid content is required."} try: print("Creating mindmap from Mermaid diagram (full).", file=sys.stderr) _deserialize_mermaid(mermaid=mermaid, turbo_mode=False) print("Mindmap created from Mermaid diagram.", file=sys.stderr) ret_val = {"status": "success", "message": "Mindmap created from Mermaid diagram."} return ret_val except Exception as e: return _handle_mindmanager_error("create_mindmap_from_mermaid", e)
  • Key helper function that performs the Mermaid deserialization using serialization.deserialize_mermaid_full, creates a MindmapDocument instance, sets the mindmap, and calls create_mindmap() to apply it to MindManager.
    def _deserialize_mermaid(mermaid="", turbo_mode=True): guid_mapping = {} deserialized = serialization.deserialize_mermaid_full(mermaid, guid_mapping) document = _get_document_instance(turbo_mode=turbo_mode) document.mindmap = deserialized document.create_mindmap() return None
  • Helper to create MindmapDocument instance used in deserialization and mindmap creation.
    def _get_document_instance( charttype: str = 'auto', turbo_mode: bool = False, inline_editing_mode: bool = False, mermaid_mode: bool = True, macos_access: str = MACOS_ACCESS_METHOD ) -> MindmapDocument: document = MindmapDocument( charttype=charttype, turbo_mode=turbo_mode, inline_editing_mode=inline_editing_mode, mermaid_mode=mermaid_mode, macos_access=macos_access ) return document
  • Helper function to format and return standardized error responses for MindManager operations, used in the handler.
    def _handle_mindmanager_error(func_name: str, e: Exception) -> Dict[str, str]: """Formats MindManager errors for MCP response.""" error_message = f"Error during MindManager operation '{func_name}': {e}" print(f"ERROR: {error_message}", file=sys.stderr) # Check for specific known errors from mindm.mindmanager if possible if "No document found" in str(e): return {"error": "MindManager Error", "message": "No document found or MindManager not running."} # Add more specific error checks here based on mindm library return {"error": "MindManager Error", "message": f"An error occurred: {e}"}

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/robertZaufall/mindm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server