# MCP Tool Definition Template for Adapters

This document provides templates for adding MCP tool definitions to all MW-Core adapters.

## Adapters with MCP Definitions ✅

- [x] AdapterBanking - Core banking transactions
- [x] AdapterKafka - Event streaming
- [x] AdapterAmqp - RabbitMQ messaging  
- [x] AdapterGrpc - gRPC microservices

## Remaining Adapters - Templates

### AdapterDw (Data Warehouse)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_dw",
      description: "Data warehouse adapter for bulk transaction data loading. Handles batch inserts of processed records for analytics and reporting.",
      inputSchema: %{
        type: "object",
        properties: %{
          batch_size: %{
            type: "integer",
            description: "Number of records per batch",
            default: 1000
          },
          table_name: %{
            type: "string",
            description: "Target data warehouse table"
          }
        },
        required: ["table_name"]
      },
      metadata: %{
        timeout_ms: 10000,
        supports_fallback: false,
        async: true,
        protocol: "HTTP/REST"
      }
    }
  end
```

### AdapterHttp (Generic HTTP)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_http",
      description: "Generic configurable HTTP/REST adapter for calling external APIs. Supports dynamic endpoint configuration with auth, timeout, and retry policies.",
      inputSchema: %{
        type: "object",
        properties: %{
          endpoint_name: %{
            type: "string",
            description: "Named endpoint from configuration (e.g., payment_validation, account_lookup)"
          },
          method: %{
            type: "string",
            description: "HTTP method",
            enum: ["GET", "POST", "PUT", "PATCH", "DELETE"]
          },
          body: %{
            type: "object",
            description: "Request body payload"
          },
          query_params: %{
            type: "object",
            description: "URL query parameters"
          }
        },
        required: ["endpoint_name", "method"]
      },
      metadata: %{
        timeout_ms: 5000,
        supports_fallback: true,
        protocol: "HTTP/REST"
      }
    }
  end
```

### AdapterFile (SFTP)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_file",
      description: "SFTP file transfer adapter for batch file processing. Polls configured SFTP locations, downloads CSV files, and feeds rows into processing pipeline.",
      inputSchema: %{
        type: "object",
        properties: %{
          remote_path: %{
            type: "string",
            description: "SFTP remote file path or directory"
          },
          file_pattern: %{
            type: "string",
            description: "File name pattern (glob) for filtering",
            default: "*.csv"
          },
          archive_after_processing: %{
            type: "boolean",
            description: "Move files to archive directory after processing",
            default: true
          }
        },
        required: ["remote_path"]
      },
      metadata: %{
        timeout_ms: 30000,
        supports_fallback: false,
        async: true,
        protocol: "SFTP"
      }
    }
  end
```

### AdapterMqtt (MQTT)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_mqtt",
      description: "MQTT adapter for IoT and lightweight messaging. Publishes messages to MQTT brokers for device communication and telemetry.",
      inputSchema: %{
        type: "object",
        properties: %{
          topic: %{
            type: "string",
            description: "MQTT topic to publish to"
          },
          qos: %{
            type: "integer",
            description: "Quality of Service level (0, 1, or 2)",
            enum: [0, 1, 2],
            default: 1
          },
          retain: %{
            type: "boolean",
            description: "Retain message on broker",
            default: false
          }
        },
        required: ["topic"]
      },
      metadata: %{
        timeout_ms: 3000,
        supports_fallback: true,
        protocol: "MQTT"
      }
    }
  end
```

### AdapterEdi (EDI/X12)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_edi",
      description: "EDI X12/EDIFACT adapter for electronic data interchange with trading partners. Handles EDI document transformation and transmission.",
      inputSchema: %{
        type: "object",
        properties: %{
          transaction_set: %{
            type: "string",
            description: "EDI transaction set type (e.g., 850, 810, 856)"
          },
          partner_id: %{
            type: "string",
            description: "Trading partner identifier"
          },
          document_format: %{
            type: "string",
            description: "EDI format",
            enum: ["X12", "EDIFACT"],
            default: "X12"
          }
        },
        required: ["transaction_set", "partner_id"]
      },
      metadata: %{
        timeout_ms: 8000,
        supports_fallback: true,
        protocol: "EDI/AS2"
      }
    }
  end
