Understanding Authorization in MCP changeddocs/draft/tutorials/security/authorization
Nearest release: v2.1.316, published 6 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 31 Oct 2026 07:36 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 31 Oct 2026 07:37 UTC.
Upstream edited
Recorded here
Lines+62added
Lines−3removed
From line
922
where the diff opens
First seen
26 Aug 2026
this site's first read of the page
Recorded edits8to this page, all time
The whole hunk
from line 922, old and new numbered
/
from line 922
922922>
923923> To set up authorization in your MCP server using the MCP C# SDK, you can lean on the standard ASP.NET Core builder pattern. Instead of using the introspection endpoint provided by Keycloak, we will use built-in ASP.NET Core capabilities for token validation.
924924>
925> In the root of your server folder, create two files, `Program.cs` and `ProtectedMcpServer.csproj`, and a `Tools` folder. Fill `Program.cs` with:
926>
925927> ```csharp theme={null}
926928> using Microsoft.AspNetCore.Authentication.JwtBearer;
927929> using Microsoft.IdentityModel.Tokens;
from line 985
983985> {
984986> options.ResourceMetadata = new()
985987> {
986> Resource = new Uri(serverUrl),
987> ResourceDocumentation = new Uri("https://docs.example.com/api/math"),
988> AuthorizationServers = { new Uri(authorizationServerUrl) },
988> Resource = serverUrl,
989> ResourceDocumentation = "https://docs.example.com/api/math",
990> AuthorizationServers = { authorizationServerUrl },
989991> ScopesSupported = ["mcp:tools"]
990992> };
991993> });
from line 1013
10111013> Console.WriteLine("Press Ctrl+C to stop the server");
10121014>
10131015> app.Run(serverUrl);
1016> ```
1017>
1018> Fill `ProtectedMcpServer.csproj` with:
1019>
1020> ```xml theme={null}
1021> <Project Sdk="Microsoft.NET.Sdk.Web">
1022>
1023> <PropertyGroup>
1024> <TargetFramework>net9.0</TargetFramework>
1025> <Nullable>enable</Nullable>
1026> <ImplicitUsings>enable</ImplicitUsings>
1027> <!-- Identifier for the local secret store, not a secret itself. -->
1028> <UserSecretsId>local-authorization-mcp-server</UserSecretsId>
1029> </PropertyGroup>
1030>
1031> <ItemGroup>
1032> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.18" />
1033> <PackageReference Include="ModelContextProtocol" Version="2.0.0" />
1034> <PackageReference Include="ModelContextProtocol.AspNetCore" Version="2.0.0" />
1035> </ItemGroup>
1036>
1037> </Project>
1038> ```
1039>
1040> In the `Tools` folder, create `MathTools.cs` and fill it with:
1041>
1042> ```csharp theme={null}
1043> using System.ComponentModel;
1044> using ModelContextProtocol.Server;
1045>
1046> namespace ProtectedMcpServer.Tools;
1047>
1048> [McpServerToolType]
1049> public sealed class MathTools
1050> {
1051> [McpServerTool, Description("Add two numbers together.")]
1052> public Task<double> Add(
1053> [Description("First operand")] double a,
1054> [Description("Second operand")] double b)
1055> {
1056> return Task.FromResult(a + b);
1057> }
1058>
1059> [McpServerTool, Description("Multiply two numbers together.")]
1060> public Task<double> Multiply(
1061> [Description("First operand")] double a,
1062> [Description("Second operand")] double b)
1063> {
1064> return Task.FromResult(a * b);
1065> }
1066> }
1067> ```
1068>
1069> Then from the server's root, run:
1070>
1071> ```bash theme={null}
1072> dotnet run
10141073> ```
10151074>
10161075> For more details, see the [C# SDK documentation](https://github.com/modelcontextprotocol/csharp-sdk).
No line in this hunk matches that.