Authorization Support (Using ASP.NET Core Native AuthN/AuthZ Integration)#377
Conversation
Co-authored-by: Stephen Halter <halter73@gmail.com>
Co-authored-by: Stephen Halter <halter73@gmail.com>
…sions.cs Co-authored-by: Stephen Halter <halter73@gmail.com>
# Conflicts: # tests/ModelContextProtocol.AspNetCore.Tests/HttpServerIntegrationTests.cs
…zation more reliable
# Conflicts: # src/ModelContextProtocol.Core/Client/StreamableHttpClientSessionTransport.cs
Aiming for a merge in the next couple of days. Need to run a few extra tests. |
|
@localden I was trying to integrate with Auth0, and having some issue. I am using Client Id / Secrect so Dynamic Client Registration is off. As per the documentation authorization-code-flow-with-pkce we should pass audience however from As of now, my soln is like below, which works - ClientOAuthOptions.cs BuildAuthorizationUrl in ClientOAuthProvider.cs ExchangeCodeForTokenAsync in ClientOAuthProvider.cs essentially add the above block whereever required. and finally from Client potentially, Another question in slightly different note, How do I get AccessToken and RefreshToken which we received from auth server for that McpTool. My scenario is - User will authenticate MCPtool in client but tool will be invoked from SignalR hub using SK, I would like to pass the same accesstoken in header which i received from client |
…id-configuration in TestOAuthServer
|
@anktsrkr ASP.NET Core has something similar to your proposed
You can use IHttpContextAccessor in |
- This takes inspiration from ASP.NET Core's OAuthOptions.AdditionalAuthorizationParameters



Implements the authorization flow for clients and servers, per specification. Instead of re-implementing everything from scratch, this follows the suggestions from #349 and uses the native ASP.NET Core constructs to handle post-discovery steps server-side.
Developer experience
Server
HTTP context in tools
.AddHttpContextAccessoris used to ensure that tools can access the HTTP context (such as the authorization header contents).Tools that want to use the HTTP context will need to amend their signatures to include a reference to
IHttpContextAccessor, like this:Client
Fixes #521