Skip to main content
Glama
huiseo
by huiseo

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
NameRequiredDescriptionDefault
descriptionYes

Implementation Reference

  • 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.',
      };
    },
  • 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'),
    });
  • 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'
    ),
  • 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);
    }
  • 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);
      }

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/huiseo/outline-wiki-mcp'

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