MCP C# SDK Tutorial: Production MCP in .NET with Hosting, ASP.NET Core, and Task Workflows

May 11, 2026 ยท View on GitHub

Learn how to build and operate MCP clients and servers with modelcontextprotocol/csharp-sdk, including package choices, auth patterns, tasks, diagnostics, and versioning strategy.

GitHub Repo NuGet ModelContextProtocol NuGet AspNetCore

Why This Track Matters

The C# SDK is one of the strongest MCP implementations for enterprise .NET stacks, with first-class hosting/DI integration, ASP.NET Core transport support, and detailed concept docs.

This track focuses on:

  • selecting the right package layer (ModelContextProtocol, .Core, .AspNetCore)
  • implementing client/server patterns with host-friendly abstractions
  • using filters, diagnostics, and versioning guidance for safer evolution
  • deploying protected MCP endpoints with OAuth-compatible flows

Current Snapshot (auto-updated)

Mental Model

flowchart LR
    A[.NET host] --> B[ModelContextProtocol]
    B --> C[Stdio transports]
    A --> D[ModelContextProtocol.AspNetCore]
    D --> E[HTTP MCP endpoints]
    B --> F[Filters + diagnostics + tasks]

Chapter Guide

ChapterKey QuestionOutcome
01 - Getting Started and Package SelectionWhich C# SDK package should I use for my app shape?Correct package boundary
02 - Client/Server Hosting and stdio BasicsHow do I stand up MCP clients and servers in typical .NET hosts?Faster onboarding
03 - ASP.NET Core HTTP Transport and Session RoutingHow do I design HTTP MCP deployments with route/session control?Better HTTP architecture
04 - Tools, Prompts, Resources, and Filter PipelinesHow do I keep primitive behavior and interception predictable?Cleaner extensibility
05 - Logging, Progress, Elicitation, and TasksHow do advanced capabilities work end to end in C#?Stronger feature execution
06 - OAuth-Protected MCP Servers and ClientsHow do we secure MCP endpoints and clients in production?Lower security risk
07 - Diagnostics, Versioning, and Breaking-Change ManagementHow do teams evolve safely while APIs are still moving?Safer upgrade process
08 - Testing, Operations, and Contribution WorkflowsHow do we operationalize reliability and contribute upstream?Long-term maintainability

What You Will Learn

  • how to map package boundaries to real .NET deployment scenarios
  • how to use filters, diagnostics, and concept docs as operational tools
  • how to secure and test protected MCP deployments in ASP.NET Core
  • how to handle preview-stage versioning with lower blast radius

Source References


Start with Chapter 1: Getting Started and Package Selection.

Full Chapter Map

  1. Chapter 1: Getting Started and Package Selection
  2. Chapter 2: Client/Server Hosting and stdio Basics
  3. Chapter 3: ASP.NET Core HTTP Transport and Session Routing
  4. Chapter 4: Tools, Prompts, Resources, and Filter Pipelines
  5. Chapter 5: Logging, Progress, Elicitation, and Tasks
  6. Chapter 6: OAuth-Protected MCP Servers and Clients
  7. Chapter 7: Diagnostics, Versioning, and Breaking-Change Management
  8. Chapter 8: Testing, Operations, and Contribution Workflows

Generated by AI Codebase Knowledge Builder