Romatech.Extensions.Ai.Mcp 3.0.0

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

Romatech.Extensions.Ai

NuGet License: MIT

A plug-and-play AI enablement framework for ASP.NET Core applications. Transforms existing APIs into MCP-compatible tool providers, AI-readable semantic documentation, and RAG-enabled knowledge sources — without architectural rewrites.

Node.js version? See @romatech/ai-extensions for the equivalent framework in Node.js.

Installation

dotnet add package Romatech.Extensions.Ai

Quick Start

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();

// Your OpenAPI generator of choice (Swashbuckle, Scalar, MS OpenApi, etc.)
builder.Services.AddSwaggerGen();

// One line to enable MCP + RAG — auto-detects your OpenAPI endpoint
builder.Services.UseMcp();
builder.Services.UseRag();

var app = builder.Build();

// Your API docs UI (managed by you — the lib doesn't render anything)
app.UseSwagger();
app.UseSwaggerUI();

// AI capabilities
app.UseMcp();
app.UseRag();

app.MapControllers();
app.Run();

That's it. Your APIs are now AI-consumable.

How It Works

The framework automatically:

  1. Auto-detects your OpenAPI document source (Swashbuckle, Microsoft.AspNetCore.OpenApi, Scalar, etc.) via DI inspection
  2. Reads AI metadata attributes from your code
  3. Exposes executable tools via MCP at POST /mcp
  4. Indexes all non-hidden endpoints for RAG semantic search
  5. Provides a rag_search MCP tool for LLM context retrieval

OpenAPI Auto-Detection

The library inspects your DI container at runtime to determine where the OpenAPI document is served:

Provider Detected Service Default Route
Swashbuckle ISwaggerProvider /swagger/v1/swagger.json
Microsoft.AspNetCore.OpenApi IOpenApiDocumentService /openapi/v1.json
Scalar (via Swashbuckle) ISwaggerProvider /swagger/v1/swagger.json

You can always override with manual configuration:

builder.Services.UseMcp(options =>
{
    options.OpenApiEndpoint = "/my-custom/openapi.json";
});

AI Metadata Attributes

Control how your endpoints are exposed to AI systems:

// Executable MCP Tool — LLMs can call this
[AiTool("create_pix_payment")]
[AiDescription("Creates a PIX payment")]
[AiCategory("Payments")]
[AiRole("finance")]
[AiRateLimit(5)]
[AiContextPriority(100)]
[HttpPost("pix")]
public IActionResult CreatePixPayment([FromBody] PixPaymentRequest request) { ... }

// Read-only — available in RAG/docs but not executable
[HttpGet]
[AiDescription("Lists all orders")]
public IActionResult GetOrders() { ... }

// Hidden — completely invisible to AI
[AiHidden]
[HttpDelete("{id}")]
public IActionResult DeleteOrder(int id) { ... }

Attribute Reference

Attribute Purpose
[AiTool] Marks as executable MCP tool
[AiHidden] Hides from all AI systems
[AiDescription("...")] Provides AI-facing description
[AiCategory("...")] Groups for semantic organization
[AiRole("...")] Requires role for execution
[AiRateLimit(n)] Max requests/minute
[AiContextPriority(n)] RAG ranking priority

MCP Protocol

The framework exposes a standard MCP endpoint supporting:

// Initialize
{ "method": "initialize" }

// List available tools
{ "method": "tools/list" }

// Execute a tool
{ "method": "tools/call", "params": { "name": "create_order", "arguments": {...} } }

Automatic semantic search over your API documentation:

{
  "method": "tools/call",
  "params": {
    "name": "rag_search",
    "arguments": { "query": "How does payment creation work?" }
  }
}

Minimal API Support

app.MapPost("/api/products", handler)
    .AiTool("create_product")
    .AiDescription("Creates a new product")
    .AiCategory("Products")
    .AiRateLimit(20);

app.MapDelete("/api/products/{id}", handler)
    .AiHidden();

Configuration

MCP Options

services.UseMcp(options =>
{
    options.Route = "/mcp";
    options.EnableRateLimiting = true;
    options.GlobalRateLimitPerMinute = 60;
    options.ServerName = "My API";
    options.OpenApiEndpoint = "/swagger/v1/swagger.json"; // optional manual override
});

RAG Options

services.UseRag(options =>
{
    options.IncludeXmlDocs = true;
    options.MaxSearchResults = 10;
    options.MinimumSimilarity = 0.3f;
});

Exposure Rules

State MCP RAG Docs
[AiHidden] No No No
[AiTool] Executable Yes Yes
No attribute No Yes Yes

Security

  • Inherits existing ASP.NET Core authentication automatically
  • Role-based execution control via [AiRole]
  • Per-tool rate limiting via [AiRateLimit]
  • Global rate limiting configuration
  • JWT token forwarding from MCP callers

Architecture

ASP.NET Application
       |
OpenAPI Document (auto-detected)
       |
AI Metadata Layer
       |
MCP Layer + RAG Layer
       |
AI Consumers (Claude, GPT, Copilot, etc.)

The library is agnostic to your OpenAPI UI. It only reads the OpenAPI document — it never renders documentation. Use Swagger UI, Scalar, or any other tool you prefer.

Solution Structure

src/
  Romatech.Extensions.Ai/          -> Main package (install this)
  Romatech.Extensions.Ai.Mcp/      -> MCP server implementation
  Romatech.Extensions.Ai.Rag/      -> RAG indexing and search
  Romatech.Extensions.Ai.Metadata/ -> Attributes and resolution
  Romatech.Extensions.Ai.Swagger/  -> OpenAPI discovery (auto-detect)
  Romatech.Extensions.Ai.Shared/   -> Abstractions and contracts
tests/
samples/
benchmarks/

Supported .NET Versions

  • .NET 6.0
  • .NET 7.0
  • .NET 8.0 (LTS)
  • .NET 9.0
  • .NET 10.0+

Migrating from v2.x

v3.0 is a breaking change:

  1. Remove UseScalar() — The library no longer manages UI rendering. Configure your own Swagger/Scalar UI.
  2. Remove Swashbuckle.AspNetCore from the lib's concerns — it's now your responsibility to add an OpenAPI generator to your app (you probably already have one).
  3. SwaggerDiscoveryOptions renamed to OpenApiDiscoveryOptions — If you were configuring this directly.
  4. SwaggerEndpointDiscoveryProvider renamed to OpenApiEndpointDiscoveryProvider — If you were overriding the discovery provider.
  5. New option: McpOptions.OpenApiEndpoint — Use this for manual override if auto-detection doesn't work.

Troubleshooting

MCP endpoint returns 404: Ensure app.UseMcp() is called in the pipeline and your route matches.

No tools discovered: Verify your OpenAPI generator is enabled and the document is accessible. Ensure at least one endpoint has [AiTool]. Check logs for the detected OpenAPI route.

Auto-detection not working: Set options.OpenApiEndpoint explicitly in UseMcp() configuration. The library logs which provider it detected at startup.

RAG returns empty results: Check that endpoints have descriptions and are not marked [AiHidden].

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 is compatible.  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 (1)

Showing the top 1 NuGet packages that depend on Romatech.Extensions.Ai.Mcp:

Package Downloads
Romatech.Extensions.Ai

Plug-and-play AI enablement framework for ASP.NET Core. Transforms APIs into MCP tools and RAG-enabled knowledge sources automatically.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 169 8/22/2026
2.0.0 168 6/26/2026
1.2.0 141 6/18/2026
1.0.0 165 6/15/2026