Skip to main content
Glama

add_checkpoint

Add checkpoint save/restore capability to n8n workflows, enabling workflow state preservation and recovery at specific nodes.

Instructions

Add a checkpoint save/restore capability to a workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the workflow file
checkpointNameYesName for the checkpoint
afterNodeNoNode to add checkpoint after (for saving)
addRestoreNoAlso add checkpoint restore at workflow start

Implementation Reference

  • Main handler for 'add_checkpoint' tool: reads workflow, injects checkpoint logic via TrackingInjector, saves modified workflow.
    case 'add_checkpoint':
      const checkpointPath = args?.path as string;
      const checkpointName = args?.checkpointName as string;
      const afterNode = args?.afterNode as string;
      const addRestore = args?.addRestore as boolean;
    
      // Read workflow
      const fullCheckpointPath = path.join(this.workflowsPath, checkpointPath);
      const checkpointWorkflowContent = await fs.readFile(fullCheckpointPath, 'utf-8');
      const checkpointWorkflow = JSON.parse(checkpointWorkflowContent);
    
      // Use configured storage URL or environment variable
      const checkpointStorageUrl = this.trackingConfig.storageUrl || process.env.WORKFLOW_STORAGE_URL;
    
      if (!checkpointStorageUrl) {
        return {
          content: [{
            type: 'text',
            text: '❌ Storage URL not configured. Use configure_tracking to set storageUrl or set WORKFLOW_STORAGE_URL environment variable.'
          }]
        };
      }
    
      // Create injector
      const checkpointInjector = new TrackingInjector({
        enabled: true,
        storageUrl: checkpointStorageUrl,
        enableCheckpoints: true
      });
    
      // Add checkpoint
      let modifiedCheckpointWorkflow = checkpointWorkflow;
    
      if (afterNode) {
        // Add save checkpoint after specified node
        modifiedCheckpointWorkflow = await checkpointInjector.injectTracking(checkpointWorkflow, {
          checkpoints: [{ afterNode, checkpointName }]
        });
      }
    
      if (addRestore) {
        // Add restore checkpoint at workflow start
        modifiedCheckpointWorkflow = await checkpointInjector.addCheckpointRestore(
          modifiedCheckpointWorkflow,
          checkpointName
        );
      }
    
      // Save modified workflow
      await fs.writeFile(fullCheckpointPath, JSON.stringify(modifiedCheckpointWorkflow, null, 2));
    
      return {
        content: [{
          type: 'text',
          text: `✅ Added checkpoint "${checkpointName}" to workflow\\n\\n` +
            (afterNode ? `Save checkpoint after: ${afterNode}\\n` : '') +
            (addRestore ? `Restore checkpoint at workflow start\\n` : '') +
            `Storage URL: ${checkpointStorageUrl}`
        }]
      };
  • Tool registration including name, description, and input schema for 'add_checkpoint' in getToolDefinitions().
    {
      name: 'add_checkpoint',
      description: 'Add a checkpoint save/restore capability to a workflow',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to the workflow file',
          },
          checkpointName: {
            type: 'string',
            description: 'Name for the checkpoint',
          },
          afterNode: {
            type: 'string',
            description: 'Node to add checkpoint after (for saving)',
          },
          addRestore: {
            type: 'boolean',
            description: 'Also add checkpoint restore at workflow start',
          },
        },
        required: ['path', 'checkpointName'],
      },
    },
  • Helper method addCheckpointRestore in TrackingInjector: adds restore node and IF node for checkpoint restoration at workflow start.
    async addCheckpointRestore(workflow: any, checkpointName: string): Promise<any> {
      const modifiedWorkflow = JSON.parse(JSON.stringify(workflow));
    
      // Create checkpoint restore node
      const restoreNode = this.tracker.createCheckpointRestoreNode(
        checkpointName,
        { x: 100, y: 200 }
      );
    
      // Create IF node to check if checkpoint exists
      const ifNode = {
        parameters: {
          conditions: {
            boolean: [
              {
                value1: '={{$json.checkpointData}}',
                operation: 'isNotEmpty'
              }
            ]
          }
        },
        id: 'if_checkpoint_' + Date.now(),
        name: `Check ${checkpointName} Exists`,
        type: 'n8n-nodes-base.if',
        typeVersion: 2,
        position: [350, 200]
      };
    
      // Add nodes
      modifiedWorkflow.nodes.push(restoreNode);
      modifiedWorkflow.nodes.push(ifNode);
    
      // Connect restore to IF
      modifiedWorkflow.connections[restoreNode.name] = {
        main: [[{ node: ifNode.name, type: 'main', index: 0 }]]
      };
    
      // IF node will have two outputs: true (has checkpoint) and false (no checkpoint)
      // These need to be connected to appropriate workflow paths
    
      return modifiedWorkflow;
    }
  • Private helper addCheckpoints: inserts checkpoint save nodes after specified target nodes in the workflow, rewiring connections.
    private addCheckpoints(workflow: any, checkpoints: Array<{ afterNode: string; checkpointName: string }>) {
      for (const checkpoint of checkpoints) {
        const targetNode = workflow.nodes.find((n: any) => n.name === checkpoint.afterNode);
        if (!targetNode) continue;
    
        // Create checkpoint node
        const checkpointNode = this.tracker.createCheckpointNode(
          checkpoint.checkpointName,
          {
            x: targetNode.position[0] + 250,
            y: targetNode.position[1] + 50
          }
        );
    
        // Add to workflow
        workflow.nodes.push(checkpointNode.node);
    
        // Insert checkpoint between target and its connections
        const existingConnections = workflow.connections[checkpoint.afterNode]?.main?.[0] || [];
        
        // Connect checkpoint to target's destinations
        if (existingConnections.length > 0) {
          workflow.connections[checkpointNode.node.name] = {
            main: [existingConnections]
          };
        }
        
        // Connect target to checkpoint
        workflow.connections[checkpoint.afterNode] = {
          main: [[{ node: checkpointNode.node.name, type: 'main', index: 0 }]]
        };
      }
    }
  • Input schema definition for the 'add_checkpoint' tool validation.
    inputSchema: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'Path to the workflow file',
        },
        checkpointName: {
          type: 'string',
          description: 'Name for the checkpoint',
        },
        afterNode: {
          type: 'string',
          description: 'Node to add checkpoint after (for saving)',
        },
        addRestore: {
          type: 'boolean',
          description: 'Also add checkpoint restore at workflow start',
        },
      },
      required: ['path', 'checkpointName'],
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. While 'Add a checkpoint save/restore capability' implies a mutation operation, it doesn't specify permissions, side effects, error handling, or response format. For a tool with no annotations, 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 is appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 of a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits, error conditions, and what the tool returns. The high schema coverage helps with parameters, but overall context is insufficient for safe and effective use.

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 input schema has 100% description coverage, so the schema already documents all four parameters. The description doesn't add any additional meaning or context about the parameters beyond what the schema provides. This meets the baseline for high schema coverage but doesn't enhance parameter understanding.

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: 'Add a checkpoint save/restore capability to a workflow.' It specifies the verb ('add') and resource ('checkpoint save/restore capability'), making it clear what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'add_node' or 'add_tracking,' which prevents a perfect score.

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. There is no mention of prerequisites, context, or exclusions, and it doesn't reference any sibling tools for comparison. This leaves the agent with minimal usage context beyond the basic purpose.

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/mckinleymedia/mcflow-mcp'

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