{
  "name": "FFmpeg Conversion API for AI Agents (MCP Tool Backend)",
  "nodes": [
    {
      "name": "MCP Convert Tool Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "path": "convert-file",
        "httpMethod": "POST",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "name": "Prepare Conversion Request",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        300
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "source_url",
              "type": "string",
              "value": "={{ $json.body.source_url }}"
            },
            {
              "id": "a2",
              "name": "target_format",
              "type": "string",
              "value": "={{ $json.body.target_format }}"
            },
            {
              "id": "a3",
              "name": "tool_name",
              "type": "string",
              "value": "={{ $json.body.tool_name || 'convert_file' }}"
            },
            {
              "id": "a4",
              "name": "request_id",
              "type": "string",
              "value": "={{ $json.body.request_id }}"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Call FFmpeg Conversion API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        300
      ],
      "parameters": {
        "url": "https://api.example.com/v1/convert",
        "method": "POST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"source_url\": $json.source_url, \"target_format\": $json.target_format, \"wait_for_completion\": true } }}",
        "options": {
          "timeout": 60000
        }
      }
    },
    {
      "name": "Conversion Successful?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        900,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.status }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "name": "Log Converted File",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        1120,
        180
      ],
      "parameters": {
        "operation": "create",
        "base": {
          "value": "YOUR_AIRTABLE_BASE_ID",
          "mode": "id"
        },
        "table": {
          "value": "Conversions",
          "mode": "id"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Source URL": "={{ $json.source_url }}",
            "Target Format": "={{ $json.target_format }}",
            "Download URL": "={{ $json.download_url }}",
            "Status": "={{ $json.status }}",
            "Converted At": "={{ $now }}"
          }
        },
        "options": {}
      }
    },
    {
      "name": "Respond to MCP Client",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1340,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"request_id\": $json.request_id, \"status\": $json.status, \"download_url\": $json.download_url || null, \"error\": $json.error || null } }}",
        "options": {}
      }
    },
    {
      "name": "Setup Notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        240,
        520
      ],
      "parameters": {
        "width": 460,
        "height": 260,
        "content": "## Setup\n1. Replace `https://api.example.com/v1/convert` with your FFmpeg conversion API base URL.\n2. Add an HTTP Header Auth credential (or paste your key) replacing `YOUR_API_KEY`.\n3. Create an Airtable Personal Access Token credential and set `YOUR_AIRTABLE_BASE_ID` + table `Conversions` (Source URL, Target Format, Download URL, Status, Converted At).\n4. Deploy this workflow, then expose the Webhook URL as the `convert_file` tool endpoint in your MCP tool config (source_url, target_format, request_id).\n5. Point your AI agent's MCP client at this URL instead of shelling out to local ffmpeg."
      }
    }
  ],
  "connections": {
    "MCP Convert Tool Webhook": {
      "main": [
        [
          {
            "node": "Prepare Conversion Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Conversion Request": {
      "main": [
        [
          {
            "node": "Call FFmpeg Conversion API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call FFmpeg Conversion API": {
      "main": [
        [
          {
            "node": "Conversion Successful?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversion Successful?": {
      "main": [
        [
          {
            "node": "Log Converted File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to MCP Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Converted File": {
      "main": [
        [
          {
            "node": "Respond to MCP Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {}
}