
C# MCP SDK
The official C# SDK for the Model Context Protocol (MCP), maintained in collaboration with Microsoft. It enables .NET developers to easily build MCP servers and clients, exposing tools, resources, and prompts to AI agents like Claude, Cursor, and Gemini.
Overview
The C# MCP SDK (repository: modelcontextprotocol/csharp-sdk) is the official .NET SDK for the Model Context Protocol, developed in collaboration with Microsoft. It allows .NET developers to implement MCP servers and clients with idiomatic C# APIs, making it simple to connect AI agents to .NET applications, enterprise data sources, internal APIs, and custom workflows.
Released to stable v1.0 in March 2026 with full support for the 2025-11-25 MCP specification, the SDK is Tier 1 in the official MCP ecosystem and is the recommended way for C#/.NET teams to participate in the growing MCP landscape.
Key Features
- Full MCP Specification Support: Implements the latest 2025-11-25 protocol including Tools, Resources, Prompts, Elicitation, Sampling, and experimental Tasks.
- Three NuGet Packages:
ModelContextProtocol.Core— Minimal dependencies for clients and low-level servers.ModelContextProtocol— Full-featured for most use cases.ModelContextProtocol.AspNetCore— Seamless integration with ASP.NET Core for HTTP/SSE transport.
- Easy Tool Definition: Decorate methods with attributes or use fluent APIs to expose C# functions as MCP Tools with automatic JSON Schema generation.
- Built-in Authorization: First-class support for OAuth 2.1, OpenID Connect discovery, PKCE, and incremental scope consent.
- Multiple Transports: stdio, HTTP, SSE, and Streamable HTTP.
- Microsoft.Extensions.AI Integration: Smooth interoperability with Semantic Kernel and other .NET AI libraries.
- Production Ready: Observability, logging, dependency injection, HttpContext access, and AOT compatibility options.
- Excellent Documentation: Comprehensive API docs at csharp.sdk.modelcontextprotocol.io.
How It Works
Building an MCP Server (Minimal Example)
using ModelContextProtocol;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMcpServer()
.WithHttpTransport()
.WithTools<MyCustomTools>();
var app = builder.Build();
app.MapMcp();
app.Run();
Define tools simply:
public class MyCustomTools
{
[McpTool]
public string GetWeather(string city)
=> $"Sunny in {city}";
}
AI agents (Claude Desktop, Cursor, etc.) can then discover and call these tools automatically.
Use Cases
- Enterprise Data Integration: Expose internal databases, CRM systems, or business APIs to AI agents securely.
- .NET Tooling for Agents: Build MCP servers that let AI control dotnet CLI, Roslyn analyzers, NuGet packages, or Azure resources.
- Custom AI Workflows: Connect legacy .NET services to modern agentic applications.
- Hybrid AI Applications: Combine MCP with Semantic Kernel or Microsoft.Extensions.AI for rich agent experiences.
- Internal Developer Tools: Create organization-specific tools for code generation, deployment, or monitoring.
Getting Started
-
Install the main package:
dotnet add package ModelContextProtocol -
Follow the official quickstarts in the GitHub repository or SDK Documentation.
-
Explore rich samples in microsoft/mcp-dotnet-samples.
The SDK works with console apps, ASP.NET Core, Azure Functions, and more. Full support for both server and client implementations.
Benefits
The C# MCP SDK brings the power of the Model Context Protocol to the .NET ecosystem with familiar patterns, strong typing, dependency injection, and enterprise-grade security. It lowers the barrier for .NET teams to build production MCP servers while maintaining full compatibility with the broader MCP ecosystem (Claude, Cursor, Gemini CLI, etc.).
As a Tier 1 official SDK maintained with Microsoft, it receives timely updates aligned with the evolving MCP specification and is widely used for both internal tools and public AI integrations.
Official Links:
- GitHub: https://github.com/modelcontextprotocol/csharp-sdk
- Docs: https://csharp.sdk.modelcontextprotocol.io/
- .NET Blog Announcement: https://devblogs.microsoft.com/dotnet/release-v10-of-the-official-mcp-csharp-sdk/
Tags
Related Entries
Keep exploring similar tools and resources in this category.
Related Reads
Background, tutorials, and protocol context connected to this entry.








