Skip to sessions and notes

These session notes are AI-generated and may contain mistakes. Verify important details against the original recording.

What's new in the MCP C# SDK

Stefan Halter

Session · 25:34 recording · 6 min read

At a glance

  • The Model Context Protocol (MCP) as the standardized "USB-C of AI"
  • Agentic AI Foundation / Linux Foundation Tier 1 C# SDK
  • Three-tier package layering (ModelContextProtocol.AspNetCore, ModelContextProtocol, Core)
  • ASP.NET Core endpoint integration via app.MapMcp("/mcp") with full DI and routing
  • Native AOT and Microsoft.Extensions.AI (AIFunction / IChatClient) unification

Executive Summary

As AI models evolve from passive conversational chatbots into active, tool-wielding software agents, standardizing how external services, databases, and operational environments are exposed to models is vital. The Model Context Protocol (MCP)—originally designed by Anthropic and now governed under the Linux Foundation's Agentic AI Foundation—has emerged as the universal standard: "The USB-C of AI."

In this demo-rich session, Microsoft .NET team developer Stefan Halter detailed the architecture of the official C# SDK for MCP. Officially designated as a Tier 1 SDK, the C# library bridges the full power of modern ASP.NET Core, Native AOT, and Microsoft.Extensions.AI to the MCP specification. Stefan unveiled major innovations in the SDK, including Stateless Mode by default, interactive MCP Apps (embedded iframes), human-in-the-loop Elicitation, enterprise OAuth/Entra ID integration, and developer tooling via the MCP Inspector.

What's New in the MCP C# SDK
What's New in the MCP C# SDK


1. The Value Proposition: The "USB-C of AI"

Before USB, connecting peripherals required a fragmented landscape of serial ports, parallel ports, and PS/2 connectors. Similarly, AI tool invocation previously relied on vendor-specific proprietary toolkits (OpenAI Functions, Anthropic Tool Use, LangChain wrappers).

