Skip to main content
Glama

Create Excalidraw View

create_view

Render Excalidraw elements as interactive inline diagrams by providing element arrays with coordinates and styling. Diagrams stream progressively during generation.

Instructions

Render Excalidraw elements as an interactive inline diagram. Pass an array of elements with type, x, y coordinates and optional styling. The diagram streams in progressively as elements are generated. Use read_me first to see available element types and color palettes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementsYes
titleNo
backgroundNo

Implementation Reference

  • The main handler function handleCreateView that processes create_view tool calls. It accepts elements and optional title, optionally persists elements to store, and returns the diagram data as JSON text content.
    export async function handleCreateView(
      args: CreateViewArgs,
      persistToStore?: (elements: Record<string, unknown>[]) => Promise<void>
    ): Promise<{ content: Array<{ type: 'text'; text: string }> }> {
      const { elements, title } = args;
    
      // Persist elements to the store so other tools can reference them
      if (persistToStore) {
        await persistToStore(elements as unknown as Record<string, unknown>[]);
      }
    
      const result = {
        title: title ?? 'Excalidraw Diagram',
        elementCount: elements.length,
        elements,
      };
    
      return {
        content: [{
          type: 'text' as const,
          text: JSON.stringify(result, null, 2),
        }],
      };
    }
  • Zod schema definitions for create_view input validation. Includes viewElementSchema for individual elements (with type, coordinates, styling options) and CREATE_VIEW_SCHEMA for the main tool input (elements array, optional title, and background).
    const viewElementSchema = z.object({
      type: z.enum(ELEMENT_TYPES),
      x: CoordZ,
      y: CoordZ,
      width: DimZ,
      height: DimZ,
      points: z.array(PointZ).max(LIMITS.MAX_POINTS).optional(),
      backgroundColor: ColorZ,
      strokeColor: ColorZ,
      strokeWidth: z.number().min(0).max(LIMITS.MAX_STROKE_WIDTH).finite().optional(),
      roughness: z.number().min(0).max(LIMITS.MAX_ROUGHNESS).finite().optional(),
      opacity: z.number().min(LIMITS.MIN_OPACITY).max(LIMITS.MAX_OPACITY).finite().optional(),
      text: z.string().max(LIMITS.MAX_TEXT_LENGTH).optional(),
      fontSize: z.number().min(1).max(LIMITS.MAX_FONT_SIZE).finite().optional(),
      fontFamily: z.number().int().min(1).max(4).optional(),
      groupIds: z.array(z.string().max(LIMITS.MAX_GROUP_ID_LENGTH)).max(LIMITS.MAX_GROUP_IDS).optional(),
      locked: z.boolean().optional(),
      angle: z.number().min(-360).max(360).finite().optional(),
    });
    
    export const CREATE_VIEW_SCHEMA = {
      elements: z.array(viewElementSchema).min(1).max(LIMITS.MAX_BATCH_SIZE),
      title: z.string().max(200).optional(),
      background: ColorZ,
    };
  • Registration of the create_view tool using registerAppTool from MCP Apps SDK. Includes tool metadata (title, description, UI resource URI) and wraps handleCreateView with error handling.
    registerAppTool(
      server,
      'create_view',
      {
        title: 'Create Excalidraw View',
        description:
          'Render Excalidraw elements as an interactive inline diagram. ' +
          'Pass an array of elements with type, x, y coordinates and optional styling. ' +
          'The diagram streams in progressively as elements are generated. ' +
          'Use read_me first to see available element types and color palettes.',
        inputSchema: CREATE_VIEW_SCHEMA,
        _meta: {
          ui: { resourceUri: WIDGET_RESOURCE_URI },
        },
      },
      async (args: CreateViewArgs) => {
        try {
          return await handleCreateView(args, opts.persistToStore);
        } catch (err) {
          return {
            content: [{ type: 'text' as const, text: `Error: ${(err as Error).message}` }],
            isError: true,
          };
        }
      }
    );
  • Helper type validators and constants used in the schema. Defines coordinate, dimension, color, and point validators, plus the ELEMENT_TYPES array enumerating supported shape types.
    const CoordZ = z.number().min(LIMITS.MIN_COORDINATE).max(LIMITS.MAX_COORDINATE).finite();
    const DimZ = z.number().min(0).max(LIMITS.MAX_DIMENSION).finite().optional();
    const ColorZ = z.string().max(LIMITS.MAX_COLOR_LENGTH).optional();
    const PointZ = z.object({ x: CoordZ, y: CoordZ });
    
    const ELEMENT_TYPES = [
      'rectangle', 'ellipse', 'diamond', 'arrow',
      'text', 'line', 'freedraw',
    ] as const;
  • Type definition for CreateViewArgs inferred from the Zod schema, providing TypeScript type safety for the handler function.
    export type CreateViewArgs = z.infer<z.ZodObject<typeof CREATE_VIEW_SCHEMA>>;
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It reveals important behavioral traits: the diagram 'streams in progressively as elements are generated' and the tool creates an 'interactive inline diagram.' However, it doesn't address whether this is a read-only or write operation, what permissions might be needed, or any rate limits or error conditions.

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 perfectly concise with three sentences that each serve distinct purposes: stating the core function, describing parameter usage, and providing prerequisite guidance. There's no wasted language, and the information is front-loaded with the most important details first.

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

Completeness3/5

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

For a tool with 3 parameters, no annotations, no output schema, and 0% schema description coverage, the description provides adequate but incomplete context. It explains the main purpose and gives some parameter guidance but doesn't fully compensate for the missing structured information about behavior, output format, or all parameters.

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

Parameters3/5

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

The description mentions the 'elements' parameter ('Pass an array of elements with type, x, y coordinates and optional styling') which adds some context beyond the schema's 0% description coverage. However, with 3 total parameters and only 1 mentioned in the description, it doesn't fully compensate for the schema's lack of parameter descriptions. The baseline is appropriate given the partial coverage.

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

Purpose5/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 with specific verbs ('Render Excalidraw elements as an interactive inline diagram') and distinguishes it from siblings by specifying it creates a view rather than individual elements or other operations. It identifies the resource (Excalidraw elements) and output format (interactive inline diagram).

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Render Excalidraw elements as an interactive inline diagram') and includes a helpful prerequisite ('Use read_me first to see available element types and color palettes'). However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools.

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