MCPfiedSwagger 0.0.3-preview

This is a prerelease version of MCPfiedSwagger.
dotnet add package MCPfiedSwagger --version 0.0.3-preview
                    
NuGet\Install-Package MCPfiedSwagger -Version 0.0.3-preview
                    
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="MCPfiedSwagger" Version="0.0.3-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MCPfiedSwagger" Version="0.0.3-preview" />
                    
Directory.Packages.props
<PackageReference Include="MCPfiedSwagger" />
                    
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 MCPfiedSwagger --version 0.0.3-preview
                    
#r "nuget: MCPfiedSwagger, 0.0.3-preview"
                    
#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 MCPfiedSwagger@0.0.3-preview
                    
#: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=MCPfiedSwagger&version=0.0.3-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MCPfiedSwagger&version=0.0.3-preview&prerelease
                    
Install as a Cake Tool

MCPfiedSwagger 🚀

An ASP.NET extension that generates a Model Context Protocol (MCP) server, enabling seamless conversion of existing REST APIs as MCP tools, now with enhanced authorization support and improved schema descriptions.

NuGet

📦 Installation

Install the MCPfiedSwagger NuGet package from your preferred NuGet source:

dotnet add package MCPfiedSwagger --version 0.0.1-preview

Or via the NuGet Package Manager:

PM> Install-Package MCPfiedSwagger -Version 0.0.1-preview

⚙️ Usage

  1. Add the MCPfiedSwagger service in your ASP.NET Core project. In your Program.cs, register the service after adding controllers and Swagger:
builder.Services.AddMCPfiedSwagger();
  1. Enable the middleware in your HTTP pipeline, after mapping controllers:
app.UseMCPfiedSwagger();
  1. Configure Swagger (optional): By default, the Swagger/OpenAPI document is named "v1". To specify a different document name, pass it as an argument:
app.UseMCPfiedSwagger("v1");
  1. Specify the MCP endpoint (optional): The default MCP endpoint is /mcp. To change it, provide the desired path:
app.UseMCPfiedSwagger("v1", "/custom-mcp-endpoint");

🔒 Authorization Support

Authorization support is now integrated. You can enable stateless authorization easily:

builder.Services.AddMCPfiedSwagger()
    .AddAuthorization();

The authorization process validates controller actions based on Authorize attributes and handles unauthorized requests gracefully.

📝 Example

A minimal Program.cs setup:

using MCPfiedSwagger.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddMCPfiedSwagger();

var app = builder.Build();

app.UseSwagger();
app.UseSwaggerUI();

app.UseAuthorization();
app.MapControllers();

// Enable MCP endpoint at /mcp for the "v1" Swagger document
app.UseMCPfiedSwagger();

app.Run();

▶️ Running the Example Project

With Authentication Example

  1. Restore dependencies and build:
dotnet restore
dotnet build
  1. Run the authentication example project:
dotnet run --project MCPfiedSwagger.Authenticated
  1. Access the Swagger UI: Open 🌐 http://localhost:<port>/swagger in your browser.

  2. Test Authorization:

    • Authenticate via POST /api/Auth/login with username test and password password.
    • Use the received JWT token as your authorization header when connecting to your MCP endpoint.

Standard Example

Run the original example project:

dotnet run --project MCPfiedSwagger.Example
  • Swagger UI: 🌐 http://localhost:<port>/swagger
  • MCP Endpoint: 🔗 http://localhost:<port>/mcp

💡 Notes

  • The NuGet package depends on ModelContextProtocol.AspNetCore and Swashbuckle.AspNetCore.
  • Ensure your project targets .NET 9.0 or compatible.
  • For more details, see the project repository.
  • Streamable HTTP MCP does not work on https for some reason. Still trying to investigate the issue I encountered.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in 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
0.0.3-preview 17 7/18/2025
0.0.2-preview 114 7/13/2025
0.0.1-preview 73 7/12/2025