Repository navigation
Replies: 1 comment
|
There's no public var transport = new HttpClientTransport(new()
{
Endpoint = new Uri("https://example.com/mcp"),
OAuth = new ClientOAuthOptions
{
RedirectUri = new Uri("http://localhost:1179/callback"),
AuthorizationCallbackHandler = async (ctx, ct) =>
{
// ctx.AuthorizationUri is the auth URL
return await HandleLoginAsync(ctx, ct);
}
}
});
await using McpClient client = await McpClient.CreateAsync(transport);There's a complete example in https://github.com/modelcontextprotocol/csharp-sdk/tree/main/samples/ProtectedMcpClient |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Pre-submission Checklist
Question Category
Your Question
Like the title suggests, I'd like to know if there is a standard way to query for an MCP server authentication URL (or maybe the ProtectedResourceMetadata as a whole) before invoking
McpClientFactory.CreateAsync.The way I found to override this is first to issue an HTTP GET to the URL of the MCP Server and check the
www-authenticateheader to get the ProtectedResourceMetadata URL but I feel like there should be an easier way, like McpClient.GetProtectedResourceMetadata.Thanks to the helpers.
All reactions