Skip to main content
Glama

update

Modify existing n8n workflow files by providing updated JSON content and file paths to streamline automation development and maintenance.

Instructions

Update an existing n8n workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the workflow file relative to workflows root
workflowYesThe updated workflow JSON object

Implementation Reference

  • Main handler function that performs the actual update: preserves workflow metadata (ID, createdAt), writes the new JSON to file, marks as edited, updates documentation and credentials.
    async updateWorkflow(workflowPath: string, workflow: any): Promise<any> {
      try {
        const fullPath = path.join(this.workflowsPath, workflowPath);
        
        // Try to preserve the existing workflow ID if it exists
        try {
          const existingContent = await fs.readFile(fullPath, 'utf-8');
          const existingWorkflow = JSON.parse(existingContent);
          
          // Preserve important metadata from existing workflow
          if (existingWorkflow.id && !workflow.id) {
            workflow.id = existingWorkflow.id;
            console.error(`Preserving workflow ID: ${workflow.id}`);
          }
          if (existingWorkflow.createdAt && !workflow.createdAt) {
            workflow.createdAt = existingWorkflow.createdAt;
          }
          // Always update the updatedAt timestamp
          workflow.updatedAt = new Date().toISOString();
        } catch (readError) {
          // File might not exist yet or might be invalid JSON
          console.error('Could not read existing workflow, creating new');
        }
        
        await fs.writeFile(fullPath, stringifyWorkflowFile(workflow));
        
        // Mark as edited in change tracker
        const relativePath = path.relative(this.workflowsPath, fullPath);
        await this.changeTracker.markEdited(relativePath);
        
        // Update documentation
        const workflowName = path.basename(workflowPath, '.json');
        
        try {
          const customInstructions = await this.documenter.getCustomInstructions();
          await this.documenter.updateWorkflowDocumentation(workflowName, workflow, 'update', customInstructions);
          
          // Extract and update credentials
          const credentials = this.initializer.extractCredentialsFromWorkflow(workflow);
          if (credentials.size > 0) {
            await this.initializer.updateEnvExample(credentials);
          }
          
          // Update README with workflow list
          const allWorkflows = await this.getWorkflowList();
          await this.initializer.updateReadmeWorkflowList(allWorkflows);
        } catch (docError) {
          console.error('Failed to update documentation:', docError);
          // Don't fail the workflow update if documentation fails
        }
        
        return {
          content: [
            {
              type: 'text',
              text: `โœ… Workflow Updated!\n\n` +
                    `๐Ÿ“ File: ${workflowPath}\n` +
                    `๐Ÿ“ Name: ${workflowName}\n\n` +
                    `The workflow and documentation have been updated.`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to update workflow: ${error}`);
      }
    }
  • ToolHandler switch case that dispatches 'update' tool calls to WorkflowManager.updateWorkflow
    case 'update':
      return await this.workflowManager.updateWorkflow(
        args?.path as string,
        args?.workflow as any
      );
  • Input schema definition for the 'update' tool, specifying path and workflow object as required inputs.
    {
      name: 'update',
      description: 'Update an existing n8n workflow',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to the workflow file relative to workflows root',
          },
          workflow: {
            type: 'object',
            description: 'The updated workflow JSON object',
          },
        },
        required: ['path', 'workflow'],
      },
    },
  • MCP server registration for tool calls, which invokes ToolHandler.handleTool for any tool including 'update'
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      return await this.toolHandler.handleTool(
        request.params.name,
        request.params.arguments
      );
    });
  • MCP server registration for listing tools, which returns the tool definitions including 'update' from registry.ts
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: getToolDefinitions(),
    }));
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 this is an update operation, implying mutation, but doesn't cover critical aspects like required permissions, whether changes are reversible, potential side effects (e.g., on deployed workflows), or error handling. This leaves significant gaps for a mutation tool.

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 directly states the tool's purpose without unnecessary elaboration. It's appropriately sized and front-loaded, making it easy 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 updating workflows (a mutation operation with nested objects) and the lack of annotations and output schema, the description is insufficient. It doesn't address behavioral traits, usage context, or output expectations, leaving the agent with incomplete guidance for proper tool invocation.

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 schema description coverage is 100%, with both parameters ('path' and 'workflow') well-documented in the schema. The description doesn't add any meaningful semantic context beyond what the schema provides (e.g., it doesn't explain the structure of the workflow JSON or path conventions). Baseline 3 is appropriate as the schema handles the heavy lifting.

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 action ('Update') and the resource ('an existing n8n workflow'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from other update-related siblings like 'configure_tracking' or 'add_node', which could also involve modifications to workflows or related components.

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. With siblings like 'create' (for new workflows), 'read' (for viewing), and 'deploy' (for activating changes), there's no indication of prerequisites, scenarios where this is preferred, or exclusions (e.g., not for creating new workflows).

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