```

### AdapterFix (FIX Protocol)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_fix",
      description: "FIX protocol adapter for financial trading and order execution. Supports FIX 4.2/4.4 message exchange with trading systems.",
      inputSchema: %{
        type: "object",
        properties: %{
          message_type: %{
            type: "string",
            description: "FIX message type (e.g., D=NewOrderSingle, G=OrderCancelReplace)"
          },
          sender_comp_id: %{
            type: "string",
            description: "FIX SenderCompID"
          },
          target_comp_id: %{
            type: "string",
            description: "FIX TargetCompID"
          }
        },
        required: ["message_type", "sender_comp_id", "target_comp_id"]
      },
      metadata: %{
        timeout_ms: 2000,
        supports_fallback: true,
        protocol: "FIX 4.4"
      }
    }
  end
```

### AdapterSwift (SWIFT MT)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_swift",
      description: "SWIFT MT message adapter for international banking and financial messaging. Handles MT message formatting and transmission.",
      inputSchema: %{
        type: "object",
        properties: %{
          message_type: %{
            type: "string",
            description: "SWIFT MT message type (e.g., MT103, MT202, MT940)"
          },
          sender_bic: %{
            type: "string",
            description: "Sender Bank Identifier Code (BIC)"
          },
          receiver_bic: %{
            type: "string",
            description: "Receiver Bank Identifier Code (BIC)"
          }
        },
        required: ["message_type", "sender_bic", "receiver_bic"]
      },
      metadata: %{
        timeout_ms: 10000,
        supports_fallback: true,
        protocol: "SWIFT MT"
      }
    }
  end
```

### AdapterJms (JMS/ActiveMQ)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_jms",
      description: "JMS adapter for Java Message Service integration. Supports ActiveMQ and other JMS-compliant brokers.",
      inputSchema: %{
        type: "object",
        properties: %{
          destination: %{
            type: "string",
            description: "JMS queue or topic name"
          },
          destination_type: %{
            type: "string",
            description: "Destination type",
            enum: ["queue", "topic"],
            default: "queue"
          },
          message_properties: %{
            type: "object",
            description: "JMS message properties/headers"
          }
        },
        required: ["destination"]
      },
      metadata: %{
        timeout_ms: 5000,
        supports_fallback: true,
        protocol: "JMS"
      }
    }
  end
```

### AdapterAriticMail (Email Marketing)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_aritic_mail",
      description: "Aritic Mail integration for transactional email delivery and email marketing campaigns.",
      inputSchema: %{
        type: "object",
        properties: %{
          template_id: %{
            type: "string",
            description: "Email template identifier"
          },
          recipient_email: %{
            type: "string",
            description: "Recipient email address"
          },
          personalization_data: %{
            type: "object",
            description: "Template variable substitutions"
          }
        },
        required: ["template_id", "recipient_email"]
      },
      metadata: %{
        timeout_ms: 5000,
        supports_fallback: true,
        protocol: "HTTP/REST"
      }
    }
  end
```

### AdapterAriticMa (Marketing Automation)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_aritic_ma",
      description: "Aritic Marketing Automation integration for customer journey tracking and behavioral triggers.",
      inputSchema: %{
        type: "object",
        properties: %{
          event_type: %{
            type: "string",
            description: "Marketing automation event type"
          },
          contact_email: %{
            type: "string",
            description: "Contact email address"
          },
          event_attributes: %{
            type: "object",
            description: "Event-specific attributes"
          }
        },
        required: ["event_type", "contact_email"]
      },
      metadata: %{
        timeout_ms: 5000,
        supports_fallback: true,
        protocol: "HTTP/REST"
      }
    }
  end
```

### AdapterCloudi (CloudI)
```elixir
  @impl MwKernel.Adapter
  def mcp_tool_definition do
    %{
      name: "adapter_cloudi",
      description: "CloudI integration for distributed service communication and cloud-native messaging.",
      inputSchema: %{
        type: "object",
        properties: %{
          service_name: %{
            type: "string",
            description: "CloudI service name to invoke"
          },
          request_info: %{
            type: "object",
            description: "CloudI request metadata"
          }
        },
        required: ["service_name"]
      },
      metadata: %{
        timeout_ms: 5000,
        supports_fallback: true,
        protocol: "CloudI"
      }
    }
  end
```

## How to Apply

For each adapter module:

1. Open the adapter file (e.g., `apps/adapter_dw/lib/adapter_dw.ex`)
2. Add the MCP tool definition before the final `end`
3. Make sure to add `@impl MwKernel.Adapter` annotation
4. Customize the `description` and `inputSchema` properties based on the adapter's actual functionality
5. Set appropriate `metadata` values (timeout, protocol, etc.)

## Testing

After adding MCP definitions, test discovery:

```elixir
# In IEx
MwKernel.AdapterDiscovery.discover_adapters()
MwKernel.AdapterDiscovery.get_mcp_schemas()
```

The AI Orchestrator will now include these adapters in its context when generating flow proposals.
