anthony-c-martin/remote-mcp-dotnet-oauth
If you are the rightful owner of remote-mcp-dotnet-oauth and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project is a .NET implementation of a Model Context Protocol (MCP) server designed for deployment on Azure App Service, enabling AI models to request additional context during inference.
Model Context Protocol (MCP) Server - .NET Implementation
This project contains a .NET web app implementation of a Model Context Protocol (MCP) server. The application is designed to be deployed to Azure App Service.
This project uses OAuth OBO, which allows users to authenticate via MCP, and then gives the MCP the ability to access downstream APIs on behalf of the user. In this example, it has been given access to Azure Resource Manager APIs.
The MCP server provides an API that follows the Model Context Protocol specification, allowing AI models to request additional context during inference.
Key Features
- Complete implementation of the MCP protocol in C#/.NET using MCP csharp-sdk
- Azure App Service integration
- Custom tools support
- Support for OAUth OBO, giving the server the ability to access authenticated downstream APIs in the user's context.
Project Structure
src/
- Contains the main C# project filesProgram.cs
- The entry point for the MCP serverTools/
- Contains custom tools that can be used by models via the MCP protocolAzureResourceManagerTools.cs
- Tools for performing basic Azure Resource Manager operations
infra/
- Contains Azure infrastructure as code using Bicepmain.bicep
- Main infrastructure definitionresources.bicep
- Resource definitionsmain.bicepparam
- Parameters for deployment
Prerequisites
- Azure Developer CLI
- .NET 9 SDK
- For local development with VS Code:
Local Development
Run the Server Locally
- Clone this repository
- Navigate to the project directory
cd src
- Install required packages
dotnet restore
- Run the project:
dotnet run
- The MCP server will be available at
http://localhost:5000
- When you're done, press Ctrl+C in the terminal to stop the app
Testing the Available Tools
The server provides these tools:
- AzureResourceManager:
get_subscriptions
- Get a list of Azure subscriptionsget_resource_groups
- Get a list of Azure resource groups in a particular Azure subscription
Connect to the Local MCP Server
Using VS Code - Copilot Agent Mode
- Add MCP Server from command palette and add the URL to your running server's HTTP endpoint:
http://localhost:5000
- List MCP Servers from command palette and start the server
- In Copilot chat agent mode, enter a prompt to trigger the tool:
Fetch my Azure subscriptions
- When prompted to run the tool, consent by clicking Continue
Using MCP Inspector
- In a new terminal window, install and run MCP Inspector:
npx @modelcontextprotocol/inspector
- CTRL+click the URL displayed by the app (e.g. http://localhost:5173/#resources)
- Set the transport type to
HTTP
- Set the URL to your running server's HTTP endpoint and Connect:
http://localhost:5000
- List Tools, click on a tool, and Run Tool
Deploy to Azure
-
Login to Azure:
azd auth login
-
Initialize your environment:
azd env new
-
Deploy the application:
azd up
-
Grant admin consent (Entra Portal UI) - first time only:
- Open the Entra application in App Registrations
- Select "Manage" -> "API Permissions", and press "Grant admin consent"
This will:
- Build the .NET application
- Provision Azure resources defined in the Bicep templates
- Deploy the application to Azure App Service
Connect to Remote MCP Server
Using MCP Inspector
Use the web app's URL:
https://<webappname>.azurewebsites.net
Using VS Code - GitHub Copilot
Follow the same process as with the local app, but use your App Service URL:
https://<webappname>.azurewebsites.net
Clean up resources
When you're done working with your app and related resources, you can use this command to delete the function app and its related resources from Azure and avoid incurring any further costs:
azd down