Library for ASP.NET Core Web API, which automatically turns each controller method into a tool for the MCP server.
Under the hood, MCP Endpoints Tools uses the Model Context Protocol C# SDK for working with tools.
Note
This project is in alpha version! Various errors are possible. Please write to the issue for errors and suggestions on library expansion.
MCP Endpoints Tools scans the application build, finds all controllers and their public methods marked with HTTP attributes, and registers them as Model Context Protocol (MCP) tools. In this case, XML comments from the assembly are used to fill in the description (summary) of the tools.
- Automatic registration of all controller methods as MCP tools and resources
- Support for method exclusion via the
[McpIgnore]attribute - Automatic addition of the tool description from the XML comments of the assembly via the 'XmlCommentsProvider`
- Flexible configuration via
ServerOptions(path, name, description, version, XML path) - Easy integration into 'IServiceCollection
andIEndpointRouteBuilder' via extensionsServiceCollectionExtensionsandEndpointRouteBuilderExtensions
-
Add the
McpEndpointsToolsproject to your solution or connect via NuGet (if there is a package):dotnet add package McpEndpointsTools --version 1.0.12-alpha
-
In the file
Program.cs(orStartup.cs), register the services and mapping:using McpEndpointsServer.Extensions; var builder = WebApplication.CreateBuilder(args); // MCP Server registration and controller scanning builder.Services.AddMcpEndpointsServer(opts => { opts.PipelineEndpoint = "/mcp"; // path for the HTTP pipeline opts.ServerName = "My MCP Server"; // server name opts.ServerDescription = "API for MCP"; // description opts.ServerVersion = "1.2.3"; // version opts.XmlCommentsPath = "MyApp.xml "; // path to the XML documentation file opts.HostUrl = "https://api.mysite "; // base URL });
-
Enable XML documentation generation in your
.csprojproject file:<PropertyGroup> <GenerateDocumentationFile>true</GenerateDocumentationFile> <NoWarn>$(NoWarn);1591</NoWarn> </PropertyGroup>
-
Set up routing in the same or another location:
var app = builder.Build(); app.MapControllers(); // regular controllers app.MapMcpEndpointsServer(); // MCP endpoints (HTTP stream & SSE) app.Run();
Follow the registration procedure
McpIgnoreAttributeIt is placed above the controller method to exclude it from the list of generated MCP tools.AuthorizeMethods and controllers marked with the Authorize attribute will not be added to the tools. In future versions, support for authentication authorization may be added.
Here is an example of an attribute over a controller method
/// <summary>
/// Provides clothing advice based on the current temperature in Celsius.
/// </summary>
/// <param name="tempC">The temperature in Celsius for which clothing advice is needed.</param>
/// <returns>
/// A string containing clothing advice suitable for the specified temperature.
/// </returns>
[HttpGet("GetClothingAdvice")]
[McpIgnore]
public IActionResult GetClothingAdvice([FromQuery] double tempC)
{
if (tempC >= 25) return Ok("Put on a T-shirt and shorts.");
if (tempC >= 15) return Ok("A light jacket will do.");
if (tempC >= 5) return Ok("I need a coat.");
return Ok("It's very cold — keep warm!");
}If you mark the entire controller with this attribute, all controller methods will be ignored by the MCP server.
See the sample application on ASP .NET Core is available via the link
{
"workbench.startupEditor": "none",
"explorer.confirmDelete": false,
"mcp": {
"servers": {
"test-mcp": {
"url": "http://localhost:5220/mcp"
},
"API-helper": {
"url": "https://api.il2-expert.ru/mcp"
}
}
},
"explorer.confirmDragAndDrop": false,
"chat.editing.confirmEditRequestRetry": false
}{
"mcpServers": {
"my-mcp-server": {
"url": "http://localhost:5258/mcp",
"type": "http"
}
}
}- The demo API application is deployed at: https://api.il2-expert.ru/mcp/resources
- To test connecting the MCP IDE client to the endpoint: https://api.il2-expert.ru/mcp
MIT License. See the LICENSE file for details.