coffeeshop-agent icon indicating copy to clipboard operation
coffeeshop-agent copied to clipboard

.NET Agents technologies (Microsoft Agent Framework, MCP, A2A, AG-UI)

coffeeshop-agent

.NET Agents technologies

This is a demonstration application. Certain scenarios presented may be unrealistic or not suitable for real-world use. Please do not replicate or deploy this in a production environment.

High level architecture

graph TD
    subgraph "Identity Provider"
        EntraID[Microsoft Entra ID]
    end

    subgraph "User Interaction"
        WebApp[ChatApp <br> - A2A Client]
    end

    subgraph "Orchestration"
        AppHost
    end

    subgraph "Backend Services"
        Counter[CounterService <br> - A2A Server/Client, MCP Client]
        Barista[BaristaService <br> - A2A Server]
        Kitchen[KitchenService <br> - A2A Server]
        ProductCatalog[ProductCatalogService <br> - MCP Server]
    end

    subgraph "Shared Infrastructure"
        ServiceDefaults
    end

    %% Core Interactions
    WebApp -- "A2A Protocol" --> Counter
    Counter -- "A2A Protocol" --> Barista
    Counter -- "A2A Protocol" --> Kitchen
    Counter -- "MCP Protocol" --> ProductCatalog

    %% Authentication & Authorization
    EntraID -- "Secures" --> WebApp
    EntraID -- "Secures" --> Counter
    EntraID -- "Secures" --> Barista
    EntraID -- "Secures" --> Kitchen
    EntraID -- "Secures" --> ProductCatalog

    %% Development-time Orchestration
    AppHost -.-> WebApp
    AppHost -.-> Counter
    AppHost -.-> Barista
    AppHost -.-> Kitchen
    AppHost -.-> ProductCatalog
    
    %% Shared Dependencies
    WebApp -- "Uses" --> ServiceDefaults
    Counter -- "Uses" --> ServiceDefaults
    Barista -- "Uses" --> ServiceDefaults
    Kitchen -- "Uses" --> ServiceDefaults
    ProductCatalog -- "Uses" --> ServiceDefaults

    class WebApp user;
    class Counter,Barista,Kitchen,ProductCatalog backend;
    class AppHost orchestrator;
    class ServiceDefaults shared;
    class EntraID identity;

Get starting

dotnet run

Access to .NET Aspire dashboard, then open the web, and from the chat box type:

a black coffee pls
I want a black coffee, cappuccino, latte, 2 chicken meat balls and 2 cake pops.

MCP

npx @modelcontextprotocol/inspector
http://localhost:5001/mcp/sse
http://localhost:5001/.well-known/oauth-protected-resource

A2A

$Env:GEMINI_API_KEY = '<key>'; agentgateway -f .\agentgateway\config.yaml
http://localhost:5000/.well-known/agent.json

MAF - Workflow

flowchart TD
  ValidatorExecutor["ValidatorExecutor (Start)"];
  SplitExecutor["SplitExecutor"];
  HandleUncertainExecutor["HandleUncertainExecutor"];
  BaristaExecuter["BaristaExecuter"];
  KitchenExecuter["KitchenExecuter"];
  AggregationExecutor["AggregationExecutor"];

  fan_in::AggregationExecutor::76F793D9((fan-in))
  BaristaExecuter --> fan_in::AggregationExecutor::76F793D9;
  KitchenExecuter --> fan_in::AggregationExecutor::76F793D9;
  fan_in::AggregationExecutor::76F793D9 --> AggregationExecutor;
  ValidatorExecutor --> SplitExecutor;
  ValidatorExecutor --> HandleUncertainExecutor;
  SplitExecutor --> BaristaExecuter;
  SplitExecutor --> KitchenExecuter;

References

  • https://github.com/thangchung/practical-dotnet-aspire
  • https://github.com/thangchung/mcp-labs/blob/feat/a2a_mcp_auth/a2a_mcp_auth_dotnet
  • https://devblogs.microsoft.com/foundry/building-ai-agents-a2a-dotnet-sdk/
  • https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp/
  • https://devblogs.microsoft.com/dotnet/announcing-dotnet-ai-template-preview1/