File tree Expand file tree Collapse file tree 2 files changed +1
-7
lines changed
samples/ProtectedMCPServer
src/ModelContextProtocol.AspNetCore Expand file tree Collapse file tree 2 files changed +1
-7
lines changed Original file line number Diff line number Diff line change 9898app . UseAuthentication ( ) ;
9999app . UseAuthorization ( ) ;
100100
101- // Map MCP endpoints with authorization
102- // Note: The SDK will automatically map /.well-known/oauth-protected-resource
103- // and make it accessible without authorization
104- app . MapMcp ( ) ;
101+ app . MapMcp ( ) . RequireAuthorization ( McpAuthenticationDefaults . AuthenticationScheme ) ;
105102
106103Console . WriteLine ( "Starting MCP server with authorization at http://localhost:7071" ) ;
107104Console . WriteLine ( "PRM Document URL: http://localhost:7071/.well-known/oauth-protected-resource" ) ;
Original file line number Diff line number Diff line change @@ -65,9 +65,6 @@ public static IEndpointConventionBuilder MapMcp(this IEndpointRouteBuilder endpo
6565 . WithMetadata ( new ProducesResponseTypeMetadata ( StatusCodes . Status200OK , contentTypes : [ "application/json" ] ) )
6666 . AllowAnonymous ( )
6767 . WithDisplayName ( "MCP Resource Metadata" ) ;
68-
69- // Apply authorization to MCP endpoints
70- mcpGroup . RequireAuthorization ( McpAuthenticationDefaults . AuthenticationScheme ) ;
7168 }
7269
7370 return mcpGroup ;
You can’t perform that action at this time.
0 commit comments