WhoBuilt

Building Protected MCP Servers

Jun 20, 2025· 20 min· 1.0K views·Watch on YouTube

Speakers

Den Delimarsky, a product engineer at Microsoft and MCP Steering Committee member, and Julia Kasper, who works in Azure API Management at Microsoft, explain protected remote MCP servers and demonstrate OAuth flows with the MCP C# SDK, Azure API Management, and VS Code.

Why remote MCP servers need protection

Den says remote MCP servers may be reachable over the public internet, so servers that connect to APIs with user-specific permissions need authorization. An API can grant different access to an admin and a contributor. Local servers run on the user’s machine and can use a wider range of authentication methods, including secrets, certificates, or passkeys.

Separate the MCP server from authorization

Den contrasts the stable March 2025 specification with a draft developed with Anthropic and security experts. The earlier approach required server developers to issue, manage, refresh, and sign tokens themselves. The draft separates the MCP server as a resource server from the authorization server, so providers such as Okta, Auth0, or Microsoft Entra ID can handle token issuance.

How the OAuth flow works

Julia says clients use metadata to find an authorization server and handle the OAuth flow, while MCP servers validate the tokens they receive. Den explains that an unauthenticated client gets an HTTP 401 response with a pointer to Protected Resource Metadata, or PRM. The PRM identifies the resource, authorization servers, supported bearer methods, and scopes so the client can discover and complete authorization.

Protected server demo with the C# SDK

Den demonstrates an ASP.NET Core MCP server configured with authentication, token validation, and PRM metadata pointing to Microsoft Entra ID. A C# client uses generic OAuth configuration to discover the metadata, obtain a token, and call a weather tool. Den says the official MCP C# SDK example was in a pull request at the time of the session.

Putting a remote MCP server behind a gateway

Julia demonstrates Azure API Management acting as a proxy between a remote MCP server and clients, with Microsoft Entra ID handling login and consent. She connects to the server using MCP Inspector and VS Code Insiders, then uses GitHub Copilot to call one of its three tools. She also shows API Management exposing tools from existing REST endpoints to VS Code.

Takeaways

  • For remote MCP servers that access user-specific APIs, validate user credentials and enforce the permissions those APIs require.
  • Use an established OAuth identity provider to handle token issuance and lifetimes instead of building that machinery into the MCP server.
  • Publish Protected Resource Metadata so clients can discover the authorization server and scopes they need.
  • Test the full client-to-server authorization flow, including token validation and tool calls, before deploying.
  • A gateway such as Azure API Management can sit between clients and a remote MCP server and connect the flow to an identity provider.

Mentioned in this talk

Search inside this talk

What was claimed 7

Related talks