Skip to main content
Glama
Abdullah007bajwa

Excalidraw MCP Server

save_scene

Save Excalidraw diagrams to .excalidraw files for persistent storage and future editing.

Instructions

Saves the current Excalidraw elements and scene state to a .excalidraw file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameNoOptional filename ending with .excalidraw (default: mcp_scene.excalidraw)

Implementation Reference

  • Handler for the save_scene tool: validates params with SaveSceneSchema, builds Excalidraw-compatible sceneData from elements and sceneState, converts selectedElements Set to object, fixes points for lines/arrows, writes JSON file via fs.promises.writeFile, returns success/error message.
    case 'save_scene': {
      const params = SaveSceneSchema.parse(args || {});
      const filename = params.filename || 'mcp_scene.excalidraw';
    
      if (!filename.endsWith('.excalidraw')) {
        throw new Error("Filename must end with .excalidraw");
      }
    
      // Convert selectedElements Set to the expected object format
      const selectedElementIds = {};
      sceneState.selectedElements.forEach(id => {
        selectedElementIds[id] = true;
      });
    
      // Ensure all elements have points in the correct format
      const elementsToSave = Array.from(elements.values()).map(el => {
        if ((el.type === 'arrow' || el.type === 'line') && (!el.points || el.points.length < 2)) {
          logger.warn(`Element ${el.id} of type ${el.type} has invalid/missing points. Adding default points.`);
          el.points = [[0, 0], [el.width || 10, el.height || 0]];
        }
        return el;
      });
    
      const sceneData = {
        type: "excalidraw",
        version: 2,
        source: "mcp-server",
        elements: elementsToSave,
        appState: {
          viewBackgroundColor: sceneState.viewBackgroundColor ?? "#ffffff",
          scrollX: sceneState.viewport?.x ?? 0,
          scrollY: sceneState.viewport?.y ?? 0,
          zoom: { value: sceneState.viewport?.zoom ?? 1 }, // Updated zoom format
          selectedElementIds: selectedElementIds, // Updated selectedElementIds format
          gridSize: null,
          zenModeEnabled: false,
          editingGroupId: null,
          theme: sceneState.theme ?? 'light',
          currentItemStrokeColor: "#000000",
          currentItemBackgroundColor: "transparent",
          currentItemFillStyle: "hachure",
          currentItemStrokeWidth: 1,
          currentItemStrokeStyle: "solid",
          currentItemRoughness: 1,
          currentItemOpacity: 100,
          currentItemFontFamily: 1,
          currentItemFontSize: 20,
          currentItemTextAlign: "center",
          currentItemStartArrowhead: null,
          currentItemEndArrowhead: "arrow",
        },
        files: {}
      };
    
      try {
        await fs.writeFile(filename, JSON.stringify(sceneData, null, 2), 'utf8');
        logger.info(`Scene saved successfully to ${filename}`);
        return {
          content: [{ type: 'text', text: `Scene saved successfully to ${filename}` }]
        };
      } catch (error) {
        logger.error(`Error saving scene: ${error.message}`, { error });
        return {
          content: [{ type: 'text', text: `Error saving scene: ${error.message}` }],
          isError: true
        };
      }
    }
  • Zod schema defining the input for save_scene: optional filename string.
    // ADDED: Schema for the new save_scene tool
    const SaveSceneSchema = z.object({
      filename: z.string().optional().describe("Optional filename ending with .excalidraw (default: mcp_scene.excalidraw)")
    });
  • src/index.js:268-280 (registration)
    MCP capabilities registration for save_scene tool, specifying description and inputSchema (note: inputSchema duplicated from zod schema).
    // ADDED: Definition for the save_scene tool
    save_scene: {
      description: 'Saves the current Excalidraw elements and scene state to a .excalidraw file.',
      inputSchema: {
        type: 'object',
        properties: {
          filename: {
            type: 'string',
            description: 'Optional filename ending with .excalidraw (default: mcp_scene.excalidraw)'
          }
        }
      }
    }
  • src/index.js:841-853 (registration)
    Registration of save_scene in the ListToolsRequestSchema handler response.
    {
      name: 'save_scene',
      description: 'Saves the current Excalidraw elements and scene state to a .excalidraw file.',
      inputSchema: {
        type: 'object',
        properties: {
          filename: {
            type: 'string',
            description: 'Optional filename ending with .excalidraw (default: mcp_scene.excalidraw)'
          }
        }
      }
    }
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. It mentions saving to a file but doesn't disclose behavioral traits like whether it overwrites existing files, requires write permissions, handles errors, or what happens if no elements exist. For a mutation 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 with zero waste. It front-loads the core action and resource, making it easy to parse. Every word earns its place by specifying the tool's purpose clearly without redundancy.

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?

Given the tool's moderate complexity (saving scene state) and lack of annotations or output schema, the description is minimally adequate. It covers the basic purpose but lacks details on behavior, error handling, or output format beyond the file extension. For a mutation tool, more context would be helpful, but it meets the minimum viable threshold.

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?

Schema description coverage is 100%, so the schema already documents the single parameter 'filename' with its type, optionality, and default value. The description adds no additional meaning beyond what the schema provides, such as filename constraints or usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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 specific action ('Saves') and the resource ('current Excalidraw elements and scene state'), with the output format specified ('.excalidraw file'). It distinguishes from siblings like 'create_element' or 'update_element' by focusing on file export rather than element manipulation.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing existing elements to save), exclusions, or comparisons with other tools like 'get_resource' which might retrieve files. The description only states what it does, not when it's appropriate.

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/Abdullah007bajwa/mcp_excalidraw'

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