* Simplify ModelContextProtocol.AspNetCore README * Add StreamableHttpHandler * Use "docker info" in CheckIsDockerAvailable * Call WithHttpTransport in samples, tests and README * Cleanup test namespaces * Add CanConnect_WithMcpClient_AfterCustomizingRoute test * Simplify relative URI handling * Handle request made directly to the MapMcp route pattern * Add Messages_FromNewUser_AreRejected test * Fix README * Shorten UserIdClaim ValueTuple names * Remove MaxReconnectAttempts and ReconnectDelay from SseClientTransportOptions - Add proper AdditionalHeaders support
52 lines
1.8 KiB
Markdown
52 lines
1.8 KiB
Markdown
# ASP.NET Core extensions for the MCP C# SDK
|
|
|
|
[](https://www.nuget.org/packages/ModelContextProtocol/absoluteLatest)
|
|
|
|
The official C# SDK for the [Model Context Protocol](https://modelcontextprotocol.io/), enabling .NET applications, services, and libraries to implement and interact with MCP clients and servers. Please visit our [API documentation](https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.html) 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:
|
|
|
|
- [Official Documentation](https://modelcontextprotocol.io/)
|
|
- [Protocol Specification](https://spec.modelcontextprotocol.io/)
|
|
- [GitHub Organization](https://github.com/modelcontextprotocol)
|
|
|
|
## Installation
|
|
|
|
To get started, install the package from NuGet
|
|
|
|
```
|
|
dotnet new web
|
|
dotnet add package ModelContextProtocol.AspNetCore --prerelease
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
```csharp
|
|
// Program.cs
|
|
using ModelContextProtocol.Server;
|
|
using System.ComponentModel;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Services.AddMcpServer()
|
|
.WithHttpTransport()
|
|
.WithToolsFromAssembly();
|
|
var app = builder.Build();
|
|
|
|
app.MapMcp();
|
|
|
|
app.Run("http://localhost:3001");
|
|
|
|
[McpServerToolType]
|
|
public static class EchoTool
|
|
{
|
|
[McpServerTool, Description("Echoes the message back to the client.")]
|
|
public static string Echo(string message) => $"hello {message}";
|
|
}
|
|
```
|