Crestapps core mcp file resources

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core mcp file resources is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for exposing FTP, FTPS and SFTP files as CrestApps.Core MCP resource types with the consolidated CrestApps.Core.AI.Ftp and CrestApps.Core.AI.Sftp packages. Covers AddFtpResources, AddSftpResources, AddCoreAIFtpMcpResources and AddCoreAISftpMcpResources, FtpResourceTypeHandler and SftpResourceT

How to use this skill

Skill file

CrestApps.Core MCP File Resources

Expose files on an FTP, FTPS or SFTP server to MCP clients as resources. In 2.0 each protocol lives in one package that also carries the file source ingestion connector for the same protocol (see crestapps-core-file-sources). Registering one side does not register the other.

| Package | MCP resource registration | Ingestion connector registration |

|---|---|---|

| CrestApps.Core.AI.Ftp | AddFtpResources() / AddCoreAIFtpMcpResources() | AddCoreFtpIngestionConnector() |

| CrestApps.Core.AI.Sftp | AddSftpResources() / AddCoreAISftpMcpResources() | AddCoreSftpIngestionConnector() |

Register Both Resource Types

using CrestApps.Core.AI.Ftp;
using CrestApps.Core.AI.Mcp;
using CrestApps.Core.AI.Sftp;

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddMcpServer(mcpServer => mcpServer
            .AddYesSqlStores()
            .AddFtpResources()
            .AddSftpResources())));

Without the builder:

builder.Services
    .AddCoreAIMcpServer()
    .AddCoreAIFtpMcpResources()
    .AddCoreAISftpMcpResources();

Both registration methods take an optional Action<McpResourceTypeEntry> to change the display name, description or variables. The MCP server itself (SDK transport, WithCrestAppsHandlers(), MapMcp) is covered in crestapps-core-mcp.

Handlers

Attach FTP Metadata

using CrestApps.Core;
using CrestApps.Core.AI.Ftp;
using CrestApps.Core.AI.Ftp.Models;

var protector = dataProtectionProvider.CreateProtector(FtpResourceConstants.DataProtectionPurpose);

resource.Put(new FtpConnectionMetadata
{
    Host = "files.example.com",
    Port = 21,
    Username = "reader",
    Password = protector.Protect(password),
    EncryptionMode = "Explicit",
    DataConnectionType = "AutoPassive",
    ConnectTimeout = 30,
    ReadTimeout = 30,
    RetryAttempts = 2,
});

A connection with a Username must use EncryptionMode Explicit or Implicit; unset, None and Auto can run in plain text and are refused unless the host sets FtpOptions.AllowUnencrypted. ValidateAnyCertificate is honored only when the host sets FtpOptions.AllowAnyCertificate; otherwise the connection is refused with FtpOptions.AnyCertificateNotAllowedMessage. Anonymous connections are not affected. Both checks are FtpOptions.GetPolicyViolation(metadata), used by the resource handler and the ingestion connector:

using CrestApps.Core.AI.Ftp;

// Development servers only.
builder.Services.Configure<FtpOptions>(options =>
{
    options.AllowAnyCertificate = true;
    options.AllowUnencrypted = true;
});

Attach SFTP Metadata

using CrestApps.Core;
using CrestApps.Core.AI.Sftp;
using CrestApps.Core.AI.Sftp.Models;

var protector = dataProtectionProvider.CreateProtector(SftpResourceConstants.DataProtectionPurpose);

resource.Put(new SftpConnectionMetadata
{
    Host = "sftp.example.com",
    Port = 22,
    Username = "reader",
    PrivateKey = protector.Protect(privateKeyPem),
    Passphrase = protector.Protect(passphrase),
    HostKeyFingerprint = "SHA256:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU", // as ssh-keygen -lf prints it
    ConnectionTimeout = 30,
    KeepAliveInterval = 30,
});

The handler requires Host, at least one protected Password or PrivateKey, and HostKeyFingerprint (SHA256:... or the legacy MD5 hex form; separate several with commas to rotate a key). SftpHostKeys refuses the connection when no fingerprint is stored or the server presents a different key, so credentials never reach an unverified server (the factory throws InvalidOperationException, the handler returns an error result). It reads Username for the SSH authentication methods. SftpConnectionMetadata declares ProxyType, ProxyHost, ProxyPort, ProxyUsername and ProxyPassword, but the resource handler does not apply them to its ConnectionInfo.

| Constant | Value |

|---|---|

| FtpResourceConstants.DataProtectionPurpose | FtpResourcePassword |

| SftpResourceConstants.DataProtectionPurpose | SftpResourceCredentials |

The ingestion connectors decrypt with the same purposes, so a file source and an MCP resource can share the same stored connection shape. A mismatched purpose reads back as no credential rather than an error.

Resource Records

Create an McpResource whose Source is ftp or sftp and whose Resource.Uri is a fixed URI or a template containing {path}, then Put(...) the connection metadata on it. The metadata is read at resource-read time and is never shown to the MCP client. Use an IMcpResourceHandler.Exporting handler to remove credentials when resources are exported.

Upgrading Within 2.0 Previews

Upgrading from 1.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.