{
  "name": "File Conversion API for AI Agents (MCP-ready)",
  "nodes": [
    {
      "id": "webhook_trigger",
      "name": "Webhook - Convert File Request",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -200,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "convert-file",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "set_prepare_request",
      "name": "Prepare Conversion Request",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        40,
        300
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "assign-1",
              "name": "apiKey",
              "value": "YOUR_API_KEY",
              "type": "string"
            },
            {
              "id": "assign-2",
              "name": "fileUrl",
              "value": "={{ $json.body.file_url }}",
              "type": "string"
            },
            {
              "id": "assign-3",
              "name": "sourceFormat",
              "value": "={{ $json.body.source_format }}",
              "type": "string"
            },
            {
              "id": "assign-4",
              "name": "targetFormat",
              "value": "={{ $json.body.target_format || 'pdf' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "http_convert_call",
      "name": "Call Conversion API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.example.com/v1/convert",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.apiKey }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"file_url\": $json.fileUrl, \"source_format\": $json.sourceFormat, \"target_format\": $json.targetFormat } }}",
        "options": {
          "timeout": 60000
        }
      }
    },
    {
      "id": "if_success",
      "name": "Conversion Successful?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        520,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "cond-1",
              "leftValue": "={{ $json.status }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "gdrive_upload",
      "name": "Save Converted File to Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        760,
        180
      ],
      "parameters": {
        "operation": "upload",
        "name": "={{ $json.converted_file_name || 'converted-output' }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root"
        },
        "options": {}
      }
    },
    {
      "id": "respond_success",
      "name": "Respond - Success",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1000,
        180
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"status\": \"success\", \"download_url\": $json.webContentLink || $json.result_url } }}",
        "options": {}
      }
    },
    {
      "id": "respond_error",
      "name": "Respond - Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        760,
        420
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"status\": \"error\", \"message\": $json.error || \"Conversion failed\" } }}",
        "options": {
          "responseCode": 500
        }
      }
    },
    {
      "id": "sticky_note_setup",
      "name": "Setup Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -200,
        520
      ],
      "parameters": {
        "width": 400,
        "height": 240,
        "content": "## Setup\n1. Replace YOUR_API_KEY in 'Prepare Conversion Request' with your conversion API key.\n2. Point 'Call Conversion API' url at your file-conversion API endpoint (PDF/Office/image/audio-video via ffmpeg).\n3. Connect a Google Drive credential on the 'Save Converted File to Drive' node, or swap it for S3/Supabase Storage.\n4. Activate this workflow to expose a webhook your MCP server / AI agent can POST to: { file_url, source_format, target_format }.\n5. Agent receives back { status, download_url } to hand the converted file to the user."
      }
    }
  ],
  "connections": {
    "Webhook - Convert File Request": {
      "main": [
        [
          {
            "node": "Prepare Conversion Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Conversion Request": {
      "main": [
        [
          {
            "node": "Call Conversion API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Conversion API": {
      "main": [
        [
          {
            "node": "Conversion Successful?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversion Successful?": {
      "main": [
        [
          {
            "node": "Save Converted File to Drive",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond - Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Converted File to Drive": {
      "main": [
        [
          {
            "node": "Respond - Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {}
}