serialize_current_mindmap_to_mermaid
Convert the active mind map to Mermaid format for visualization, with options to control detail level and include only IDs or text content.
Instructions
Serializes the currently loaded mindmap to Mermaid format.
Args:
id_only (bool): If True, only include IDs without detailed attributes. Defaults to False.
mode (str): Detail level ('full', 'content', 'text'). Defaults to 'full'.
turbo_mode (bool): Enable turbo mode (text only). Defaults to False.
Returns:
Union[str, Dict[str, str]]: Mermaid formatted string or error dictionary.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id_only | No | ||
| mode | No | full | |
| turbo_mode | No |
Implementation Reference
- mindm_mcp/server.py:281-306 (handler)Primary handler for the 'serialize_current_mindmap_to_mermaid' MCP tool. Decorated with @mcp.tool() for automatic registration. Calls internal _serialize_mermaid helper, handles MindManager errors, and returns Mermaid diagram or error dict.@mcp.tool() async def serialize_current_mindmap_to_mermaid( id_only: bool = False, mode: str = 'full', turbo_mode: bool = False ) -> Union[str, Dict[str, str]]: """ Serializes the currently loaded mindmap to Mermaid format. Args: id_only (bool): If True, only include IDs without detailed attributes. Defaults to False. mode (str): Detail level ('full', 'content', 'text'). Defaults to 'full'. turbo_mode (bool): Enable turbo mode (text only). Defaults to False. Returns: Union[str, Dict[str, str]]: Mermaid formatted string or error dictionary. """ try: print(f"Serializing current mindmap to Mermaid (id_only={id_only}).", file=sys.stderr) text = _serialize_mermaid(id_only=id_only, mode=mode, turbo_mode=turbo_mode) print("Serialization to Mermaid successful.", file=sys.stderr) return text except Exception as e: print(f"ERROR during serialization to Mermaid: {e}", file=sys.stderr) return {"error": "Serialization Error", "message": f"Failed to serialize to Mermaid: {e}"}
- mindm_mcp/server.py:123-131 (helper)Core helper function that retrieves the current mindmap from MindManager via MindmapDocument, builds GUID-to-ID mapping, and serializes the mindmap structure to Mermaid format using the external 'serialization' module.def _serialize_mermaid(id_only=True, mode='content', turbo_mode=False): document = _get_document_instance(turbo_mode=turbo_mode) if document.get_mindmap(mode=mode): guid_mapping = {} serialization.build_mapping(document.mindmap, guid_mapping) mermaid = serialization.serialize_mindmap(document.mindmap, guid_mapping, id_only=id_only) return mermaid return None
- mindm_mcp/server.py:281-281 (registration)The @mcp.tool() decorator on the handler function registers 'serialize_current_mindmap_to_mermaid' as an MCP tool in the FastMCP server instance 'mcp'.@mcp.tool()