# coding-crashkurse/a2a-langgraph architecture

> Architecture diagram of the GitHub repository coding-crashkurse/a2a-langgraph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/coding-crashkurse/a2a-langgraph
- Repository: https://github.com/coding-crashkurse/a2a-langgraph

## Overview

##### Project type and purpose
- This is a Python-based multi-agent communication demo. It showcases two agents (Agent A and Agent B) interacting via the Agent-to-Agent (A2A) protocol, and Agent B invoking remote “tools” exposed by a Model-Context-Protocol (MCP) server.

##### File structure
- Flat layout: no “frontend” or “backend” directories.
- Key scripts:
- mcp_app.py – the MCP server exposing tool endpoints
- agentpartner.py – Agent B, which registers with and calls the MCP server
- host_agent.py – Agent A, which initiates A2A calls to Agent B
- Other Python modules ( abc_task_manager.py, card_resolver.py, push_notification_auth.py, etc.) implement individual tool functions imported by mcp_app.py.
- Utilities: in_memory_cache.py, client.py, utils.py, custom_types.py support HTTP calls, caching, type definitions.

##### README
- Confirms the three main components and the expected run sequence.
- Describes that Agent A → Agent B uses A2A; Agent B → MCP server uses MCP protocol to invoke tools.

a. Main components
1. Host Agent (Agent A) – host_agent.py
2. Partner Agent (Agent B) – agentpartner.py
3. MCP Server – mcp_app.py
4. Tool Modules – individual Python files loaded by the MCP server
5. Shared utilities – e.g., in_memory_cache, client for HTTP interactions
b. Relationships and data flows
1. Agent A sends an A2A request (over HTTP or WebSocket) to Agent B.
2. Agent B receives the request, processes it, and issues MCP calls (HTTP REST) to the MCP server endpoints.
3. The MCP server routes each call to the appropriate tool module (e.g., abc_task_manager, card_resolver, push_notification_auth).
4. Tool modules execute logic (possibly using in_memory_cache) and return results back through the MCP server to Agent B.
5. Agent B aggregates or transforms the response and replies to Agent A.
c. Architectural patterns / design principles
- Microservice-style separation: each agent and the MCP server are standalone processes.
- Plugin architecture for tools: mcp_app dynamically loads tool functions from separate modules.
- Clear protocol layering: A2A layer (Agent A ↔ Agent B) and MCP layer (Agent B ↔ MCP server).
d. Technologies / frameworks
- Python 3.x
- HTTP framework (e.g., FastAPI or Flask in mcp_app.py)
- requests or httpx (client.py) for making HTTP calls
- in_memory_cache for fast local caching of MCP responses

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Agents"
        A["Agent A<br/>(host_agent.py)"]:::agent
        B["Agent B<br/>(agentpartner.py)"]:::agent
    end

    subgraph "MCP Server"
        M["MCP Server<br/>(mcp_app.py)"]:::mcp
    end

    subgraph "Tool Modules"
        T1["ABC Task Manager<br/>(abc_task_manager.py)"]:::tool
        T2["Card Resolver<br/>(card_resolver.py)"]:::tool
        T3["Push Notification Auth<br/>(push_notification_auth.py)"]:::tool
        T4["General Task Manager<br/>(task_manager.py)"]:::tool
    end

    subgraph "Shared Utilities"
        U1["HTTP Client<br/>(client.py)"]:::util
        U2["In-Memory Cache<br/>(in_memory_cache.py)"]:::util
        U3["Common Types<br/>(custom_types.py)"]:::util
        U4["Misc Helpers<br/>(utils.py)"]:::util
    end

    A -->|A2A request| B
    B -->|MCP API call| M

    M -->|routes to tools| T1
    M -->|routes to tools| T2
    M -->|routes to tools| T3
    M -->|routes to tools| T4

    T1 -->|result| M
    T2 -->|result| M
    T3 -->|result| M
    T4 -->|result| M

    M -->|MCP response| B
    B -->|A2A response| A

    B -->|uses HTTP client| U1
    M -->|uses cache| U2
    B -->|uses misc helpers| U4
    M -->|uses common types| U3

    click A "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/host_agent.py"
    click B "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/agentpartner.py"
    click M "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/mcp_app.py"
    click T1 "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/abc_task_manager.py"
    click T2 "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/card_resolver.py"
    click T3 "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/push_notification_auth.py"
    click T4 "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/task_manager.py"
    click U1 "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/client.py"
    click U2 "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/in_memory_cache.py"
    click U3 "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/custom_types.py"
    click U4 "https://github.com/coding-crashkurse/a2a-langgraph/blob/main/utils.py"

    classDef agent fill:#cce5ff,stroke:#004085,color:#004085
    classDef mcp fill:#d4edda,stroke:#155724,color:#155724
    classDef tool fill:#fff3cd,stroke:#856404,color:#856404
    classDef util fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
