RSCG_MCP2OpenAPI by Ignat Andrei
NuGet / site data
Details
Info
info
Name: RSCG_MCP2OpenAPI
Generating Swagger/OpenAPI function from MCP tool.
Author: Ignat Andrei
NuGet: https://www.nuget.org/packages/RSCG_MCP2OpenAPI/
You can find more details at https://github.com/ignatandrei/RSCG_OpenApi2MCP
Author
note
Ignat Andrei

Original Readme
note
This is a place holder
About
note
Generating OpenAPI based on MCP source code.
How to use
Example (source csproj, source files)
- CSharp Project
- Program.cs
- MyTools.cs
This is the CSharp Project that references RSCG_MCP2OpenAPI
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="ModelContextProtocol" Version="0.5.0-preview.1" />
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.5.0-preview.1" />
<PackageReference Include="RSCG_MCP2OpenAPI" Version="9.2025.1202.1952" />
<PackageReference Include="OpenAPISwaggerUI" Version="9.2024.1215.2209" />
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>
This is the use of RSCG_MCP2OpenAPI in Program.cs
// See https://aka.ms/new-console-template for more information
global using Microsoft.AspNetCore.Builder;
using MCPDemo;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using OpenAPISwaggerUI;
Console.WriteLine("Hello, World!");
var builderApp = Host.CreateApplicationBuilder(args);
var builderWeb = WebApplication.CreateBuilder();
// Configure all logs to go to stderr (stdout is used for the MCP protocol messages).
//builder.Logging.AddConsole(o => o.LogToStandardErrorThreshold = LogLevel.Trace);
var serverApp = builderApp.Services
.AddMcpServer();
serverApp = serverApp.WithStdioServerTransport();
serverApp.WithTools<MyTools>();
var serverWeb = builderWeb.Services.AddMcpServer();
serverWeb = serverWeb.WithHttpTransport();
serverWeb.WithTools<MyTools>();
builderWeb.Services.AddOpenApi();
builderWeb.Services.AddTransient<MyTools>();
var app = builderApp.Build();
var web = builderWeb.Build();
web.MapOpenApi();
web.MapOpenApi("/openapi/{documentName}.yaml");
web.MapMcp();
web.UseOpenAPISwaggerUI();
web.AddAll_MyTools();
var t1 = web.RunAsync();
var t2 = app.RunAsync();
await Task.WhenAll(t1, t2);
This is the use of RSCG_MCP2OpenAPI in MyTools.cs
using ModelContextProtocol.Server;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace MCPDemo;
[MCP2OpenAPI.AddMCP2OpenApi()]
partial class MyTools
{
[McpServerTool]
[Description("Echo demo")]
public async Task<string> SendEcho([Description("echo")] string echoData)
{
await Task.Delay(10);
return echoData;
}
}
Generated Files
Those are taken from $(BaseIntermediateOutputPath)\GX
- MCP2OpenAPI.g.cs
- Microsoft.CodeAnalysis.EmbeddedAttribute.cs
- MyTools_ExportToFile.g.cs
namespace MCP2OpenAPI
{
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
[global::System.AttributeUsage(global::System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal class AddMCP2OpenApi: global::System.Attribute {}
}
// <auto-generated/>
namespace Microsoft.CodeAnalysis
{
internal sealed partial class EmbeddedAttribute : global::System.Attribute
{
}
}
namespace MCPDemo;
///Number methods : 1
internal static partial class MyTools_OpenAPI
{
public static void AddAll_MyTools(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder builder){
Add_SendEcho(builder);
}
public record rec_SendEcho ( string? echoData );
public static void Add_SendEcho (Microsoft.AspNetCore.Routing.IEndpointRouteBuilder builder){
builder.MapPost("/api/mcp/MyTools/SendEcho",([Microsoft.AspNetCore.Mvc.FromServices]MCPDemo.MyTools toolClass,[Microsoft.AspNetCore.Mvc.FromBody]rec_SendEcho value)=>
toolClass.SendEcho(value.echoData)
);
}
}
Useful
Download Example (.NET C#)
Share RSCG_MCP2OpenAPI
https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_MCP2OpenAPI
Category "MCP" has the following generators:
1 RSCG_MCP2File
2025-11-15
2 RSCG_MCP2OpenAPI
2025-11-11