{
  "name": "MCP convert_file Tool Backend (FFmpeg/Convert Fleet API)",
  "nodes": [
    {
      "name": "Webhook - convert_file",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "mcp-convert-file",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "name": "Prepare Conversion Request",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        500,
        300
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "apiBase",
              "type": "string",
              "value": "https://api.example.com/v1"
            },
            {
              "id": "2",
              "name": "apiKey",
              "type": "string",
              "value": "YOUR_CONVERTFLEET_API_KEY"
            },
            {
              "id": "3",
              "name": "sourceUrl",
              "type": "string",
              "value": "={{ $json.body.file_url }}"
            },
            {
              "id": "4",
              "name": "targetFormat",
              "type": "string",
              "value": "={{ $json.body.target_format }}"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Submit Conversion Job",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        760,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "={{ $json.apiBase }}/convert",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.apiKey }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"source_url\": $json.sourceUrl, \"target_format\": $json.targetFormat, \"engine\": \"ffmpeg\" } }}",
        "options": {}
      }
    },
    {
      "name": "Job Completed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1020,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "cond1",
              "leftValue": "={{ $json.status }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "name": "Format Success Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1280,
        180
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "status",
              "type": "string",
              "value": "success"
            },
            {
              "id": "2",
              "name": "download_url",
              "type": "string",
              "value": "={{ $json.output_url }}"
            },
            {
              "id": "3",
              "name": "format",
              "type": "string",
              "value": "={{ $json.target_format }}"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Format Error Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1280,
        420
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "status",
              "type": "string",
              "value": "error"
            },
            {
              "id": "2",
              "name": "message",
              "type": "string",
              "value": "={{ $json.error || 'Conversion job did not complete' }}"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Respond to MCP Client",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1540,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      }
    },
    {
      "name": "Setup Notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        240,
        60
      ],
      "parameters": {
        "width": 460,
        "height": 200,
        "content": "## MCP convert_file Tool Backend\n\nThis workflow is the HTTP backend your MCP server calls when Claude Code (or any MCP client) invokes the `convert_file` tool, instead of shelling out to local ffmpeg.\n\n1. Replace `YOUR_CONVERTFLEET_API_KEY` in **Prepare Conversion Request** with your real Convert Fleet / FFmpeg API key (use n8n Credentials in production instead of a raw string).\n2. Replace `https://api.example.com/v1` with your actual Convert Fleet API base URL.\n3. Copy the Webhook's Production URL into your MCP server's tool handler as the `convert_file` endpoint.\n4. POST body expected: `{ \"file_url\": ..., \"target_format\": ... }`."
      }
    }
  ],
  "connections": {
    "Webhook - convert_file": {
      "main": [
        [
          {
            "node": "Prepare Conversion Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Conversion Request": {
      "main": [
        [
          {
            "node": "Submit Conversion Job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit Conversion Job": {
      "main": [
        [
          {
            "node": "Job Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Job Completed?": {
      "main": [
        [
          {
            "node": "Format Success Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Success Response": {
      "main": [
        [
          {
            "node": "Respond to MCP Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Error Response": {
      "main": [
        [
          {
            "node": "Respond to MCP Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {}
}