.NET
Backend-Development
Artificial Intelligence

Building AI Agents with Microsoft Agent Framework and Model Context Protocol using .NET

A hands-on, comprehensive workshop for .NET developers to build production-ready AI agents using Microsoft Agent Framework and the Model Context Protocol (MCP).

Building AI Agents with Microsoft Agent Framework and Model Context Protocol using .NET

3-day workshop for .NET Developers

Course Description

A hands-on, comprehensive workshop for .NET developers to build production-ready AI agents using Microsoft Agent Framework and the Model Context Protocol (MCP). This three-day intensive combines Microsoft's enterprise-grade agentic AI framework with open standards for AI-context integration and a governance-first approach with the Agent Governance Toolkit. You'll learn to create intelligent agents that orchestrate multiple services, integrate with business systems, and provide seamless user experiences—all while leveraging familiar .NET patterns and Microsoft.Extensions.AI abstractions.

Day 1 focuses on core concepts: building chat-based agents, implementing tools and function calling, working with multiple AI providers, and understanding agent orchestration patterns. Day 2 dives into advanced implementation topics: integrating MCP servers and clients, building custom tools, implementing workflows with human-in-the-loop, and preparing agents for production deployment. Day 3 is dedicated to governance: implementing policy controls, risk management, auditability, and operational guardrails with the Agent Governance Toolkit.

Overall Learning Objectives

By the end of this workshop, participants will be able to:

  • Understand the architecture and core concepts of Microsoft Agent Framework and how it builds on Microsoft.Extensions.AI.
  • Create simple and multi-agent systems using different orchestration patterns (sequential, concurrent, handoff, magentic).
  • Implement function calling and custom tools to extend agent capabilities.
  • Integrate multiple AI inference services (Azure OpenAI, OpenAI, Ollama, Azure AI Foundry) using IChatClient abstraction.
  • Understand and implement the Model Context Protocol (MCP) for standardizing AI context integration.
  • Build MCP servers to expose resources, tools, and prompts to AI agents.
  • Build MCP clients to consume context from external MCP servers.
  • Implement workflows with conditional logic, external integrations, and checkpointing.
  • Use Aspire AppHost to orchestrate multi-agent services, MCP servers, and Docker-based dependencies for local development and deployment-ready setups.
  • Apply enterprise-grade security using Microsoft Entra Agent ID for agent authentication and authorization.
  • Implement governance controls with the Agent Governance Toolkit, including policy enforcement, audit trails, and compliance evidence.
  • Integrate agents with UI frameworks using the AG-UI protocol and CopilotKit.
  • Monitor and observe agent behavior using OpenTelemetry and responsible AI features.
  • Deploy and scale agents in production environments (containers, Azure, multi-cloud).

Day 1: Agent Framework Fundamentals

Modules & Agenda
  1. Introduction to Agentic AI with .NET

    • What are AI agents vs. traditional applications
    • Microsoft Agent Framework overview and architecture
    • Evolution: Semantic Kernel + AutoGen = Agent Framework (GA v1.0.0, current v1.1.0)
    • Microsoft.Extensions.AI abstractions (IChatClient, IEmbeddingGenerator)
    • Key capabilities: multi-agent orchestration, cloud/provider flexibility, enterprise features
    • Standards-based interoperability: Agent-to-Agent (A2A) protocol and MCP
  2. Building Your First Agent

    • Setting up the development environment
    • Creating a ChatClientAgent from an IChatClient
    • Understanding agent configuration: instructions, model parameters, tools
    • Running agents: Run() vs. RunStreamingAsync()
    • Working with chat history and conversation context
    • Structured output and response formats
  3. Function Calling and Tools

    • Understanding function calling in AI agents
    • Creating AIFunction instances with AIFunctionFactory.Create()
    • Tool execution lifecycle and error handling
    • Approval modes and human-in-the-loop for sensitive operations
    • Invoking command-line tools (CLI) directly from agents: wrapping shell commands and executables as AIFunctions without an MCP server
    • Agent Skills: file-based and class-based skills using FileAgentSkillsProvider for script and executable invocation
    • Best practices for tool design and security
  4. Multi-Provider Integration

    • Working with Azure OpenAI Service
    • Integrating OpenAI directly
    • Using local models with Ollama
    • Azure AI Foundry integration
    • Provider-agnostic design patterns
    • Switching and comparing providers
  5. Agent Orchestration Patterns

    • Single agent vs. multi-agent systems
    • Sequential orchestration: step-by-step agent chains
    • Concurrent orchestration: parallel agent execution
    • Handoff orchestration: specialized agent collaboration
    • Magentic orchestration: lead agent directing other agents
    • Group chat patterns for collaborative agents
  6. Introduction to Model Context Protocol (MCP)

    • What is MCP and why it matters
    • MCP architecture: servers, clients, and transports
    • Core MCP concepts: resources, tools, prompts, and sampling
    • MCP C# SDK overview (ModelContextProtocol.* packages, now stable at v1.2.0)
    • MCP ecosystem and the registry
    • Standards-based context integration benefits
