McpHttpServer 1.0.0

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

McpHttpServer

A robust, plug-and-play .NET class library that implements the official Model Context Protocol (MCP) using the new Streamable HTTP transport (2025-03-26 specification).

This library allows you to effortlessly host MCP Tools, Resources, and Prompts directly inside your ASP.NET Core applications. It handles all JSON-RPC parsing, SSE stream management, session IDs, and routing automatically.

Features

  • Streamable HTTP Compliant: Fully implements the latest standard for HTTP/SSE based MCP communication.
  • Attribute-Based Routing: Auto-discovers your tools, resources, and prompts using simple [McpTool], [McpResource], and [McpPrompt] attributes.
  • Built-in Session Management: Automatically handles Mcp-Session-Id headers and maintains SSE streams for unprompted server notifications.
  • Secure: Native integration with ASP.NET Core Authentication and Authorization ([Authorize]).
  • CORS Support: Easy toggles for Cross-Origin Resource Sharing to allow web-based MCP clients to connect directly.

Installation

Install the package via NuGet:

dotnet add package McpHttpServer

Quick Start

1. Configure your ASP.NET Core App

In your Program.cs, add the MCP Server services and map the endpoints:

using McpHttpServer;

var builder = WebApplication.CreateBuilder(args);

// Optional: Optimize Kestrel for HTTP/2 Streams
builder.ConfigureKestrelForMcp();

// Add MCP Server
builder.Services.AddMcpHttpServer(options =>
{
    options.ServerName = "MyMcpServer";
    options.Endpoint = "/mcp"; // The HTTP endpoint MCP clients will hit
    options.RequireAuthorization = false; // Set to true to require auth
    options.UseDefaultCors = true; 
});

var app = builder.Build();

// Map the /mcp endpoint
app.MapMcpHttpServer();

app.Run();

2. Create Tools, Resources, and Prompts

Simply create a class anywhere in your project and decorate it with [McpHandler]. Use the corresponding attributes for your methods:

using McpHttpServer.Attributes;

[McpHandler]
public class MyAiTools
{
    [McpTool("calculate_sum", "Calculates the sum of two numbers.")]
    public int CalculateSum([McpParameter] int a, [McpParameter] int b)
    {
        return a + b;
    }

    [McpResource("system://status", "System Status", "Returns the current system status.", "application/json")]
    public string GetStatus()
    {
        return "{ \"status\": \"online\", \"uptime\": \"99.9%\" }";
    }

    [McpPrompt("greet_user", "Generates a greeting prompt.")]
    public string Greet([McpArgument] string username)
    {
        return $"Hello {username}, how can I help you today?";
    }
}

That's it! The library will auto-discover MyAiTools on startup, build the required JSON schemas, and expose them over the Streamable HTTP transport.

Testing with MCP Inspector

You can easily test your server using the official MCP Inspector.

  1. Run your .NET application.
  2. Launch the inspector: npx @modelcontextprotocol/inspector
  3. Select SSE transport and connect to http://localhost:<port>/mcp.
Product Compatible and additional computed target framework versions.
.NET 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.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 125 7/9/2026