Dynamic MCP Input Test 1

Test MCP with dynamic arguments from workflow inputs

Back
Workflow Information

ID: mcp_dynamic_input_test_v4_test1

Namespace: default

Version: 1.0

Created: 2025-07-15

Updated: 2025-07-15

Tasks: 9

Quick Actions
Manage Secrets
Inputs
Name Type Required Default
pdf_url string Optional https://example.com/invoice.pdf
vendor_threshold integer Optional 85
Outputs

No outputs defined

Tasks
download_pdf
script

Mock PDF download from the provided URL

Task Outputs: {'name': 'pdf_path', 'value': '/tmp/invoice.pdf'}
ocr_processing
script

Extract text from PDF using OCR

Task Outputs: {'name': 'ocr_status', 'value': 'OCR completed successfully'}
extract_key_data
script

Extract structured data from OCR results

Task Outputs: {'name': 'extraction_status', 'value': 'Data extraction completed'}
validate_data
script

Validate extracted data quality

Task Outputs: {'name': 'validation_status', 'value': 'Data validation completed'}
check_vendor_sap
script

Verify vendor exists in SAP system

Task Outputs: {'name': 'vendor_check_status', 'value': 'Vendor check completed'}
po_matching
script

Match invoice with purchase order

Task Outputs: {'name': 'po_match_status', 'value': 'PO matching completed'}
post_invoice_sap
script

Create invoice document in SAP

Task Outputs: {'name': 'sap_posting_status', 'value': 'Invoice posted to SAP successfully'}
archive_document
script

Archive the processed PDF document

Task Outputs: {'name': 'archive_status', 'value': 'Document archived successfully'}
send_confirmation
script

Send processing confirmation to stakeholders

Task Outputs: {'name': 'confirmation_status', 'value': 'Processing confirmation sent'}
Triggers
Manual Trigger: Manual Invoice Processing
Webhook Trigger: Invoice Upload Webhook
POST /webhook/invoice-upload
Scheduled Trigger: Batch Processing
YAML Source
id: invoice_processing_workflow
name: Invoice Processing Workflow
tasks:
- id: download_pdf
  name: Download PDF Invoice
  type: script
  script: "#!/usr/bin/env python3\nimport json\nimport os\n\npdf_url = os.environ.get('pdf_url')\n\
    print(f\"Mock downloading PDF from: {pdf_url}\")\n\n# Mock PDF metadata\npdf_info\
    \ = {\n    \"url\": pdf_url,\n    \"filename\": \"invoice_INV-2024-001.pdf\",\n\
    \    \"size_bytes\": 245760,\n    \"content_type\": \"application/pdf\",\n   \
    \ \"download_status\": \"success\"\n}\n\n# Save mock PDF info\nwith open('/tmp/pdf_info.json',\
    \ 'w') as f:\n    json.dump(pdf_info, f, indent=2)\n\n# Create mock PDF file\n\
    with open('/tmp/invoice.pdf', 'w') as f:\n    f.write(\"Mock PDF content - Invoice\
    \ INV-2024-001\")\n\nprint(\"Mock PDF download completed successfully\")\nprint(f\"\
    File: {pdf_info['filename']}, Size: {pdf_info['size_bytes']} bytes\")\n"
  outputs:
  - name: pdf_path
    value: /tmp/invoice.pdf
  packages:
  - json==2.0.9
  description: Mock PDF download from the provided URL
- id: ocr_processing
  name: OCR Processing
  type: script
  script: "#!/usr/bin/env python3\nimport json\nimport os\n\nprint(\"Processing PDF\
    \ with OCR...\")\n\n# Mock OCR results\nocr_results = {\n    \"text_confidence\"\
    : 92,\n    \"extracted_text\": \"INVOICE\\nVendor: ACME Corp\\nInvoice #: INV-2024-001\\\
    nDate: 2024-07-15\\nPO Number: PO-12345\\nAmount: $1,250.00\"\n}\n\nwith open('/tmp/ocr_results.json',\
    \ 'w') as f:\n    json.dump(ocr_results, f, indent=2)\n\nprint(\"OCR processing\
    \ completed\")\n"
  outputs:
  - name: ocr_status
    value: OCR completed successfully
  packages:
  - json==2.0.9
  depends_on:
  - download_pdf
  description: Extract text from PDF using OCR
- id: extract_key_data
  name: Extract Key Data
  type: script
  script: "#!/usr/bin/env python3\nimport json\nimport re\n\n# Load OCR results\n\
    with open('/tmp/ocr_results.json', 'r') as f:\n    ocr_data = json.load(f)\n\n\
    text = ocr_data['extracted_text']\n\n# Mock data extraction\nextracted_data =\
    \ {\n    \"vendor_name\": \"ACME Corp\",\n    \"invoice_number\": \"INV-2024-001\"\
    ,\n    \"invoice_date\": \"2024-07-15\",\n    \"po_number\": \"PO-12345\",\n \
    \   \"amount\": 1250.00,\n    \"currency\": \"USD\"\n}\n\n# Save extracted data\n\
    with open('/tmp/extracted_data.json', 'w') as f:\n    json.dump(extracted_data,\
    \ f, indent=2)\n\nprint(\"Key data extracted successfully\")\nprint(f\"Vendor:\
    \ {extracted_data['vendor_name']}\")\nprint(f\"Amount: ${extracted_data['amount']}\"\
    )\n"
  outputs:
  - name: extraction_status
    value: Data extraction completed
  depends_on:
  - ocr_processing
  description: Extract structured data from OCR results
