About .NET OpenAI MCP Agent
.NET OpenAI MCP Agent is a sample project showing how to build an AI agent in .NET using OpenAI models that connects to an MCP server hosted on Azure Container Apps. It suits developers who want a reference for combining .NET with Azure services.
Key features
- 01Blazor-based MCP host and client in .NET
- 02Connects to a TypeScript to-do MCP server
- 03Client and server deployed to Azure Container Apps
- 04Deployment through azd commands
Use cases
- 01Learning how to build an MCP client agent in .NET
- 02Deploying a remote MCP server to Azure Container Apps
- 03Reviewing how Azure OpenAI can be combined with MCP
MCP support
The project includes both an MCP client and an MCP server. The Blazor app acts as the client, connecting to a remote TypeScript to-do MCP server and using its functions through the agent.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEname: .NET OpenAI MCP Agent description: This is an MCP agent app written in .NET, using OpenAI, with a remote MCP server written in TypeScript. languages:
- csharp
- bicep
- azdeveloper products:
- azure-openai
- azure-container-apps
- azure page_type: sample urlFragment: openai-mcp-agent-dotnet
.NET OpenAI MCP Agent
This is an MCP agent app written in .NET, using Azure OpenAI, with a remote MCP server written in TypeScript.
Features
This app provides features like:
- The MCP host + MCP client app is written in .NET Blazor.
- The MCP client app connects to a to-do MCP server written in TypeScript.
- Both MCP client and server apps are running on Azure Container Apps (ACA).
- The MCP client app is secured by the built-in auth of ACA.
- The MCP server app is only accessible from the MCP client app.

Prerequisites
- .NET 9 SDK
- Visual Studio Code + C# Dev Kit
- node.js LTS
- Docker Desktop or Podman Desktop
- Azure Subscription
Getting Started
You can now use GitHub Codespaces to run this sample app (takes several minutes to open it)! 👉 .
Get Azure AI Foundry or GitHub Models
- To run this app, you should have an Azure AI Foundry instance.
- If you use Azure AI Foundry, make sure you have the GPT-5-mini models deployed.
- As a default, the deployed model name is
gpt-5-mini.
Get AI Agent App
-
Create a directory for the app.
# zsh/bash mkdir -p openai-mcp-agent-dotnet# PowerShell New-Item -ItemType Directory -Path openai-mcp-agent-dotnet -Force -
Initialize
azd.cd openai-mcp-agent-dotnet azd init -t openai-mcp-agent-dotnetNOTE: You'll be asked to enter an environment name, which will be the name of your Azure Resource Group. For example, the environment name might be
openai-mcp-agent.
Run on Azure
-
Check that you have the necessary permissions:
- Your Azure account must have the
Microsoft.Authorization/roleAssignments/writepermission, such as Role Based Access Control Administrator, User Access Administrator, or Owner at the subscription level. - Your Azure account must also have the
Microsoft.Resources/deployments/writepermission at the subscription level.
- Your Azure account must have the
-
Login to Azure.
azd auth login -
Deploy apps to Azure. It will automatically find the MCP server app and deploy it at the same time.
azd upNOTE:
-
By default, the MCP client app is protected by the ACA built-in auth feature. You can turn off this feature before running
azd upby setting:azd env set USE_LOGIN false -
By default, the agent uses
gpt-5-mini. You can change it to something else by setting:azd env set GPT_MODEL_NAME <azure-openai-model-name> -
By default, the agent uses the keyless approach for Azure OpenAI authentication. You can change it to use Azure OpenAI API key by setting:
azd env set AOAI_USE_API_KEY true -
By default, the agent is production mode. You can change it to the development mode to either
BothorClientthat shows more detailed logs by setting:azd env set ENABLE_DEVELOPMENT_MODE Both -
By default, the MCP server app is production mode. You can change it to the development mode to either
BothorServerthat shows more detailed logs by setting:azd env set ENABLE_DEVELOPMENT_MODE Both -
During the deployment,
- You will be asked to enter the Azure Subscription and two locations - one for Azure AI Foundry and the other for the rest of resources.
-
-
In the terminal, get the client app URL deployed. It might look like:
https://mcptodo-clientapp.{{some-random-string}}.{{location}}.azurecontainerapps.io/ -
Navigate to the client app URL, log-in to the app and enter prompts like:
Give me list of to do. Set "meeting at 1pm". Give me list of to do. Mark #1 as completed. Delete #1 from the to-do list.NOTE: You might not be asked to login, if you've set the
USE_LOGINvalue tofalse. -
Clean up all the resources deployed.
azd down --force --prune
Resources
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.