Skip to main content

MCP FTP/FTPS Resource Handler

The FTP/FTPS Resource Handler module provides FTP and FTPS resource support for the MCP Server, allowing remote files on FTP servers to be exposed as MCP resources.

Overview

This module implements the IMcpResourceTypeHandler interface to handle ftp:// URIs. It uses the FluentFTP library to connect to FTP servers and retrieve file content.

Features

  • FTP and FTPS Support: Connect to both standard FTP and secure FTPS servers
  • Credentials Protection: Passwords are encrypted using IDataProtector when stored
  • Export Safety: Passwords are automatically cleared during deployment export
  • MIME Type Detection: Automatic MIME type detection based on file extension

URI Pattern

ftp://{itemId}/{path}
  • {itemId}: The unique identifier of the MCP resource
  • {path}: The path to the file on the FTP server

Configuration

When creating an FTP resource in the admin UI, you can configure:

FieldDescription
HostThe FTP server hostname or IP address
PortThe FTP port (default: 21)
UsernameFTP authentication username
PasswordFTP authentication password (encrypted in storage)
Use SSLEnable FTPS (FTP over SSL/TLS)

Usage

Creating an FTP Resource via Admin UI

  1. Navigate to Artificial IntelligenceMCP Resources
  2. Click Add Resource
  3. Select FTP/FTPS as the resource type
  4. Fill in the connection details:
    • Display Text: A friendly name for the resource
    • URI: ftp://auto-generated-id/path/to/file.txt
    • Name: The MCP resource name
    • Host, Port, Username, Password, Use SSL
  5. Save the resource

Creating an FTP Resource via Recipe

{
"steps": [
{
"name": "McpResource",
"Resources": [
{
"Source": "ftp",
"DisplayText": "Remote Config File",
"Resource": {
"Uri": "ftp://resource-id/config/settings.json",
"Name": "remote-config",
"Description": "Configuration file from FTP server",
"MimeType": "application/json"
},
"Properties": {
"FtpConnectionMetadata": {
"Host": "ftp.example.com",
"Port": 21,
"Username": "user",
"Password": "",
"UseSsl": false
}
}
}
]
}
]
}

Note: Passwords are not exported for security reasons. You must manually set the password after importing.

Dependencies

This module requires:

  • CrestApps.OrchardCore.AI.Mcp (MCP Server module)
  • FluentFTP NuGet package

Security Considerations

  • Password Encryption: Passwords are encrypted at rest using ASP.NET Core Data Protection
  • Export Safety: Passwords are automatically removed during deployment/recipe export
  • FTPS: Use FTPS (SSL/TLS) when possible for encrypted connections
  • Firewall: Ensure your server can reach the FTP host on the configured port

Extending

To create a custom FTP resource handler, you can implement IMcpResourceHandler to handle additional events:

public class CustomFtpMcpResourceHandler : IMcpResourceHandler
{
public void Exporting(ExportingMcpResourceContext context)
{
// Handle export customization
}
}