A2A-MCP-ADK-Integration

mcp
Security Audit
Warn
Health Warn
  • No license — Repository has no license file
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 9 GitHub stars
Code Pass
  • Code scan — Scanned 7 files during light audit, no dangerous patterns found
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

Convert a Google ADK agent with Firecrawl MCP tools into an A2A service, plus an orchestrator that discovers and calls it

README.md

A2A × MCP × ADK Integration

Turn a Google ADK agent that uses MCP tools into an A2A-compatible service that other agents can discover and call.

Python
Google ADK
A2A SDK
MCP
Gemini
Starlette

[!NOTE]
Companion code for the Google Cloud Blog post Unlock AI agent collaboration: Convert ADK agents for A2A.


📖 Overview

Agents built with the Agent Development Kit (ADK) usually live inside a single process. The
Agent2Agent (A2A) protocol lets independent agents advertise their skills and talk to each other over HTTP.
This repo bridges the two:

  1. Search agent (MultiURLBrowser) – an ADK LlmAgent powered by Gemini that scrapes web pages through the
    Firecrawl MCP server (Model Context Protocol), wrapped in an A2A server with an Agent Card.
  2. Orchestrator agent (root_orchestrator) – a second ADK agent that has no scraping ability of its own. It
    discovers remote agents via their A2A Agent Card and delegates tasks to them with two function tools,
    list_agents() and call_agent().
  3. Test client – a minimal A2A client that fetches the Agent Card and sends a scrape request directly.

A step-by-step explanation of the conversion pattern is in ADK_TO_A2A_CONVERSION_GUIDE.md.


🏗️ Architecture

Target architecture on Google Cloud

Target architecture on Google Cloud. Run locally today (adk web + Uvicorn on localhost:10000); this is the production target.

  • Cloud Run (two services): root_orchestrator and the MultiURLBrowser A2A server each run as their own container. The search agent serves its Agent Card at /.well-known/agent.json, and the Firecrawl MCP server runs inside the same container as a stdio subprocess (npx firecrawl-mcp).
  • Vertex AI (Gemini): both ADK agents call Gemini for reasoning. Locally this uses GOOGLE_API_KEY. On Cloud Run, set GOOGLE_GENAI_USE_VERTEXAI=true and authenticate with the service account instead.
  • Identity-Aware Proxy + service accounts: IAP authenticates people calling the orchestrator. The orchestrator calls the search agent with a Google-signed ID token (Cloud Run IAM roles/run.invoker), and each service has its own least-privilege service account.
  • Secret Manager: holds FIRECRAWL_API_KEY and mounts it into the search-agent service as an environment variable.
  • Cloud Build + Artifact Registry: build the container images and deploy them to Cloud Run.
  • Cloud Logging / Monitoring: collect agent and A2A task logs, latency, and error metrics.

Diagram source: docs/architecture/gcp_architecture.py (rendered with the diagrams library).

Request flow

sequenceDiagram
    actor U as User
    participant O as root_orchestrator (ADK)
    participant S as Search Agent A2A Server
    participant E as AgentTaskManager
    participant B as MultiURLBrowser (ADK + Gemini)
    participant F as Firecrawl MCP

    U->>O: "Scrape https://... and summarise"
    O->>S: list_agents() → GET Agent Card
    S-->>O: AgentCard (name, skills, url)
    O->>S: call_agent("MultiURLBrowser", msg) → message/send
    S->>E: execute(RequestContext, EventQueue)
    E->>B: invoke(query, session_id)
    B->>F: MCP tool call (scrape)
    F-->>B: page content
    B-->>E: progress updates + final result
    E-->>S: TaskState.working → TaskState.completed
    S-->>O: Task result (text part)
    O-->>U: Final answer

