DEV Community

Cover image for Building MCP Servers in .NET for AI Agents, a 10-part tutorial series
Taiseer Joudeh
Taiseer Joudeh

Posted on

Building MCP Servers in .NET for AI Agents, a 10-part tutorial series

If you're a .NET developer and you want to build an MCP server, it's hard to know where to start. Most examples stop at a "hello world" tool running on your own machine. I wanted a series that goes from that first tool all the way to a server that real users can sign in to and use from different AI clients.

So I wrote one. It's 10 parts, it's free, and it's built on .NET 10 and ASP.NET Core from start to finish.

What you'll build

The whole series builds one sample app, BitOfTech Expenses, an MCP server for expense reports and approvals. Each part adds to the one before it, so by the end you have a complete, working server and not a set of separate demos.

By the end of the series, you'll have:

  • A working MCP server in C# with tools, resources and prompts, connected to a real database and an external API.
  • The server hosted in ASP.NET Core and secured with Microsoft Entra ID, so each user only sees and runs the tools they're allowed to use.
  • A deployment on Azure Container Apps that you can use from VS Code Copilot, Claude, your own .NET agent and Microsoft Foundry.
  • A clear view of what it costs to run and how to protect it from common MCP security risks.

The 10 parts

  1. What is the Model Context Protocol? An Introduction for .NET Developers
  2. Building Your First MCP Server in C#
  3. MCP Tools, Resources and Prompts in .NET
  4. Wiring MCP Tools to Azure SQL and External APIs
  5. Hosting an MCP Server in ASP.NET Core with Streamable HTTP
  6. Building an MCP Client and AI Agent in .NET
  7. Securing an MCP Server with Microsoft Entra ID
  8. Deploying an MCP Server to Azure Container Apps
  9. Connecting an MCP Server to Microsoft Foundry Agent Service
  10. Observability, Cost Control and MCP Security

Who it's for

The series is for .NET developers who know C# and ASP.NET Core but are new to MCP. You don't need any AI or machine learning background. If you can build a Minimal API, you can follow along.

What you need

  • The .NET 10 SDK and VS Code.
  • Parts 1 to 3 run on your own machine, with no cloud account.
  • From Part 4 onwards, you need an Azure subscription.

Source code

Everything is on GitHub, with a git tag for each part. If you get stuck, you can check out the tag for the part you're on and compare it with your code.

🔗 https://github.com/tjoudeh/building-mcp-servers-dotnet

I verified every step before publishing, but MCP and its tooling change quickly. If something doesn't work for you, leave a comment here or open an issue on the repo, and I'll take a look.

Top comments (0)