openai-mcp-agent-dotnet
This is an MCP agent application built using .NET, leveraging Azure OpenAI and a remote MCP server written in TypeScript. The application runs on Azure Container Apps and includes built-in security features.
GitHub Stars
18
User Rating
Not Rated
Favorites
0
Views
77
Forks
11
Issues
4
name: .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 either Azure AI Foundry instance or GitHub Models.
- If you use Azure AI Foundry, make sure you have the GPT-5-mini models deployed 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 -ForceInitialize
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.Make sure that your deployed model name is
gpt-5-mini. If your deployed model is different, updatesrc/McpTodo.ClientApp/appsettings.json.{ "OpenAI": { // Make sure this is the right deployment name. "DeploymentName": "gpt-5-mini" } }
Get MCP Server App
Clone the MCP server.
git clone https://github.com/Azure-Samples/mcp-container-ts.git ./src/McpTodo.ServerAppSet JWT token.
# zsh/bash ./scripts/set-jwttoken.sh# PowerShell ./scripts/Set-JwtToken.ps1
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 loginAdd JWT token to azd environment.
# zsh/bash env_dir=".azure/$(azd env get-value AZURE_ENV_NAME)" mkdir -p "$env_dir" cat ./src/McpTodo.ServerApp/.env >> "$env_dir/.env"# PowerShell $dotenv = Get-Content ./src/McpTodo.ServerApp/.env $dotenv | Add-Content -Path ./.azure/$(azd env get-value AZURE_ENV_NAME)/.env -Encoding utf8 -ForceDeploy apps to Azure.
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 falseDuring the deployment, you will be asked to enter the Azure Subscription, location and OpenAI connection string.
The connection string should be in the format of
Endpoint={{AZURE_OPENAI_ENDPOINT}};Key={{AZURE_OPENAI_API_KEY}}. The Azure OpenAI API endpoint should look likehttps://<location>.api.cognitive.microsoft.com/.You can add GitHub PAT in the same format above to use GitHub Models like
Endpoint=https://models.inference.ai.azure.com;Key={{GITHUB_PAT}}.
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
Run locally
Make sure you're in the
openai-mcp-agent-dotnetdirectory.Add Azure OpenAI API Key.
dotnet user-secrets --project ./src/McpTodo.ClientApp set ConnectionStrings:openai "Endpoint={{AZURE_OPENAI_ENDPOINT}};Key={{AZURE_OPENAI_API_KEY}}"NOTE: You can add GitHub PAT in the same format above to use GitHub Models like
Endpoint=https://models.inference.ai.azure.com;Key={{GITHUB_PAT}}.Run the MCP server app.
cd ./src/McpTodo.ServerApp npm run devRun the client app in another terminal.
dotnet watch run --project ./src/McpTodo.ClientAppNavigate to
https://localhost:7256orhttp://localhost:5011and 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.Type
CTRL+Cto stop the agent app.
Run in local containers
Make sure that you're running either Docker Desktop or Podman Desktop on your local machine.
Make sure you're in the
openai-mcp-agent-dotnetdirectory.Export user secrets to
.env.# zsh/bash dotnet user-secrets list --project src/McpTodo.ClientApp \ | sed 's/ConnectionStrings:openai/ConnectionStrings__openai/' \ | sed 's/McpServers:JWT:Token/McpServers__JWT__Token/' > .env# PowerShell $($(dotnet user-secrets list --project src/McpTodo.ClientApp) ` -replace "ConnectionStrings:openai", "ConnectionStrings__openai") ` -replace "McpServers:JWT:Token", "McpServers__JWT__Token" | Out-File ".env" -ForceRun both apps in containers.
docker compose up --buildNavigate to
http://localhost:8080and 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.Type
CTRL+Cto stop all containers.Delete all running containers.
docker compose down
Resources
Microsoft Azure code samples and examples in .NET, Java, Python, JavaScript, TypeScript, PHP and Ruby
7,170
Followers
3,028
Repositories
0
Gists
0
Total Contributions
Shrimp Task Manager is a task tool built for AI Agents, emphasizing chain-of-thought, reflection, and style consistency. It converts natural language into structured dev tasks with dependency tracking and iterative refinement, enabling agent-like developer behavior in reasoning AI systems.
The Voice Assistant MCP Server is a powerful Model Context Protocol (MCP) server that integrates Twilio Voice, Deepgram AI, and OpenAI. This system enables AI assistants to conduct phone interviews, deliver notifications, and manage HR communications through natural voice conversations. Utilizing real-time voice processing, it facilitates seamless interactions with candidates.