export_tree
Export hierarchical research trees to JSON, Markdown, Mermaid, or DOT formats for visualization and documentation purposes.
Instructions
Export a tiling tree in various formats for visualization or documentation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| treeId | Yes | ID of the tree to export | |
| format | Yes | Export format |
Implementation Reference
- src/research-tree.ts:975-993 (handler)Core handler implementation for the 'export_tree' tool. Dispatches to format-specific export methods based on the input format parameter.export(format: string, treeId: string): string { const tree = this.trees.get(treeId); if (!tree) { throw new Error(`Tree ${treeId} not found`); } switch (format) { case "json": return this.exportJSON(tree); case "markdown": return this.exportMarkdown(tree); case "mermaid": return this.exportMermaid(tree); case "dot": return this.exportDOT(tree); default: throw new Error(`Unknown export format: ${format}`); } }
- src/index.ts:343-361 (schema)Input schema definition for the 'export_tree' tool, specifying required parameters treeId and format with allowed enum values.{ name: "export_tree", description: "Export a tiling tree in various formats for visualization or documentation", inputSchema: { type: "object", properties: { treeId: { type: "string", description: "ID of the tree to export", }, format: { type: "string", enum: ["json", "markdown", "mermaid", "dot"], description: "Export format", }, }, required: ["treeId", "format"], }, },
- src/index.ts:627-639 (handler)MCP server dispatch handler case for 'export_tree' that invokes treeManager.export and formats the response.case "export_tree": { const result = treeManager.export( args.format as any, args.treeId as string ); return { content: [ { type: "text", text: result, }, ], };
- src/index.ts:393-395 (registration)Registers the list of tools including 'export_tree' via the TOOLS constant for MCP tool discovery.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS, }));
- src/research-tree.ts:1020-1058 (helper)Helper function used by exportMarkdown to recursively build the markdown representation of the tree.private tileToMarkdown(tile: Tile, depth: number): string { const indent = " ".repeat(depth); const prefix = "#".repeat(Math.min(depth + 2, 6)); let md = `${indent}${prefix} ${tile.title}\n\n`; md += `${indent}${tile.description}\n\n`; if (tile.splitAttribute) { md += `${indent}**Split by:** ${tile.splitAttribute}\n`; if (tile.splitRationale) { md += `${indent}**Rationale:** ${tile.splitRationale}\n`; } if (tile.isMECE !== undefined) { md += `${indent}**MECE Validated:** ${tile.isMECE ? "✓" : "✗"}\n`; } md += "\n"; } if (tile.isLeaf && tile.evaluation) { md += `${indent}**Evaluation:**\n`; const evaluation = tile.evaluation; if (evaluation.impact) md += `${indent}- Impact: ${evaluation.impact}/10\n`; if (evaluation.feasibility) md += `${indent}- Feasibility: ${evaluation.feasibility}/10\n`; if (evaluation.uniqueness) md += `${indent}- Uniqueness: ${evaluation.uniqueness}/10\n`; if (evaluation.timeframe) md += `${indent}- Timeframe: ${evaluation.timeframe}\n`; if (evaluation.notes) md += `${indent}- Notes: ${evaluation.notes}\n`; md += "\n"; } // Add children for (const childId of tile.childrenIds) { const child = this.tiles.get(childId); if (child) { md += this.tileToMarkdown(child, depth + 1); } } return md; }