Romatech.Extensions.Ai.Shared
3.0.0
dotnet add package Romatech.Extensions.Ai.Shared --version 3.0.0
NuGet\Install-Package Romatech.Extensions.Ai.Shared -Version 3.0.0
<PackageReference Include="Romatech.Extensions.Ai.Shared" Version="3.0.0" />
<PackageVersion Include="Romatech.Extensions.Ai.Shared" Version="3.0.0" />
<PackageReference Include="Romatech.Extensions.Ai.Shared" />
paket add Romatech.Extensions.Ai.Shared --version 3.0.0
#r "nuget: Romatech.Extensions.Ai.Shared, 3.0.0"
#:package Romatech.Extensions.Ai.Shared@3.0.0
#addin nuget:?package=Romatech.Extensions.Ai.Shared&version=3.0.0
#tool nuget:?package=Romatech.Extensions.Ai.Shared&version=3.0.0
Romatech.Extensions.Ai
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:
- Auto-detects your OpenAPI document source (Swashbuckle, Microsoft.AspNetCore.OpenApi, Scalar, etc.) via DI inspection
- Reads AI metadata attributes from your code
- Exposes executable tools via MCP at
POST /mcp - Indexes all non-hidden endpoints for RAG semantic search
- Provides a
rag_searchMCP 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": {...} } }
RAG Search
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:
- Remove
UseScalar()— The library no longer manages UI rendering. Configure your own Swagger/Scalar UI. - Remove
Swashbuckle.AspNetCorefrom the lib's concerns — it's now your responsibility to add an OpenAPI generator to your app (you probably already have one). SwaggerDiscoveryOptionsrenamed toOpenApiDiscoveryOptions— If you were configuring this directly.SwaggerEndpointDiscoveryProviderrenamed toOpenApiEndpointDiscoveryProvider— If you were overriding the discovery provider.- 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
| Product | Versions 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. |
-
net10.0
-
net6.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.5)
-
net7.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.5)
-
net8.0
-
net9.0
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Romatech.Extensions.Ai.Shared:
| Package | Downloads |
|---|---|
|
Romatech.Extensions.Ai.Metadata
AI metadata attributes for Romatech.Extensions.Ai framework |
|
|
Romatech.Extensions.Ai.Swagger
OpenAPI discovery and schema conversion for Romatech.Extensions.Ai |
|
|
Romatech.Extensions.Ai.Rag
RAG (Retrieval Augmented Generation) layer for Romatech.Extensions.Ai |
|
|
Romatech.Extensions.Ai.Mcp
MCP (Model Context Protocol) server implementation for Romatech.Extensions.Ai |
|
|
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.