RSCG_MCP2File 10.2025.1212.1953

dotnet add package RSCG_MCP2File --version 10.2025.1212.1953
                    
NuGet\Install-Package RSCG_MCP2File -Version 10.2025.1212.1953
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RSCG_MCP2File" Version="10.2025.1212.1953" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RSCG_MCP2File" Version="10.2025.1212.1953" />
                    
Directory.Packages.props
<PackageReference Include="RSCG_MCP2File" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RSCG_MCP2File --version 10.2025.1212.1953
                    
#r "nuget: RSCG_MCP2File, 10.2025.1212.1953"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RSCG_MCP2File@10.2025.1212.1953
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RSCG_MCP2File&version=10.2025.1212.1953
                    
Install as a Cake Addin
#tool nuget:?package=RSCG_MCP2File&version=10.2025.1212.1953
                    
Install as a Cake Tool

RSCG_MCP2File

NuGet

RSCG_MCP2File is a .NET Standard 2.0 source generator that generates MCP (Microsoft Code Platform) tools that generates exports to file from each MCP function defined

Features

  • Generates an MCP tool that writes the result of another tool to file

Usage

Add RSCG_MCP2File as a NuGet package to your project.

Add the following attribute to your MCP function to generate a file export tool:

[MCP2File.AddMCPExportToFile]
[McpServerToolType]
public partial class WeatherTool
{

In the program.cs file, register the generated tool:

builder.Services.AddMcpServer()
    .WithToolsFromAssembly()

How it works

For each function that returns a value, a corresponding tool will be generated that exports the result to a file. It assumes that the result is either a byte array, a string, or an object that can be converted to a string.

For example

[McpServerToolType]
[MCP2File.AddMCPExportToFile]
public partial class WeatherTool
{
    [McpServerTool, Description("Returns the current weather for a specific city")]
    public string MyGetWeatherForCity(string cityName)
    { 

it generates

  [global::ModelContextProtocol.Server.McpServerTool]
        [global::System.ComponentModel.Description("calls the MyGetWeatherForCity and saves the result to a file . Investigate Success parameter from result and, if false, see the ErrorMessage ")]
        public async Task<MCP2File.ResultWriteToFile> MyGetWeatherForCityExportToFile(string cityName, [global::System.ComponentModel.Description("please use full file path. Do NOT use relative path ")]string exportToFile)
        {
        try{
            dynamic result = MyGetWeatherForCity(cityName);
            if (result is byte[] bytes)
            {
                await File.WriteAllBytesAsync(exportToFile, bytes);
            }
            else if (result is string str)
            {
                await File.WriteAllTextAsync(exportToFile, str);
            }
            else
            {
                await File.WriteAllTextAsync(exportToFile, result?.ToString() ?? string.Empty);
            }
            return MCP2File.ResultWriteToFile.FromSuccess();
        }
        catch (Exception ex)
        {
             return MCP2File.ResultWriteToFile.FromError(ex.Message);
            
        }
        }

The ResultWriteToFile class is defined as:

public class ResultWriteToFile
{
    public bool  Success { get; set; }
    public string? ErrorMessage { get; set; }
    public static ResultWriteToFile FromSuccess() => new ResultWriteToFile { Success = true};
    public static ResultWriteToFile FromError(string errorMessage) => new ResultWriteToFile { Success = false, ErrorMessage = errorMessage };
}

The AI should investigate the Success parameter from the result and, if false, see the ErrorMessage.

License

This project is licensed under the MIT License.

Repository

For more information, visit the GitHub repository.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.2025.1212.1953 138 12/12/2025
9.2025.1208.1952 413 12/8/2025
9.2025.1202.1952 687 12/2/2025
9.2025.1202.817 669 12/2/2025
9.2025.1202.800 724 12/2/2025
9.2025.1201.1800 579 12/1/2025
9.2025.1201.1726 578 12/1/2025