Back to Frameworks & SDKs
C# MCP SDK logo
framework3,040

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

  1. Install the main package:

    dotnet add package ModelContextProtocol
    
  2. Follow the official quickstarts in the GitHub repository or SDK Documentation.

  3. 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

mcpcsharpdotnetframeworksdkai-agentmicrosoftmodelcontextprotocoltools

Related Entries

Keep exploring similar tools and resources in this category.

Browse Frameworks & SDKs
OpenViking logo

OpenViking

Frameworks & SDKs

OpenViking is an open-source context database for AI agents that organizes memory, resources, and skills using a filesystem paradigm (viking:// URIs), enabling hierarchical context delivery, layered loading, and self-evolving agents.

FastMCP logo

FastMCP

Frameworks & SDKs

The fast, Pythonic framework for building MCP (Model Context Protocol) servers and clients. Turn any Python function into production-ready LLM tools with zero boilerplate.

AgentScope logo

AgentScope

Frameworks & SDKs

Production-ready, easy-to-use multi-agent framework for building transparent, scalable LLM-powered applications with ReAct agents, tools, memory, evaluation, realtime voice, and secure runtime support.

Cloudflare Workers MCP logo

Cloudflare Workers MCP

Frameworks & SDKs

Build and deploy custom remote MCP servers on Cloudflare Workers to expose tools, APIs, and Cloudflare services to AI agents like Claude and Cursor via standardized protocol.

Dynamic Worker Loader logo

Dynamic Worker Loader

Frameworks & SDKs

Cloudflare's Dynamic Worker Loader API enables Workers to spawn new, isolated Workers at runtime with arbitrary code, providing lightweight sandboxing ideal for executing AI-generated code securely and efficiently.

Hindsight logo

Hindsight

Frameworks & SDKs

Hindsight is an open-source agent memory system that enables AI agents to truly learn over time by retaining facts, recalling with hybrid strategies, and reflecting to form mental models.