Building Protected MCP Servers – Insights from Den Delimarsky
Written by Om-Shree-0709 on .
- Problem
- Intuition
- C# Server Setup – Secure MCP with ASP.NET Core
- Python Client Example – Token Exchange and Secure Call
- Key Notes
- Acknowledgements
Den Delimarsky of Microsoft delves into the emerging authorization specification for MCP servers, showcasing how to implement protected servers with minimal friction using the C# SDK.
Problem
Building secure, standards-compliant MCP servers is complex. Developers often shy away from implementing OAuth flows, token validation, and auth metadata publishing.
Challenges include:
- Handling OAuth 2.1 flows
- Returning protected resource metadata
- Verifying JSON Web Tokens (JWTs)
- Ensuring compatibility across identity providers (Okta, Entra ID, AWS)
The goal: reduce the developer burden via drop-in SDK components.
Intuition
The new MCP authorization spec separates the authorization server from the resource server, so each can evolve independently. Your MCP server just needs to:
- Advertise the auth server via metadata
- Respond with
401 Unauthorized
and a pointer to that metadata - Validate access tokens using standard JWT libraries
Microsoft's C# SDK abstracts away much of this, allowing developers to declare auth support declaratively.
C# Server Setup – Secure MCP with ASP.NET Core
Here’s a simplified view of how to set up a protected MCP server in C#:
This configures an ASP.NET Core MCP server that:
- Validates tokens
- Advertises protected resource metadata
- Uses standard OAuth 2.1 and JWT validation
Python Client Example – Token Exchange and Secure Call
Below is a Python client that mimics the MCP flow: get metadata, authorize, then make a protected call.
Key Notes
- Authorization spec uses OAuth 2.1 + MCP metadata extension.
- Developer effort is reduced to just wiring standard components.
- Protected metadata docs (JSON or JWT) help clients discover auth servers.
- Visual Studio Code now supports this natively for registered MCPs.
Acknowledgements
This article is based on Den Delimarsky's insightful talk at the Session: Building Protected MCP Servers, where he demonstrated Microsoft's streamlined C# SDK for secure MCP server implementation.
Special thanks to the Anthropic team and the broader MCP developer community for advancing open, modular agent security standards.
Written by Om-Shree-0709 (@Om-Shree-0709)