Documentation Index
Fetch the complete documentation index at: https://mintlify.com/modelcontextprotocol/csharp-sdk/llms.txt
Use this file to discover all available pages before exploring further.
MCP C# SDK
The official C# SDK for the Model Context Protocol, enabling .NET applications, services, and libraries to implement and interact with MCP clients and servers.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.
Key Features
Build MCP Clients
Connect to any MCP server and access tools, prompts, and resources. Works with stdio, HTTP, and SSE transports.
Create MCP Servers
Expose your .NET functionality as MCP tools with attribute-based discovery and dependency injection support.
Microsoft.Extensions.AI Integration
MCP tools inherit from
AIFunction and work seamlessly with any IChatClient implementation.Multiple Transport Options
Support for stdio (process-based), HTTP, and Server-Sent Events (SSE) transports out of the box.
Hosting & DI Support
Built-in integration with Microsoft.Extensions.Hosting and dependency injection for production-ready servers.
AOT Compatible
Native AOT support for fast startup times and minimal memory footprint in your .NET applications.
Three Packages for Different Needs
The SDK consists of three NuGet packages to match your specific requirements:ModelContextProtocol.Core
Minimal dependenciesClient and low-level server APIs only. Perfect when you need the smallest footprint.
ModelContextProtocol
Recommended starting pointHosting, dependency injection, and attribute-based discovery. Ideal for most projects.
ModelContextProtocol.AspNetCore
HTTP server supportASP.NET Core integration for building HTTP-based MCP servers.
Quick Example
Here’s a complete MCP server in just a few lines of code:Program.cs
Get Started
Installation
Install the SDK packages and choose the right one for your project
Quick Start
Build your first MCP client and server in minutes
Learn More
Official MCP Documentation
Learn about the Model Context Protocol specification
API Documentation
Explore the complete API reference
GitHub Repository
View source code and contribute to the SDK