RSCG_MCP2OpenAPI 9.2025.1208.1952
dotnet add package RSCG_MCP2OpenAPI --version 9.2025.1208.1952
NuGet\Install-Package RSCG_MCP2OpenAPI -Version 9.2025.1208.1952
<PackageReference Include="RSCG_MCP2OpenAPI" Version="9.2025.1208.1952" />
<PackageVersion Include="RSCG_MCP2OpenAPI" Version="9.2025.1208.1952" />
<PackageReference Include="RSCG_MCP2OpenAPI" />
paket add RSCG_MCP2OpenAPI --version 9.2025.1208.1952
#r "nuget: RSCG_MCP2OpenAPI, 9.2025.1208.1952"
#:package RSCG_MCP2OpenAPI@9.2025.1208.1952
#addin nuget:?package=RSCG_MCP2OpenAPI&version=9.2025.1208.1952
#tool nuget:?package=RSCG_MCP2OpenAPI&version=9.2025.1208.1952
RSCG_MCP2OpenAPI
RSCG_MCP2OpenAPI is a .NET Standard 2.0 source generator that , from MCP tools , generates SWAGGER / OPEN API
Features
- Generates /api/mcp/{className}/{funcName} endpoint for any MCP tools
What it generates
For example, given the following MCP tool definition:
[McpServerToolType]
[MCP2OpenAPI.AddMCP2OpenApi]
public partial class WeatherTool
{
[McpServerTool, Description("echoes the UTC date time in sortable format")]
public string CurrentISODateTime()
{
return DateTime.UtcNow.ToString("s");
}
[McpServerTool, Description("echoes the string")]
public string EchoBack(string theString)
{
return theString;
}
The generator will produce the following endpoints:
internal static partial class WeatherTool_OpenAPI
{
public static void AddAll_WeatherTool(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder builder){
Add_CurrentISODateTime(builder);
Add_EchoBack(builder);
Add_Add2Numbers(builder);
Add_MyGetWeatherForCity(builder);
}
public static void Add_CurrentISODateTime (Microsoft.AspNetCore.Routing.IEndpointRouteBuilder builder){
builder.MapPost("/api/mcp/WeatherTool/CurrentISODateTime",([Microsoft.AspNetCore.Mvc.FromServices]OA2MCP_TestMe.WeatherTool toolClass)=>
toolClass.CurrentISODateTime()
);
}
public record rec_EchoBack ( string? theString );
public static void Add_EchoBack (Microsoft.AspNetCore.Routing.IEndpointRouteBuilder builder){
builder.MapPost("/api/mcp/WeatherTool/EchoBack",([Microsoft.AspNetCore.Mvc.FromServices]OA2MCP_TestMe.WeatherTool toolClass,[Microsoft.AspNetCore.Mvc.FromBody]rec_EchoBack value)=>
toolClass.EchoBack(value.theString)
);
}
How to use
Add RSCG_MCP2OpenAPI as a NuGet package to your project. The generator will automatically run at build time and generate the necessary swagger code from tool definition.
Add to your Program.cs or Startup.cs the following line to register the generated endpoints:
/// Add MCP Server tool as service
builder.Services.AddTransient<WeatherTool>();
//code
//app.MapGet("/", () => "todo");
//assuming your MCP tool class is named WeatherTool
app.AddAll_WeatherTool();
License
This project is licensed under the MIT License.
Repository
For more information, visit the GitHub repository.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
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 |
|---|---|---|
| 9.2025.1208.1952 | 420 | 12/8/2025 |
| 9.2025.1202.1952 | 139 | 12/6/2025 |