Opening application features to AI agents is simpler than ever with Model Context Protocol (MCP). This guide details the technical steps and OAuth 2.0 integration to set up a secure C# MCP server using .NET 11 and Duende IdentityServer.
Key points
- .NET 11 SDK now natively supports the 'mcpserver' template.
- The mental model of a web API applies directly to MCP tools.
- OAuth 2.0 must be used to secure any publicly exposed MCP server.
- Access control is implemented using the 'mcp:tools' scope in Duende IdentityServer.
- JWT Bearer is configured in ASP.NET Core along with resource metadata.
- Transitioning from standard (stdio) to remote (HTTP) transport is possible.
Real-world use
- .Exposing tools for integration with a .NET-based AI agent.
- Preventing unauthorized access of MCP tools by external agents.
- Using standard OAuth authentication for enterprise MCP server endpoints.
This summary was generated by the agent from the original post on Duende Software Blog. The full text and all rights belong to its author and publisher. Go to original