This lab is currently in Beta, content may be updated as we refine the material
LABINTERMEDIATE

Build a Custom MCP Server for Azure API Management in C#

Provision a real APIM Consumption-tier gateway, scaffold a C# MCP server with the official ModelContextProtocol .NET SDK, expose four read-only APIM tools, and drive the server from both Claude Desktop and a Microsoft Agent Framework agent.

90 minutes
ai/azure
Build a Custom MCP Server for Azure API Management in C# - Platform Engineering Hands-On Lab Icon

Lab Overview

🛠 Lab from the AI Platform Engineering on Azure short course. Doubles as the Azure-flavored extension for AI Platform Engineering Bootcamp Week 4 (the Python-leaning `ai-mcp-server` lab). Bootcamp landing page: https://academy.tekanaid.com/bootcamps/ai-platform-engineering-bootcamp Parent course(s):

  • AI Platform Engineering on Azure (slug: ai-platform-engineering-azure)

🟡 Beta lab. Hands-on instructions, check scripts, and solve scripts are in active development.

Section 2 of the parent course made three design decisions: which slice of APIM's management surface is safe to expose as MCP tools, how to build an MCP server in C# with the official .NET SDK, and how to keep the tool surface read-only and token-efficient. This lab is where those decisions become a working artifact.

You provision a real Azure API Management instance on the Consumption tier (~5-minute provision, $3.50/M calls — no mock), seed it with two demo APIs, then scaffold a C# console project on .NET 8 that hosts an MCP server via `ModelContextProtocol` 1.3.0 + `ModelContextProtocol.Core` 1.2.0 + `ModelContextProtocol.AspNetCore` 1.2.0. The server starts on stdio so it can be driven by Claude Desktop, the MCP Inspector, or a local agent process. You ship a `ping` smoke-test tool first, verify the JSON-RPC handshake by hand, then implement the four lesson-defined read tools: `apim_list_apis`, `apim_get_api_config`, `apim_get_policies` (summarized — no raw XML), and `apim_get_traffic_metrics`. Authentication is service-principal via `DefaultAzureCredential` and the `Azure.ResourceManager.ApiManagement` SDK.

The final two tasks wire the server into real clients. Task 4 connects MCP Inspector and walks through a natural-language interaction where the LLM picks the right tool and summarizes the response. Task 5 spins up a slim Microsoft Agent Framework ReAct agent (mirroring the Lab 1 pattern, trimmed for this lab's VM) that wires both the official `Azure.Mcp` server from Lab 1 AND your new APIM MCP server side-by-side. You send a single prompt that touches both — "what AKS clusters do I have and what APIs are in our APIM instance?" — and watch the agent fan out to two MCP servers, fuse the responses, and answer in one shot.

By the end you will have built and operated the Azure-specific MCP-server pattern Lab 3 needs: a read-only, token-efficient, service-principal-authenticated MCP surface over a critical platform-engineering control plane, consumed from both a desktop client and an agent in the same loop.

What You'll Learn

Provision an Azure API Management Consumption-tier instance and seed it with two demo APIs

Scaffold a C# .NET 8 MCP server with the official ModelContextProtocol SDK pinned to 1.3.0

Verify the MCP JSON-RPC handshake by hand (initialize → notifications/initialized → tools/list → tools/call)

Implement four read-only APIM tools that return structured, token-efficient JSON (no raw policy XML)

Authenticate the server to APIM via service principal using DefaultAzureCredential + Azure.ResourceManager.ApiManagement

Drive the MCP server from MCP Inspector and from a Microsoft Agent Framework ReAct agent that fans out across two MCP servers (Azure.Mcp + APIM MCP) in one prompt

Prerequisites

basic-csharp-knowledge

basic-azure-knowledge

mcp-fundamentals

linux-command-line

Technologies Covered

aiazureapimmcpcsharpmodel-context-protocolmicrosoft-agent-frameworkai-platform-engineering

Choose your plan

Simple, Transparent Pricing

Unlock full access to TeKanAid courses, labs, and bootcamps

Buying for a team? Private corporate training is available for up to 15 learners.View team training
MonthlyQuarterly

Pro

Course content without labs

$59/month

Renews automatically. Cancel anytime.

Final price verified at checkout.

  • Full access to all courses
  • Progress tracking
  • Certificate of completion
  • Community access
  • Bootcamp participation
  • New content access
Recommended

Premium

Full access with hands-on labs

$99/month

Renews automatically. Cancel anytime.

Final price verified at checkout.

  • Everything in Pro
  • Unlimited hands-on labs
  • Lab AI Assistant
  • Accelerator bootcamps with live office hours
  • Priority support

Prefer a single course?

Purchase individual courses for a one-time fee of $79. Full access to course content, quizzes, certificates, and community features, lab access is not included.

Browse Courses

Try it free, no credit card

Three free ways to start. All bridge into the paid Premium catalog when you're ready.

Not ready to commit? The crash course is email-only. No academy account required.

Ready to Get Started?

Start this hands-on lab and build real-world Platform Engineering skills

Get Access Now