- id: validate_data
  name: Validate Data
  type: script
  script: "#!/usr/bin/env python3\nimport json\nimport os\n\n# Load extracted data\n\
    with open('/tmp/extracted_data.json', 'r') as f:\n    data = json.load(f)\n\n\
    # Mock validation logic\nvalidation_results = {\n    \"is_valid\": True,\n   \
    \ \"confidence_score\": 95,\n    \"missing_fields\": [],\n    \"validation_errors\"\
    : []\n}\n\n# Check required fields\nrequired_fields = [\"vendor_name\", \"invoice_number\"\
    , \"amount\", \"po_number\"]\nfor field in required_fields:\n    if not data.get(field):\n\
    \        validation_results[\"missing_fields\"].append(field)\n        validation_results[\"\
    is_valid\"] = False\n\n# Save validation results\nwith open('/tmp/validation_results.json',\
    \ 'w') as f:\n    json.dump(validation_results, f, indent=2)\n\nif validation_results[\"\
    is_valid\"]:\n    print(\"Data validation passed\")\nelse:\n    print(\"Data validation\
    \ failed\")\n    print(f\"Missing fields: {validation_results['missing_fields']}\"\
    )\n"
  outputs:
  - name: validation_status
    value: Data validation completed
  depends_on:
  - extract_key_data
  description: Validate extracted data quality
- id: check_vendor_sap
  name: Check Vendor in SAP
  type: script
  script: "#!/usr/bin/env python3\nimport json\nimport os\n\n# Load extracted data\n\
    with open('/tmp/extracted_data.json', 'r') as f:\n    invoice_data = json.load(f)\n\
    \n# Load validation results\nwith open('/tmp/validation_results.json', 'r') as\
    \ f:\n    validation = json.load(f)\n\nif not validation[\"is_valid\"]:\n    print(\"\
    Skipping vendor check - data validation failed\")\n    exit(1)\n\nvendor_name\
    \ = invoice_data[\"vendor_name\"]\nprint(f\"Checking vendor in SAP: {vendor_name}\"\
    )\n\n# Mock SAP vendor lookup\nsap_vendors = {\n    \"ACME Corp\": {\"vendor_id\"\
    : \"V001\", \"status\": \"active\"},\n    \"TechCorp Ltd\": {\"vendor_id\": \"\
    V002\", \"status\": \"active\"}\n}\n\nvendor_info = {\n    \"vendor_exists\":\
    \ vendor_name in sap_vendors,\n    \"vendor_id\": sap_vendors.get(vendor_name,\
    \ {}).get(\"vendor_id\"),\n    \"vendor_status\": sap_vendors.get(vendor_name,\
    \ {}).get(\"status\")\n}\n\nwith open('/tmp/vendor_info.json', 'w') as f:\n  \
    \  json.dump(vendor_info, f, indent=2)\n\nif vendor_info[\"vendor_exists\"]:\n\
    \    print(f\"Vendor found in SAP: {vendor_info['vendor_id']}\")\nelse:\n    print(\"\
    Vendor not found in SAP\")\n"
  outputs:
  - name: vendor_check_status
    value: Vendor check completed
  depends_on:
  - validate_data
  description: Verify vendor exists in SAP system