Hands-On Exercises (Day 1)
  • Create your first agent with Azure OpenAI and test basic chat interactions
  • Implement custom tools using AIFunctionFactory.Create() for file operations and external API calls
  • Invoke CLI tools directly from an agent: wrap a shell command or executable as an AIFunction and test it without any MCP server
  • Build a file-based skill using FileAgentSkillsProvider to expose scripts and executables as agent tools
  • Build a function-calling agent with approval workflow for sensitive actions using ApprovalRequiredAIFunction
  • Create a multi-agent system using handoff orchestration (e.g., triage → specialist agents)
  • Implement a magentic orchestration pattern with a coordinator and specialized agents
  • Set up Ollama locally and run the same agent with different providers
  • Explore existing MCP servers from the registry and understand their capabilities
Outcomes (Day 1)

Participants can build single and multi-agent systems using Agent Framework, implement custom tools with AIFunctionFactory, invoke CLI tools and scripts directly as agent tools using Skills and AIFunctionFactory, work with multiple AI providers, and understand how MCP standardizes context integration.


Day 2: Advanced Topics, Integration, and Production-Ready Agents

Modules & Agenda
  1. Deep Dive: Model Context Protocol Implementation

    • Building MCP servers with the C# SDK (v1.2.0)
    • Implementing resources: exposing data sources to agents
    • Implementing tools: server-side functions for agents
    • Implementing prompts: reusable prompt templates
    • Server transports: stdio, Streamable HTTP (default in v1.2.0); legacy SSE transport now opt-in via EnableLegacySse
    • Building MCP clients to consume external context
    • Using McpClient to discover and invoke tools from servers
    • Integrating MCP tools (McpClientTool) into Agent Framework agents
  2. Building Custom MCP Tools and Resources

    • Design patterns for MCP server architecture
    • Exposing enterprise data sources as MCP resources
    • Creating domain-specific tools with proper descriptions and schemas
    • Handling authentication and authorization in MCP servers
    • Sampling: allowing MCP servers to query LLMs via the client
    • When to use MCP vs. direct CLI invocation: trade-offs between MCP servers and AIFunction/Skill-based tool wrappers
    • Best practices for MCP server development and testing
  3. Workflows and Advanced Orchestration

    • Understanding Agent Framework Workflows
    • Workflows vs. Agents: when to use each
    • Executors and edges: building the workflow graph
    • Conditional routing and dynamic execution paths
    • External integration patterns: request/response, webhooks
    • Checkpointing: save and resume long-running workflows
    • Human-in-the-loop patterns in workflows
  4. Agent Identity, Security, and Governance

    • Microsoft Entra Agent ID overview (agent identity platform)
    • Agent identity blueprints and agent identities
    • Authentication and authorization for AI agents
    • OAuth 2.0 and OIDC for agents
    • Agent registry and discovery
    • Responsible AI features: prompt injection protection, task adherence
    • Security best practices for production agents
  5. User Interfaces and Integration

    • AG-UI protocol overview
    • Integrating agents with CopilotKit
    • ASP.NET Core integration: MapAGUI endpoint
    • Server-Sent Events (SSE) for streaming responses
    • Frontend tool calling and shared state
    • Handling approvals and confirmations in the UI
    • Building chat interfaces with AG-UI Dojo samples
  6. Observability, Monitoring, and Deployment

    • OpenTelemetry integration for agent observability
    • Tracing agent execution and tool invocations
    • Metrics and logging best practices
    • Debugging and troubleshooting agents
    • Containerizing agents for deployment
    • Orchestrating agent services, MCP servers, and Docker dependencies with Aspire AppHost
    • Deployment patterns: Azure Container Apps, Kubernetes, on-premises
    • Scaling strategies and performance optimization
    • CI/CD pipelines for agent applications
