A currency conversion AI agent demonstrating A2A + ADK + MCP working together, powered by the Exchange-RateAPI exchange rate API.
It uses the Agent2Agent (A2A) Python SDK (a2a-sdk), Google's Agent Development Kit (google-adk), and a FastMCP server that exposes live, historical, and reference exchange rate data from Exchange-RateAPI.
- MCP Server β exposes five tools backed by exchange-rateapi.com, with built-in response caching, timeouts, and retry with backoff:
Tool Description get_exchange_rateLive exchange rate between two currencies, with optional amount conversion compare_ratesOne base currency vs. several targets in a single API call get_rate_for_dateExchange rate on a specific historical date (YYYY-MM-DD) get_rate_changeTrend over the last N days β start/end rate, change %, direction up/down list_currenciesAll supported currency codes with full names - ADK Agent β orchestrates the conversation and invokes the MCP tools when needed.
- A2A Server/Client β advertises the agent over the Agent2Agent protocol so other agents can call it.
- Multi-agent demo β a second
travel_budget_agentthat delegates currency questions to the currency agent over A2A (see below).
- Python 3.10+
- A free Exchange-RateAPI key β register at exchange-rateapi.com/register
- A Google AI Studio API key (for the default Gemini model β see Using other models for alternatives)
- Clone the repository:
git clone https://github.com/Exchange-RateAPI/currency-agent.git
cd currency-agent- Install uv (used to manage dependencies):
curl -LsSf https://astral.sh/uv/install.sh | sh- Configure environment variables:
cp .env.example .env
# then edit .env and set EXCHANGE_RATE_API_KEY and GOOGLE_API_KEYTerminal 1 β MCP server:
export $(grep -v '^#' .env | xargs) # or rely on your shell env
uv run mcp-server/server.pyTerminal 2 β A2A server (ADK agent):
uv run uvicorn currency_agent.agent:a2a_app --host localhost --port 10000Terminal 3 β A2A client:
uv run currency_agent/test_client.pyEXCHANGE_RATE_API_KEY=era_live_... GOOGLE_API_KEY=... docker compose up --build
# then, in another terminal:
uv run currency_agent/test_client.py- "How much is 500 USD in LKR?"
- "Compare USD against EUR, GBP and JPY."
- "What was the USD/EUR rate on 2026-01-15?"
- "Is the euro up or down against the dollar this week?"
- "Which currencies do you support?"
travel_agent/ contains a second agent β a travel budget planner β that has no
exchange-rate tools of its own. Whenever it needs a rate, it calls the currency agent
over the A2A protocol, which is the actual point of A2A: agents consuming other
agents as peers, not as bundled tools.
With Terminals 1 and 2 from above still running:
# Terminal 3 β travel agent (A2A server on port 10001)
uv run uvicorn travel_agent.agent:a2a_app --host localhost --port 10001
# Terminal 4 β ask it something
uv run travel_agent/test_client.py
# "I have 2000 USD for a 5-day trip to Japan. What is my total and daily budget in JPY?"| Env var | Default | Description |
|---|---|---|
EXCHANGE_RATE_API_KEY |
β (required) | Your Exchange-RateAPI key |
GOOGLE_API_KEY |
β | Google AI Studio key (required for Gemini models) |
MODEL |
gemini-2.5-flash |
Agent model β see below |
MCP_SERVER_URL |
http://localhost:8080/mcp |
Where the agent finds the MCP server |
CURRENCY_AGENT_URL |
http://localhost:10000 |
Where the travel agent finds the currency agent |
EXCHANGE_RATE_API_BASE_URL |
https://exchange-rateapi.com |
API base URL override |
PORT |
8080 |
MCP server port |
Non-Gemini models are routed through LiteLLM:
uv pip install litellm # or: pip install 'exchange-rateapi-currency-agent[litellm]'
export MODEL=anthropic/claude-sonnet-4-6 ANTHROPIC_API_KEY=sk-ant-...
# or: export MODEL=openai/gpt-4o OPENAI_API_KEY=sk-...uv pip install fastmcp==2.11.3 httpx pytest ruff
pytest # unit tests (httpx mocked β no API key needed)
ruff check . # lint
uv run mcp-server/test_server.py # integration test against a running MCP serverCI runs lint + tests on every push (see badge above).
If you just want exchange rate tools in your MCP client (without ADK/A2A), use the production Exchange-RateAPI MCP server:
{
"mcpServers": {
"exchange-rateapi": {
"command": "npx",
"args": ["-y", "@exchangerateapi/mcp-server"],
"env": { "EXCHANGE_RATE_API_KEY": "era_live_..." }
}
}
}Exchange-RateAPI is a fast, developer-friendly exchange rate API with live and historical rates, a generous free tier, and official SDKs for JavaScript, Python, PHP, and Rust, plus an MCP server.
Based on the excellent jackwotherspoon/currency-agent sample (Apache 2.0), adapted to use Exchange-RateAPI.