- id: po_matching
  name: PO Matching
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\n# Load invoice data\nwith open('/tmp/extracted_data.json',\
    \ 'r') as f:\n    invoice_data = json.load(f)\n\n# Load vendor info\nwith open('/tmp/vendor_info.json',\
    \ 'r') as f:\n    vendor_info = json.load(f)\n\npo_number = invoice_data[\"po_number\"\
    ]\nprint(f\"Matching PO: {po_number}\")\n\n# Mock PO matching\npo_database = {\n\
    \    \"PO-12345\": {\n        \"vendor_id\": \"V001\",\n        \"amount\": 1250.00,\n\
    \        \"status\": \"approved\",\n        \"goods_received\": True\n    }\n\
    }\n\npo_match = {\n    \"po_exists\": po_number in po_database,\n    \"po_data\"\
    : po_database.get(po_number, {}),\n    \"three_way_match\": False\n}\n\n# Three-way\
    \ matching logic\nif po_match[\"po_exists\"]:\n    po_data = po_match[\"po_data\"\
    ]\n    po_match[\"three_way_match\"] = (\n        po_data[\"vendor_id\"] == vendor_info.get(\"\
    vendor_id\") and\n        po_data[\"amount\"] == invoice_data[\"amount\"] and\n\
    \        po_data[\"goods_received\"] == True\n    )\n\nwith open('/tmp/po_match.json',\
    \ 'w') as f:\n    json.dump(po_match, f, indent=2)\n\nif po_match[\"three_way_match\"\
    ]:\n    print(\"Three-way match successful\")\nelse:\n    print(\"Three-way match\
    \ failed\")\n"
  outputs:
  - name: po_match_status
    value: PO matching completed
  depends_on:
  - check_vendor_sap
  description: Match invoice with purchase order
- id: post_invoice_sap
  name: Post Invoice to SAP
  type: script
  script: "#!/usr/bin/env python3\nimport json\nimport uuid\n\n# Load all previous\
    \ results\nwith open('/tmp/extracted_data.json', 'r') as f:\n    invoice_data\
    \ = json.load(f)\n\nwith open('/tmp/po_match.json', 'r') as f:\n    po_match =\
    \ json.load(f)\n\nif not po_match[\"three_way_match\"]:\n    print(\"Cannot post\
    \ invoice - three-way match failed\")\n    exit(1)\n\n# Mock SAP posting\nsap_document\
    \ = {\n    \"sap_invoice_number\": f\"SAP-{uuid.uuid4().hex[:8].upper()}\",\n\
    \    \"posting_date\": \"2024-07-15\",\n    \"document_type\": \"MIRO\",\n   \
    \ \"status\": \"posted\",\n    \"invoice_data\": invoice_data\n}\n\nwith open('/tmp/sap_document.json',\
    \ 'w') as f:\n    json.dump(sap_document, f, indent=2)\n\nprint(f\"Invoice posted\
    \ to SAP: {sap_document['sap_invoice_number']}\")\n"
  outputs:
  - name: sap_posting_status
    value: Invoice posted to SAP successfully
  depends_on:
  - po_matching
  description: Create invoice document in SAP
- id: archive_document
  name: Archive PDF Document
  type: script
  script: "#!/usr/bin/env python3\nimport json\nimport os\n\n# Load SAP document info\n\
    with open('/tmp/sap_document.json', 'r') as f:\n    sap_doc = json.load(f)\n\n\
    # Mock archival process\narchive_info = {\n    \"archive_id\": f\"ARCH-{sap_doc['sap_invoice_number']}\"\
    ,\n    \"archive_path\": \"/archive/invoices/2024/07/\",\n    \"archived_date\"\
    : \"2024-07-15T10:30:00Z\",\n    \"retention_years\": 7\n}\n\nwith open('/tmp/archive_info.json',\
    \ 'w') as f:\n    json.dump(archive_info, f, indent=2)\n\nprint(f\"Document archived:\
    \ {archive_info['archive_id']}\")\n"
  outputs:
  - name: archive_status
    value: Document archived successfully
  depends_on:
  - post_invoice_sap
  description: Archive the processed PDF document
- id: send_confirmation
  name: Send Confirmation
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\n# Load final results\nwith open('/tmp/extracted_data.json',\
    \ 'r') as f:\n    invoice_data = json.load(f)\n\nwith open('/tmp/sap_document.json',\
    \ 'r') as f:\n    sap_doc = json.load(f)\n\n# Mock confirmation\nconfirmation\
    \ = {\n    \"processing_status\": \"completed\",\n    \"invoice_number\": invoice_data[\"\
    invoice_number\"],\n    \"sap_document\": sap_doc[\"sap_invoice_number\"],\n \
    \   \"processed_date\": \"2024-07-15T10:30:00Z\",\n    \"notification_sent\":\
    \ True\n}\n\nwith open('/tmp/confirmation.json', 'w') as f:\n    json.dump(confirmation,\
    \ f, indent=2)\n\nprint(\"Confirmation sent successfully\")\nprint(f\"Invoice\
    \ {invoice_data['invoice_number']} processed as {sap_doc['sap_invoice_number']}\"\
    )\n"
  outputs:
  - name: confirmation_status
    value: Processing confirmation sent
  depends_on:
  - archive_document
  description: Send processing confirmation to stakeholders
inputs:
- name: pdf_url
  type: string
  default: https://example.com/invoice.pdf
  description: URL to the PDF invoice document
- name: vendor_threshold
  type: integer
  default: 85
  description: Minimum confidence score for vendor matching
version: '1.0'
triggers:
- name: Manual Invoice Processing
  type: manual
  description: Manually trigger invoice processing
- name: Invoice Upload Webhook
  path: /webhook/invoice-upload
  type: webhook
  config:
    method: POST
    headers:
    - name: Content-Type
      value: application/json
      required: true
    authentication: none
  description: Trigger processing when new invoice is uploaded
  input_mapping:
  - webhook_field: pdf_url
    workflow_input: pdf_url
  - webhook_field: confidence_threshold
    workflow_input: vendor_threshold
- name: Batch Processing
  type: scheduled
  schedule: 0 * * * *
  description: Process invoices in batches every hour
description: Automated workflow for processing PDF invoices with OCR and SAP integration
Execution ID Status Started Duration Actions
670ac88c... COMPLETED 2025-07-15
13:17:57
N/A View
26ca7dc3... COMPLETED 2025-07-15
12:40:15
N/A View