GML016

Overview
Large language models (LLMs) are powerful, but they have two major limitations: their knowledge is frozen at the time of their training, and they can't interact with the outside world to access real-time data or perform actions like booking a meeting or updating a customer record.
This is where the Model Context Protocol (MCP) comes to the rescue! MCP is an open standard designed to solve the limitations of LLMs.
Why use MCP?
MCP provides a secure and standardized "language" for LLMs to communicate with external data, applications, and services. It acts as a bridge, allowing AI Agents to move beyond static knowledge and become dynamic—with MCP they can retrieve current information and take action, making them more accurate, useful, and automated.
This lab provides step-by-step instructions for installing the Agent Development Kit (ADK), modifying an existing ADK agent to use MCP, and deploying the updated Agent to initialize an interactive session via the command-line interface.
Objectives
In this lab, you learn how to perform the following tasks:
- Install the Agent Development Kit (ADK) and create a virtual environment for your project.
- Test the currency-agent system (the "before" state).
- Modify the Agent to use an MCP server.
- Restart the MCP server and the Agent for the changes to take effect.
- Verify the changes made to the MCP server (the "after").
Setup and requirements
- Labs are timed and cannot be paused. The timer starts when you click Start Lab.
- The included cloud terminal is preconfigured with the gcloud SDK.
- Use the terminal to execute commands and then click Check my progress to verify your work.
Configure the environment and install the relevant dependencies
-
Run the following command in the terminal to copy code files from a Cloud Storage bucket for this lab:
gcloud storage cp -r gs://{{{project_0.project_id| YOUR_GCP_PROJECT_ID}}}-bucket/currency-agent .
-
Set up the environment and create the .env file in the currency-agent directory using the following commands:
cd currency-agent
cp /home/student/keys.json .
uv venv --python 3.12
source .venv/bin/activate
uv sync
touch .env
echo "GOOGLE_CLOUD_PROJECT={{{ project_0.project_id }}}" >> .env
echo "GOOGLE_CLOUD_LOCATION=global" >> .env
echo "GOOGLE_GENAI_USE_VERTEXAI=True" >> .env
echo "MODEL={{{project_0.startup_script.gemini_flash_model_id | gemini_flash_model_id}}}" >> .env
Task 1. Install the Agent Development Kit (ADK)
-
In a new terminal (select Terminal > New Terminal in the menu bar or press CTRL+SHIFT+'), start the MCP Server using the following commands:
cd currency-agent
uv run mcp-server/server.py
-
In a new terminal (select Terminal > New Terminal in the menu bar or press CTRL+SHIFT+'), start the A2A Server (it starts on port 10000) using the following commands:
cd currency-agent
uv run uvicorn currency_agent.agent:a2a_app --host localhost --port 10000
Task 2. Run the baseline Agent (the "before")
-
In your initial terminal instance, launch the existing Currency Agent using the following commands:
adk run currency_agent
Note: If you encounter a timeout error (e.g., asyncio.exceptions.CancelledError) when starting the agent, verify that both the MCP Server (Task 1, step 1) and A2A Server (Task 1, step 2) are running without errors in their respective terminal tabs.
-
Wait for the [user]: prompt to appear in the terminal, then interact with the agent by entering the following:
What's the exchange rate between USD and EUR?
The agent should give you the real time exchange rate between the US Dollar and Euro.
-
Try another prompt:
What's the exchange rate between USD and CNY?
The agent should give you the real time exchange rate between the US Dollar and Chinese Yuan.
-
Interact with the agent by prompting it as follows:
What's the price of Bitcoin?
From the response, you should be able to tell that the Agent only knows about flat currencies (i.e. it can't give you any current data about crypto).
Task 3. Modify the Agent
In this task, you modify your Currency Agent to be able to use the Model Context Protocol (MCP) server. Think of it as a way to call a separate "Currency Server" (via the publicly available Coinbase API) to get rates that the Agent doesn't otherwise have access to.
-
Click on the File Explorer icon in the left pane and navigate to your currency-agent/mcp-server project folder.
-
In the File Explorer, within the mcp-server directory, open the server.py file, insert the following code at line 53, and save your changes:
@mcp.tool()
def get_crypto_price(currency_pair: str = "BTC-USD") -> dict:
"""Get the current price of a cryptocurrency pair."""
# No API key required for this public endpoint
url = f"https://api.coinbase.com/v2/prices/{currency_pair}/spot"
response = httpx.get(url)
return response.json()["data"]
Task 4. Restart the MCP and A2A servers
-
Switch to the terminal instance where the MCP server is still running.
-
Press CTRL+C to stop the server.
-
Still in the same terminal, run the following command to restart the MCP Server:
uv run mcp-server/server.py
-
Switch to the terminal instance where the A2A server is still running.
-
Press CTRL+C to stop the server.
-
Still in this terminal, run the following command to restart the Agent:
uv run uvicorn currency_agent.agent:a2a_app --host localhost --port 10000
Task 5. Run and test your updated Agent (the "after")
-
Switch to the terminal instance where the currency_agent had previously been running.
-
Enter exit to end the original session.
-
Execute the following command to re-run and test your Agent:
adk run --save_session currency_agent
Note: You can ignore any warnings related to Python version dependencies.
-
Try issuing the following prompt to interact with the Agent:
Use the get_crypto_price tool to get me the current price of Bitcoin.
The Agent now has access to the get_crypto_price tool (via MCP), which enables it to answer questions about more than just flat currencies!
- Enter exit and input 1 when prompted for a session ID.
Click Check my progress to verify the objective.
Modify an ADK Agent to use MCP.
Congratulations!
You've successfully deploying an ADK agent and modified it to use the Model Context Protocol (MCP) server.
Manual Last Updated April 9, 2026
Lab Last Tested April 9, 2026
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.