generate_diagram
Create Mermaid diagrams from text descriptions to visualize concepts and workflows for documentation in Outline Wiki.
Instructions
Generate a Mermaid diagram from a text description.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes |
Implementation Reference
- src/lib/handlers/smart.ts:193-204 (handler)MCP tool handler for generate_diagram. Checks if brain is enabled, calls brain.generateDiagram, and returns the Mermaid diagram code with rendering instructions.async generate_diagram(args: { description: string }) { if (!brain.isEnabled()) { return { error: ERROR_MESSAGES.SMART_FEATURES_DISABLED }; } const diagram = await brain.generateDiagram(args.description); return { diagram, note: 'Copy this Mermaid code into an Outline document to render the diagram.', }; },
- src/lib/schemas.ts:164-166 (schema)Zod schema defining the input for generate_diagram tool: requires a description string.export const generateDiagramSchema = z.object({ description: z.string().min(1, 'Description is required'), });
- src/lib/tools.ts:225-229 (registration)Tool registration in the allTools array, converting the Zod schema to JSON schema for MCP.createTool( 'generate_diagram', 'Generate a Mermaid diagram from a text description.', 'generate_diagram' ),
- src/lib/brain/index.ts:178-181 (helper)Brain class method that checks if enabled and delegates diagram generation to LlmProcessor.async generateDiagram(description: string): Promise<string> { this.checkEnabled(); return this.processor.generateMermaid(description); }
- src/lib/brain/processor.ts:81-87 (helper)Core implementation in LlmProcessor using OpenAI chat completion with a specific prompt to generate Mermaid code from description.async generateMermaid(description: string): Promise<string> { const prompt = `Convert the following process or flow description into a Mermaid.js diagram. Output ONLY the Mermaid code block, no explanation. Use appropriate diagram type (flowchart, sequence, etc.) based on the content.`; return this.complete(prompt, description); }