csharp-sdk/src/ModelContextProtocol.AspNetCore
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Stephen Halter faf12b6a94
Use Kestrel for all in-memory HTTP tests (#225)
* Add route pattern parameter to MapMcp
* Add configureOptionsAsync
* Use Kestrel for all in-memory HTTP tests
* Use ApplicationStopping token for SSE responses
* Use RegisterNotificationHandler in MapMcp tests
* Work around SocketsHttpHandler bug where it doesn't call DispseAsync on the stream returned by the ConnectCallback
2025-04-06 19:27:17 -07:00
..
McpEndpointRouteBuilderExtensions.cs Use Kestrel for all in-memory HTTP tests (#225) 2025-04-06 19:27:17 -07:00
ModelContextProtocol.AspNetCore.csproj Reduce dependencies to 8.x versions of packages (#195) 2025-04-03 14:01:46 -04:00
README.md Put MapMcp in Microsoft.AspNetCore.Builder namespace (#171) 2025-03-31 17:35:28 -04:00

ASP.NET Core extensions for the MCP C# SDK

NuGet preview version

The official C# SDK for the Model Context Protocol, enabling .NET applications, services, and libraries to implement and interact with MCP clients and servers. Please visit our API documentation for more details on available functionality.

Note

This project is in preview; breaking changes can be introduced without prior notice.

About MCP

The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). It enables secure integration between LLMs and various data sources and tools.

For more information about MCP:

Installation

To get started, install the package from NuGet

dotnet new web
dotnet add package ModelContextProtocol.AspNetCore --prerelease

Getting Started

// Program.cs
using ModelContextProtocol.Server;
using System.ComponentModel;

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(options =>
{
    options.ListenLocalhost(3001);
});
builder.Services.AddMcpServer().WithToolsFromAssembly();
var app = builder.Build();

app.MapMcp();

app.Run();

[McpServerToolType]
public static class EchoTool
{
    [McpServerTool, Description("Echoes the message back to the client.")]
    public static string Echo(string message) => $"hello {message}";
}