Skip to main content
Glama
DrBalls

n8n MCP Server

by DrBalls

n8n_export_workflow

Export n8n workflows as JSON files for backup purposes or to transfer them between different n8n instances.

Instructions

Export a workflow as JSON for backup or import elsewhere.

Args:

  • id (string): Workflow ID to export

Returns: Complete workflow JSON that can be imported into another n8n instance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesWorkflow ID to export

Implementation Reference

  • The implementation of the `n8n_export_workflow` tool, which retrieves a workflow by ID, sanitizes it by removing instance-specific fields, and returns the JSON.
      server.registerTool(
        'n8n_export_workflow',
        {
          title: 'Export Workflow JSON',
          description: `Export a workflow as JSON for backup or import elsewhere.
    
    Args:
      - id (string): Workflow ID to export
    
    Returns:
      Complete workflow JSON that can be imported into another n8n instance.`,
          inputSchema: z.object({
            id: z.string().min(1).describe('Workflow ID to export')
          }).strict(),
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false
          }
        },
        async (params: { id: string }) => {
          const workflow = await get<Record<string, unknown>>(`/workflows/${params.id}`);
          
          // Remove instance-specific fields for export
          const exportable = { ...workflow };
          delete exportable.id;
          delete exportable.createdAt;
          delete exportable.updatedAt;
          delete exportable.versionId;
          
          const json = JSON.stringify(exportable, null, 2);
          
          return {
            content: [{ type: 'text', text: `**Exported Workflow: ${(workflow as { name?: string }).name || params.id}**\n\n\`\`\`json\n${json}\n\`\`\`` }],
            structuredContent: exportable
          };
        }
      );

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/DrBalls/n8n-mcp-server-v2'

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