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

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.

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.

Three-Tier Layering Architecture

| 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();

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:

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.
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):

- 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 Protocol (2026-07-28 Spec)
In the latest SDK:
- When a server tool requires additional input or human authorization, it does not keep an open socket thread blocked.
- Instead, it returns an
input_requirederror result detailing the exact input schema needed, accompanied by an encrypted or Base64-encoded continuation state token. - The client receives the error, prompts the human user, and issues a fresh HTTP request containing the user's answers and the state token.
- Any server instance behind a round-robin load balancer can decode the continuation token and complete the action.
- 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.

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.

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
ClaimsPrincipalcontext 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 |