flowchart LR
    A[AI Clients / Hosts<br/>VS Code, Visual Studio, Copilot App, Claude] <-->|Standardized JSON-RPC Protocol<br/>Stdio or Streamable HTTP| B[MCP Server C# SDK]
    B <--> C[Enterprise C# Code<br/>ASP.NET Core, EF Core, Redis, Microservices]

MCP Value Proposition USB of AI
MCP Value Proposition USB of AI

Why MCP Replaces Raw REST / OpenAPI

  • Bi-Directional Context Protocols: Standardizes not just tool calling, but Resources (file-like read access), Prompts (parameterized agent initialization instructions), and Elicitation (requesting human input).
  • Client Agnostic: The exact same C# MCP server connects interchangeably to VS Code, Visual Studio, GitHub Copilot App, Claude Desktop, and autonomous CLI agents.

MCP Servers Configuration JSON
MCP Servers Configuration JSON


2. Tier 1 SDK & Package Hierarchy

The C# SDK is developed as an open-source, community-driven project under the Agentic AI Foundation, co-maintained by Microsoft. It is rated as a Tier 1 SDK, satisfying 100% of the core specification and major extension proposals.

Tier 1 SDK Agentic AI Foundation
Tier 1 SDK Agentic AI Foundation

Three-Tier Layering Architecture

Package Hierarchy and Layering
Package Hierarchy and Layering

NuGet Package Target Use Case & Capabilities
ModelContextProtocol.AspNetCore High-level package for remote HTTP/SSE servers. Seamlessly mounts onto ASP.NET Core minimal APIs via app.MapMcp("/mcp") with route parameters and full DI integration.
ModelContextProtocol Standalone client and Stdio server package without ASP.NET Core framework dependencies. Native AOT compatible.
ModelContextProtocol.Core Low-level JSON-RPC serialization, schema generation, and protocol framing for maximum trimming efficiency and zero-overhead embeddings.

3. Server Implementation: ASP.NET Core & Modern C#

Exposing tools via the MCP C# SDK mirrors modern ASP.NET Core controller and minimal API semantics.

var builder = WebApplication.CreateBuilder(args);

// Register MCP server and tool collections
builder.Services.AddMcpServer()
    .WithTools<FireworksTools>()
    .WithPrompts<FireworksPrompts>()
    .WithResources<FireworksResources>();

var app = builder.Build();

// Expose remote streamable HTTP endpoint
app.MapMcp("/mcp/fireworks");

app.Run();

ASP.NET Core MapMcp Server Setup
ASP.NET Core MapMcp Server Setup

Tool Definition with Dependency Injection

Method parameters seamlessly resolve from both the server's IServiceProvider (e.g. SignalR IHubContext, EF Core DbContext) and the AI client's JSON-RPC invocation payload. [Description] attributes supply docstrings for model reasoning:

C# Tool Definition Attributes and DI
C# Tool Definition Attributes and DI


4. MCP Apps: Interactive In-Chat UI (iframes)

Beyond text responses, the SDK supports MCP Apps (formerly MCP UI). Tools can return structured HTML, JS, and CSS bundles that the host renders as isolated, interactive iframes directly inside the chat stream.

Stefan demonstrated a real-time Fireworks simulation tool: when the agent invoked launch_fireworks, an interactive celebration widget rendered inline in VS Code, synchronized with remote web viewers via SignalR.

MCP Apps iframe Inline UI
MCP Apps iframe Inline UI


5. Developer Tooling: The MCP Inspector

Debugging agentic tool invocations by prompting live LLMs is slow, nondeterministic, and costly. Stefan highlighted the MCP Inspector (npx @modelcontextprotocol/inspector):

MCP Inspector JSON-RPC Payloads
MCP Inspector JSON-RPC Payloads

  • Isolated Web Interface: Connects directly to local Stdio executables or remote HTTP endpoints with CSRF protection tokens.
  • Direct Invocation: Test tools, inspect prompts, browse resources, and view raw incoming and outgoing JSON-RPC request/response payloads in real time without sending tokens to an LLM.

6. Scalability Breakthrough: The Shift to Stateless Mode

Earlier versions of remote MCP relied on long-lived stateful sessions and server-to-client reverse RPC callbacks. This created severe deployment limitations: servers required sticky sessions on reverse proxies and could not survive container restarts or horizontal scaling.

Stateless Input Required Scalability
Stateless Input Required Scalability

Stateless Input-Required Protocol (2026-07-28 Spec)

In the latest SDK:

  1. When a server tool requires additional input or human authorization, it does not keep an open socket thread blocked.
  2. Instead, it returns an input_required error result detailing the exact input schema needed, accompanied by an encrypted or Base64-encoded continuation state token.
  3. The client receives the error, prompts the human user, and issues a fresh HTTP request containing the user's answers and the state token.
  4. Any server instance behind a round-robin load balancer can decode the continuation token and complete the action.
  5. Mixed-Mode Compatibility: For legacy clients that have not updated to the July 2026 protocol, the C# SDK includes an automated mixed-mode bridge that transparently converts the stateless error into legacy server-to-client requests if sticky sessions are active.

7. Human-in-the-Loop Elicitation

When performing critical actions (e.g. database deletions, production deployments, financial transactions), autonomous agents should not guess parameters or execute silently.

Elicitation allows C# MCP servers to mandate human confirmation:

  • In a demo planning a deployment for source.net, the tool paused and rendered a structured form inside the GitHub Copilot App.
  • The human operator selected deployment targets (Production vs Staging), rollout percentage sliders (1% to 100%), and rollback policies before the server allowed execution to proceed.

Elicitation Human-in-the-Loop Form
Elicitation Human-in-the-Loop Form


8. Enterprise Security & Authentication

A common security vulnerability in agentic systems is embedding plain-text API keys or database connection strings into agent prompts or shell environments.

Enterprise Auth MapMcp RequireAuth
Enterprise Auth MapMcp RequireAuth

The MCP C# SDK integrates natively with standard ASP.NET Core authentication:

// Secure the MCP endpoint with standard ASP.NET Core policies
app.MapMcp("/mcp/production")
   .RequireAuthorization("RequireDeploymentAdminRole");

// Inject MCP discovery into OAuth/JWT middleware
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddJwtBearer()
    .AddMcp(); // Injects resource discovery metadata for the host
  • When the host connects, it initiates standard OAuth 2.0 / OpenID Connect flows (e.g., Microsoft Entra ID).
  • The agent itself never sees credentials or tokens.
  • Inside C# tool methods, developers access the authenticated user via standard ClaimsPrincipal context to enforce Role-Based Access Control (RBAC).

Summary Comparison

Capability Legacy MCP (Pre-2026) Modern MCP C# SDK (.NET 11)
Architecture Stateful SSE + sticky sessions Stateless Mode by default (Horizontal scaling)
Interactive UI Text / Markdown output only MCP Apps (Embedded responsive iframes)
Human Governance Agent guesses parameters Elicitation (Structured user form schemas)
Security Model Unauthenticated / plain API tokens Native ASP.NET Core Auth (.RequireAuthorization)
Testing Chat prompt trial-and-error MCP Inspector direct JSON-RPC test harness
.NET Integration Custom JSON-RPC wrappers First-class Microsoft.Extensions.AI alignment