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.
Installation
The MCP C# SDK is distributed as three NuGet packages. Choose the package that best matches your scenario.Choosing the Right Package
The SDK provides three packages with different capabilities and dependencies:| Package | Use When | Dependencies |
|---|---|---|
| ModelContextProtocol.Core | You only need the client or low-level server APIs and want the minimum set of dependencies | Microsoft.Extensions.AI.Abstractions, Microsoft.Extensions.Logging.Abstractions |
| ModelContextProtocol | You’re building a client or a stdio-based server and want hosting, dependency injection, and attribute-based discovery | Includes ModelContextProtocol.Core + Microsoft.Extensions.Hosting.Abstractions |
| ModelContextProtocol.AspNetCore | You’re building an HTTP-based MCP server hosted in ASP.NET Core | Includes ModelContextProtocol + ASP.NET Core framework |
Core Package
When to Use
ChooseModelContextProtocol.Core when you:
- Only need to build an MCP client
- Want to use low-level server APIs with minimal dependencies
- Need the smallest possible package footprint
- Don’t require hosting or dependency injection features
Installation
What’s Included
McpClient- Connect to any MCP server- Low-level server types and interfaces
- Protocol types and message structures
- Transport implementations (stdio, HTTP, SSE)
- Minimal external dependencies
Framework Support
- .NET 10.0, 9.0, 8.0
- .NET Standard 2.0
- Native AOT compatible (except .NET Standard 2.0)
Main Package
When to Use
ChooseModelContextProtocol when you:
- Are building most client or server applications
- Want attribute-based tool/prompt/resource discovery
- Need dependency injection support
- Want to use Microsoft.Extensions.Hosting for server lifecycle management
- Are building a stdio-based MCP server
Installation
What’s Included
Everything fromModelContextProtocol.Core, plus:
AddMcpServer()- Service collection extensions for dependency injectionWithStdioServerTransport()- stdio transport for process-based serversWithToolsFromAssembly()- Automatic tool discovery from attributesWithResources<T>()andWithPrompts<T>()- Resource and prompt registration- Hosting integration with
IHostedService - Caching and background service support
Framework Support
- .NET 10.0, 9.0, 8.0
- .NET Standard 2.0
- Native AOT compatible (except .NET Standard 2.0)
Additional Dependencies
For hosting support, you’ll typically also install:AspNetCore Package
When to Use
ChooseModelContextProtocol.AspNetCore when you:
- Are building an HTTP-based MCP server
- Want to host your MCP server in ASP.NET Core
- Need to expose MCP over HTTP/HTTPS endpoints
- Want to integrate MCP with existing ASP.NET Core applications
- Need features like authentication, authorization, or CORS
Installation
What’s Included
Everything fromModelContextProtocol, plus:
WithHttpTransport()- HTTP transport for ASP.NET Core serversMapMcp()- Endpoint routing extensions- ASP.NET Core middleware integration
- HttpContext access from tools and resources
- Support for SSE (Server-Sent Events) streaming
Framework Support
- .NET 10.0, 9.0, 8.0
- Native AOT compatible
The AspNetCore package does not support .NET Standard 2.0 because it requires ASP.NET Core framework features.
Verification
After installation, verify the package is correctly installed by checking your project file:Package Versions
All three packages follow the same versioning scheme. Check NuGet for the latest stable version:Next Steps
Quick Start Guide
Build your first MCP client and server with step-by-step examples