Hands-On Exercises (Day 2)
  • Build a custom MCP server exposing company data as resources and tools
  • Create an MCP client that consumes multiple external MCP servers
  • Integrate MCP tools from a custom server into an Agent Framework agent
  • Implement a workflow with conditional routing, external API calls, and checkpointing
  • Set up Microsoft Entra Agent ID for agent authentication
  • Build a web UI for your agent using CopilotKit and the AG-UI protocol
  • Add OpenTelemetry instrumentation to observe agent behavior
  • Create a Aspire AppHost to orchestrate agent services, MCP servers, and Docker dependencies locally
  • Containerize and deploy an agent application to Azure Container Apps
Outcomes (Day 2)

Participants can implement production-ready agents with custom MCP integrations, workflows, security, UI, observability, and deployment strategies.


Day 3: Agent Governance and Enterprise Controls with Agent Governance Toolkit

Modules & Agenda
  1. Governance Fundamentals for Agent Systems
  • Why governance is mandatory for enterprise AI agents
  • Governance domains: policy, risk, compliance, accountability, and operations
  • Mapping governance requirements to Agent Framework architecture
  • Defining ownership and responsibility (engineering, security, compliance, operations)
  • Governance-by-design principles for .NET agent projects
  1. Implementing Governance with Agent Governance Toolkit
  • Agent Governance Toolkit overview and architecture
  • Defining and versioning governance policies
  • Guardrails for prompts, tools, external actions, and data access
  • Approval flows and escalation paths for high-risk actions
  • Capturing audit logs, decision traces, and evidence artifacts
  • Integrating governance checks into CI/CD and release gates
  1. Operational Governance, Risk, and Compliance
  • Runtime monitoring for policy violations and drift
  • Risk scoring and control effectiveness tracking
  • Incident response for agent misuse, prompt injection, and unsafe tool invocation
  • Governance dashboards and reporting for internal/external audits
  • Aligning controls with Responsible AI, security baselines, and regulatory expectations
  • Continuous governance improvement loop for agent systems
Hands-On Exercises (Day 3)
  • Install and configure Agent Governance Toolkit in a sample Agent Framework solution
  • Define governance policies for tool usage, data boundaries, and escalation thresholds
  • Implement approval and rejection workflows for high-impact agent actions
  • Capture and review audit trails for agent decisions and tool calls
  • Add governance validation steps to CI/CD before deployment
  • Build an operational governance dashboard for policy compliance and incident review
Outcomes (Day 3)

Participants can operationalize governance for AI agents with the Agent Governance Toolkit, enforce policies, produce auditable evidence, and run compliant agent solutions in enterprise environments.


Target Audience

.NET developers, solution architects, and AI engineers building intelligent agent systems for enterprise applications. Suitable for those familiar with C#, ASP.NET Core, and cloud development.

Prerequisites

  • Solid C# and .NET experience
  • Familiarity with ASP.NET Core, dependency injection, and async programming
  • Basic understanding of AI/LLMs and REST APIs
  • Access to Azure subscription (for Azure OpenAI) or OpenAI API key
  • Docker basics helpful for deployment exercises

Hands-On Lab Environment

Participants will work with:

  • Visual Studio 2026 or Visual Studio Code with C# Dev Kit
  • .NET 10 SDK
  • Aspire AppHost for local service orchestration
  • Azure OpenAI Service or OpenAI API access
  • Docker Desktop (for MCP servers and deployment)
  • Sample MCP servers from the official registry

Materials Provided

  • Complete sample code for all exercises
  • Reference implementations of MCP servers and clients
  • Agent orchestration pattern templates
  • Deployment configuration samples
  • Links to official documentation and resources

Summary

After three days, participants possess the skills to design, build, govern, secure, and deploy production-grade AI agents using Microsoft Agent Framework, the Model Context Protocol, and the Agent Governance Toolkit. They understand how to integrate enterprise data sources, orchestrate multiple agents, implement workflows, enforce governance policies, and provide seamless user experiences—all within the .NET ecosystem and using open standards.

An unhandled error has occurred. Reload 🗙