🧭 What I built — step by step

  1. Built an MCP-powered ADK agent. agents/search_agent/agent.py defines MultiURLBrowser, an ADK LlmAgent on Gemini whose tools come from MCPToolset. The toolset launches the Firecrawl MCP server over stdio and passes it FIRECRAWL_API_KEY.
  2. Wrapped the agent for A2A. The class owns an ADK Runner with in-memory session, memory, and artifact services, plus an async invoke() generator that streams progress and returns the final answer.
  3. Bridged it to the A2A task model. task_manager.py adds AgentTaskManager, an A2A AgentExecutor that turns ADK events into TaskUpdater states (working → completed / failed).
  4. Published an Agent Card and server. __main__.py declares an AgentSkill and an AgentCard, then serves them with A2AStarletteApplication + DefaultRequestHandler + InMemoryTaskStore on Uvicorn.
  5. Wrote a direct A2A client. client.py resolves the card with A2ACardResolver and sends a message/send request with A2AClient.
  6. Built an orchestrator that delegates over A2A. scrap_translate/agent.py gives a second ADK agent two FunctionTools, list_agents() and call_agent(), so it can find and call remote agents from adk web.
  7. Documented the pattern. I wrote it up in ADK_TO_A2A_CONVERSION_GUIDE.md and the companion Google Cloud Blog post.

✨ Key Features

  • ADK → A2A conversion pattern – wrap an existing ADK LlmAgent in a class exposing an async invoke() generator, then plug it into the A2A server through an AgentExecutor.
  • MCP tool integration – the search agent uses ADK's MCPToolset to launch the Firecrawl MCP server over stdio (npx -y firecrawl-mcp).
  • Agent Card & skills – the server publishes an AgentCard with an AgentSkill (MultiURLBrowser), streaming capability, and example prompts for discovery.
  • Task lifecycle – AgentTaskManager reports working → completed / failed states through TaskUpdater.
  • Agent-to-agent orchestration – an ADK orchestrator discovers and calls remote A2A agents as tools, runnable from adk web.
  • Configurable – model name and agent registry URL come from environment variables.

🧰 Tech Stack

Layer Technology
Agent framework Google ADK (google-adk)
LLM Gemini via google-genai (default gemini-2.5-pro-preview-03-25)
Agent interoperability A2A Python SDK (a2a-sdk)
Tools Model Context Protocol (mcp) + Firecrawl MCP server (Node.js / npx)
Server Starlette + Uvicorn, CLI via click
HTTP client httpx
Config python-dotenv

📁 Repository Structure

.
├── agents/
│   └── search_agent/
│       ├── __main__.py        # A2A server: AgentCard, AgentSkill, Starlette app, Uvicorn
│       ├── agent.py           # MultiURLBrowser: ADK LlmAgent + Firecrawl MCPToolset
│       ├── task_manager.py    # AgentTaskManager: A2A AgentExecutor bridging to the ADK agent
│       └── client.py          # Standalone A2A client that sends a scrape request
├── scrap_translate/
│   ├── __init__.py
│   └── agent.py               # root_orchestrator: discovers/calls A2A agents (loaded by `adk web`)
├── docs/architecture/          # GCP diagram (PNG) and its `diagrams` source
├── ADK_TO_A2A_CONVERSION_GUIDE.md   # Walkthrough of the conversion pattern
├── env.example                # Environment variable template
└── requirements.txt           # Pinned Python dependencies

🚀 Getting Started

Prerequisites

Setup

git clone https://github.com/Ashwinikumar1/A2A-MCP-ADK-Integration.git
cd A2A-MCP-ADK-Integration

python3 -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate

pip install -r requirements.txt
cp env.example .env              # then fill in your keys

Environment variables

Variable Required Default Purpose
GOOGLE_API_KEY ✅ – Gemini API access for both agents
FIRECRAWL_API_KEY ✅ – Passed to the Firecrawl MCP server
GOOGLE_MODEL_NAME gemini-2.5-pro-preview-03-25 Gemini model used by both agents
AGENT_REGISTRY_BASE_URL http://localhost:10000 Where the orchestrator looks for the A2A agent

[!WARNING]
Never commit your .env file. It is listed in .gitignore.


🎬 Usage

1. Start the search agent A2A server (from the repo root):

python3 -m agents.search_agent --host localhost --port 10000

2. Call it directly with the test client (new terminal):

python3 agents/search_agent/client.py

The client fetches the Agent Card, sends
"Scrape the title and first paragraph from this URL: https://medium.com/p/86a1735368e1", and prints the agent's reply.

3. Agent-to-agent via the ADK web UI (new terminal, from the repo root):

adk web

Select the scrap_translate agent and try prompts such as:

  • List the available agents.
  • Use the MultiURLBrowser agent to scrape https://example.com and summarise it.

The orchestrator calls list_agents() to read the search agent's Agent Card, then call_agent() to delegate the scrape over A2A.


🔐 Security

  • Secrets: API keys are read only from environment variables. env.example holds placeholders, and .env is git-ignored. In production, put FIRECRAWL_API_KEY in Secret Manager and use Vertex AI with a service account instead of GOOGLE_API_KEY.
  • IAM least privilege: give each Cloud Run service its own service account. The orchestrator needs roles/aiplatform.user and roles/run.invoker on the search agent. The search agent needs roles/aiplatform.user and roles/secretmanager.secretAccessor on its one secret.
  • Endpoint auth: as written, the A2A server is unauthenticated, which is fine for localhost only. On Cloud Run, deploy with --no-allow-unauthenticated, have the orchestrator send Google ID tokens, put IAP in front of user-facing entry points, and declare the auth scheme in the Agent Card.
  • Prompt injection and tool guardrails: scraped web content is untrusted input. Treat it as data, not instructions. Restrict the MCP toolset to the scrape tools you need (tool_filter), consider a URL allow-list, cap response size, and screen inputs and outputs with ADK callbacks or Model Armor.
  • Input validation: check the incoming A2A message (non-empty text, length limits, URL scheme http/https only) before invoking the agent, and return InvalidParamsError for bad requests.
  • PII and data handling: tasks, sessions, and memory are stored in memory and dropped on restart. Do not scrape or log personal data without a lawful basis, and redact prompts and responses before long-term log retention.
  • Audit logging: turn on Cloud Audit Logs for Vertex AI and Secret Manager access, and log A2A task IDs and caller identity to Cloud Logging.

🚀 Path to Production

  • Deploy target: containerise each agent and deploy to Cloud Run (the A2A server needs Node.js in the image for npx firecrawl-mcp). Alternatively, host the orchestrator on Vertex AI Agent Engine. Point AGENT_REGISTRY_BASE_URL at the search agent's Cloud Run URL.
  • State: replace InMemoryTaskStore and the in-memory ADK services with persistent stores (for example, a database-backed task store and VertexAiSessionService), so tasks survive restarts and work across multiple instances.
  • CI/CD: Cloud Build builds and tests the images, pushes them to Artifact Registry, and deploys to Cloud Run. Keep dependencies pinned (as in requirements.txt) and scan images.
  • Observability: use structured logs in Cloud Logging, OpenTelemetry traces in Cloud Trace (ADK supports tracing), and Cloud Monitoring alerts on error rate, latency, and failed tasks.
  • Evaluation: build an ADK eval set of scrape and summarise prompts, plus A2A contract tests for the Agent Card and task states, and run both in CI before every deploy.
  • Scaling and cost: set Cloud Run concurrency and max instances, add timeouts and retries on A2A and Firecrawl calls, and use a Flash model for routing when Pro is not needed. Track Gemini and Firecrawl usage with budgets and alerts.
  • Governance: register agents and Agent Cards in a central catalogue, version the skills, and review the tools each agent is allowed to use.

📚 Learn More


👤 Author

Ashwini Kumar — github.com/Ashwinikumar1

Reviews (0)

No results found