How coding-crashkurse/a2a-langgraph works
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