{"slug": "turn-the-asp-net-core-web-api-you-already-have-into-an-mcp-server", "title": "Turn the ASP.NET Core Web API you already have into an MCP server", "summary": "Hovik Aghajanyan released Nabu.Mcp.AspNetCore, an open-source library that turns existing ASP.NET Core Web APIs into Model Context Protocol (MCP) servers with minimal code changes. The library publishes controllers and minimal APIs as MCP tools, generating schemas from CLR types and enforcing authorization per call by pushing synthetic HttpContext through the full pipeline.", "body_md": "· **Repo:** [https://github.com/hovik-aghajanyan/nabu.net](https://github.com/hovik-aghajanyan/nabu.net)\n\n· **Docs:** [https://nabu.aghajanyan.me/](https://nabu.aghajanyan.me/)\n\n· **NuGet:** [https://www.nuget.org/packages/Nabu.Mcp.AspNetCore](https://www.nuget.org/packages/Nabu.Mcp.AspNetCore)\n\n[ Nabu.Mcp.AspNetCore](https://github.com/hovik-aghajanyan/nabu.net) publishes existing ASP.NET Core\n\n```\n[HttpGet(\"{id:guid}\")]\n[McpTool]                                   // <- that's it\npublic ActionResult<TodoItem> GetById(Guid id) => ...\njs\napp.MapGet(\"/customers/{id}\", (int id) => ...)\n   .McpTool();                              // <- same thing for Minimal APIs\njs\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services.AddControllers();\nbuilder.Services.AddNabuMcp(options =>\n{\n    options.ServerName = \"my-api\";\n    options.RequireAuthorization = true;                    // protect the MCP endpoint itself\n    options.ToolVisibility = McpToolVisibility.Authorized;  // advertise only what the caller may invoke\n});\n\nvar app = builder.Build();\napp.UseAuthentication();\napp.UseAuthorization();\napp.UseNabuMcp();          // serves MCP at /mcp\napp.MapControllers();\napp.Run();\ncurl -X POST http://localhost:5000/mcp \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}'\n```\n\nTool descriptions come from your XML docs; input schemas are generated from your CLR types, data\n\nannotations and nullability. `[Authorize]`\n\n, policies and roles are enforced per call — the same action\n\nthat returns 403 over HTTP returns an `isError`\n\ntool result over MCP for the same caller, and\n\n`tools/list`\n\ncan show each caller only the tools it is actually allowed to invoke.\n\nDirect method invocation quietly drops everything that makes an action *safe*: `[Authorize]`\n\nis enforced\n\nby middleware and filters, `ModelState`\n\nis populated by model binding, rate limiting and exception\n\nhandling live outside the method. Nabu instead captures the app's `RequestDelegate`\n\nat startup and pushes\n\na synthetic `HttpContext`\n\n— carrying the caller's identity and forwarded credentials — through the full\n\npipeline for every tool call.\n\n`[McpTool]`\n\nrepeatedly with different names, parameter subsets and pinned constants.`tools/list`\n\nevaluated with your own authorization policies.`Authorization`\n\n, `Cookie`\n\nor proxy headers.`Nabu.Mcp.ModelContextProtocol`\n\nserves the same tools through the official MCP C# SDK.📚 Full documentation: [https://nabu.aghajanyan.me/](https://nabu.aghajanyan.me/)", "url": "https://wpnews.pro/news/turn-the-asp-net-core-web-api-you-already-have-into-an-mcp-server", "canonical_source": "https://dev.to/hovikaghajanyan/turn-the-aspnet-core-web-api-you-already-have-into-an-mcp-server-1f55", "published_at": "2026-08-14 14:59:53+00:00", "updated_at": "2026-08-14 15:06:04.994958+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-infrastructure"], "entities": ["Hovik Aghajanyan", "Nabu.Mcp.AspNetCore", "ASP.NET Core", "Model Context Protocol", "GitHub", "NuGet"], "alternates": {"html": "https://wpnews.pro/news/turn-the-asp-net-core-web-api-you-already-have-into-an-mcp-server", "markdown": "https://wpnews.pro/news/turn-the-asp-net-core-web-api-you-already-have-into-an-mcp-server.md", "text": "https://wpnews.pro/news/turn-the-asp-net-core-web-api-you-already-have-into-an-mcp-server.txt", "jsonld": "https://wpnews.pro/news/turn-the-asp-net-core-web-api-you-already-have-into-an-mcp-server.jsonld"}}