Skip to main content
Glama

create_from_mermaid

Convert Mermaid diagrams to Excalidraw elements for collaborative diagramming and visualization.

Instructions

Convert a Mermaid diagram to Excalidraw elements

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mermaidDiagramYes
configNo

Implementation Reference

  • Tool registration and inline handler implementation for create_from_mermaid. This is the actual executing code that parses mermaidDiagram and config, calls client.convertMermaid(), and returns success/error messages.
    // --- Tool: create_from_mermaid ---
    server.tool(
      'create_from_mermaid',
      'Convert a Mermaid diagram to Excalidraw elements',
      {
        mermaidDiagram: z.string().min(1).max(LIMITS.MAX_MERMAID_LENGTH),
        config: z.object({
          startOnLoad: z.boolean().optional(),
          flowchart: z.object({ curve: z.enum(['linear', 'basis']).optional() }).optional(),
          themeVariables: z.object({ fontSize: z.string().max(10).optional() }).optional(),
          maxEdges: z.number().int().min(1).max(1000).optional(),
          maxTextSize: z.number().int().min(1).max(100000).optional(),
        }).optional(),
      },
      async ({ mermaidDiagram, config }) => {
        try {
          await client.convertMermaid(mermaidDiagram, config as Record<string, unknown>);
          return {
            content: [{
              type: 'text',
              text: 'Mermaid conversion broadcast to canvas. Elements will appear when a frontend client is connected.',
            }],
          };
        } catch (err) {
          return { content: [{ type: 'text', text: `Error: ${(err as Error).message}` }], isError: true };
        }
      }
    );
  • Zod schema definition for Mermaid diagram conversion input validation. Defines the structure for mermaidDiagram string and optional config object.
    export const MermaidSchema = z
      .object({
        mermaidDiagram: z.string().min(1).max(LIMITS.MAX_MERMAID_LENGTH),
        config: z
          .object({
            startOnLoad: z.boolean().optional(),
            flowchart: z
              .object({})
              .strict()
              .optional(),
            themeVariables: z
              .object({})
              .strict()
              .optional(),
            maxEdges: z.number().int().min(1).max(1000).optional(),
            maxTextSize: z.number().int().min(1).max(100_000).optional(),
          })
          .strict()
          .optional(),
      })
      .strict();
  • CanvasClient method that performs the actual HTTP POST request to /api/elements/from-mermaid endpoint with the mermaid diagram and config.
    async convertMermaid(
      mermaidDiagram: string,
      config?: Record<string, unknown>
    ): Promise<void> {
      const res = await fetch(`${this.baseUrl}/api/elements/from-mermaid`, {
        method: 'POST',
        headers: this.headers(),
        body: JSON.stringify({ mermaidDiagram, config }),
      });
    
      if (!res.ok) {
        const body = await res.json().catch(() => ({})) as ApiResponse;
        throw new Error(body.error ?? `Canvas error: ${res.status}`);
      }
    }
  • Alternative exported handler function that uses MermaidSchema for validation and calls client.convertMermaid(). Note: This function is exported but not currently used by the MCP server registration.
    import type { CanvasClient } from '../canvas-client.js';
    import { MermaidSchema } from '../schemas/element.js';
    
    export async function createFromMermaidTool(
      args: unknown,
      client: CanvasClient
    ) {
      const { mermaidDiagram, config } = MermaidSchema.parse(args);
      await client.convertMermaid(
        mermaidDiagram,
        config as Record<string, unknown> | undefined
      );
      return { success: true, message: 'Mermaid conversion sent to canvas' };
    }
  • Sandbox server registration for capability scanning. This is a noop registration used for Smithery capability detection.
    server.tool('create_from_mermaid', 'Convert a Mermaid diagram to Excalidraw elements', { mermaidDiagram: z.string().min(1).max(LIMITS.MAX_MERMAID_LENGTH) }, noop);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the conversion action but doesn't describe what happens during conversion (e.g., error handling for invalid diagrams, performance characteristics, or output format). For a transformation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to understand at a glance. Every part of the sentence earns its place by conveying essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (2 parameters with nested objects, no annotations, no output schema), the description is incomplete. It doesn't address behavioral aspects like error handling or output format, and with 0% schema coverage, parameter details are missing. For a conversion tool with configurable options, more context is needed to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning parameters are undocumented in the schema. The description adds no information about parameters beyond what the schema provides (e.g., it doesn't explain what 'mermaidDiagram' should contain or how 'config' affects conversion). With 2 parameters (one required, one optional with nested objects) and low coverage, the description fails to compensate for the schema's lack of documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: converting Mermaid diagrams to Excalidraw elements. It uses specific verbs ('convert') and identifies the resource ('Mermaid diagram') and target ('Excalidraw elements'). However, it doesn't explicitly differentiate from sibling tools like 'create_element' or 'batch_create_elements', which might also create elements but from different sources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid Mermaid diagram), exclusions (e.g., what types of diagrams are supported), or comparisons to siblings like 'create_element' (which might create elements manually). Usage is implied from the purpose but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/debu-sinha/excalidraw-mcp-server'

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