Skip to content

.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

Conversation

markwallace-microsoft
Copy link
Member

Motivation and Context

Description

Contribution Checklist

Copy link
Contributor

@Copilot Copilot AI left a 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",

@moonbox3 moonbox3 added .NET Issue or Pull requests regarding .NET code documentation labels Jul 9, 2025
@github-actions github-actions bot changed the title Sample using OAuth to access a protected MCP server .Net: Sample using OAuth to access a protected MCP server Jul 9, 2025
@markwallace-microsoft markwallace-microsoft added this pull request to the merge queue Jul 9, 2025
Merged via the queue into microsoft:main with commit 5162de1 Jul 9, 2025
19 checks passed
@markwallace-microsoft markwallace-microsoft deleted the users/markwallace/mcp_auth_sample branch July 9, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants