-
Notifications
You must be signed in to change notification settings - Fork 4.2k
.Net: Sample using OAuth to access a protected MCP server #12680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.Net: Sample using OAuth to access a protected MCP server #12680
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new .NET sample demonstrating how to authenticate via OAuth 2.0 to access a protected Model Context Protocol (MCP) server and invoke its tools through Semantic Kernel.
- Introduces a browser-based authorization code flow and SSE transport for MCP.
- Includes detailed README for prerequisites, configuration, and running steps.
- Registers the new sample in the solution and configures its project dependencies.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
dotnet/samples/Demos/ModelContextProtocolPluginAuth/README.md | Added comprehensive setup, OAuth flow explanation, and usage guide. |
dotnet/samples/Demos/ModelContextProtocolPluginAuth/Program.cs | Implemented OAuth 2.0 authorization code flow and MCP tool invocation. |
dotnet/samples/Demos/ModelContextProtocolPluginAuth/ModelContextProtocolPluginAuth.csproj | Configured project target framework and package references. |
dotnet/SK-dotnet.slnx | Added the new sample project to the solution. |
Comments suppressed due to low confidence (3)
dotnet/samples/Demos/ModelContextProtocolPluginAuth/README.md:39
- This line appears to be stray or incomplete; remove it or replace with the intended content.
"..."
dotnet/samples/Demos/ModelContextProtocolPluginAuth/README.md:20
- The project targets .NET 8.0 in the csproj but README lists .NET 9.0; update one of them to ensure consistency.
- .NET 9.0 or later
dotnet/samples/Demos/ModelContextProtocolPluginAuth/Program.cs:47
- [nitpick] Casing inconsistency: consider using 'ProtectedMCPClient' to match the 'MCP' acronym and other sample naming conventions.
ClientName = "ProtectedMcpClient",
837e5ba
to
7fdca5a
Compare
…12680) ### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
Motivation and Context
Description
Contribution Checklist