Skip to content

Commit 31f8ce9

Browse files
committed
Added overload for custom scheme
1 parent a433f5a commit 31f8ce9

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/ModelContextProtocol.AspNetCore/Auth/McpAuthorizationExtensions.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,29 @@ public static class McpAuthenticationExtensions
1818
public static AuthenticationBuilder AddMcp(
1919
this AuthenticationBuilder builder,
2020
Action<McpAuthenticationOptions>? configureOptions = null)
21+
{
22+
return AddMcp(builder, "McpAuth", "MCP Authentication", configureOptions);
23+
}
24+
25+
/// <summary>
26+
/// Adds MCP authorization support to the application with a custom scheme name.
27+
/// </summary>
28+
/// <param name="builder">The authentication builder.</param>
29+
/// <param name="authenticationScheme">The authentication scheme name to use.</param>
30+
/// <param name="displayName">The display name for the authentication scheme.</param>
31+
/// <param name="configureOptions">An action to configure MCP authentication options.</param>
32+
/// <returns>The authentication builder for chaining.</returns>
33+
public static AuthenticationBuilder AddMcp(
34+
this AuthenticationBuilder builder,
35+
string authenticationScheme,
36+
string displayName,
37+
Action<McpAuthenticationOptions>? configureOptions = null)
2138
{
2239
builder.Services.TryAddSingleton<ResourceMetadataService>();
2340

2441
return builder.AddScheme<McpAuthenticationOptions, McpAuthenticationHandler>(
25-
"McpAuth",
26-
"MCP Authentication",
42+
authenticationScheme,
43+
displayName,
2744
configureOptions ?? (options => { }));
2845
}
2946
}

0 commit comments

Comments
 (0)