This repository contains the necessary steps to implement and deploy a Looker agent using the ADK (Agent Development Kit) and MCP (Model Context Protocol) Toolbox.
First, you need to set up the MCP Toolbox server.
-
Navigate to the
mcp-toolboxdirectory and replace the contents in the .env file with your variables:BASE_URL=your_looker_instance_url LOOKER_CLIENT_ID=your_client_id LOOKER_CLIENT_SECRET=your_client_secret
-
Load your variables from the .env file into your terminal session as environment variables.:
export $(grep -v '^#' .env | xargs)
-
Start the server:
./toolbox --tools-file "tools.yaml" -
To test it locally with an interactive UI:
./toolbox --ui
Next, create the agent and connect it to your tools.
-
Navigate to the
my-agentsdirectory, set up a virtual environment, and activate it:cd my-agents python -m venv .venv source .venv/bin/activate
-
Replace the contents in the .env file with your variables:
GOOGLE_GENAI_USE_VERTEXAI=1 GOOGLE_CLOUD_PROJECT=your_google_cloud_project_id GOOGLE_CLOUD_LOCATION=us-central1 LOOKER_CLIENT_ID=your_looker_client_id LOOKER_CLIENT_SECRET=your_looker_client_secret LOOKER_BASE_URL=your_looker_instance_url
-
Install the ADK and MCP Toolbox packages:
pip install google-adk toolbox-core
-
Test your agent locally. This command will return a URL for testing.
adk web
Note: The MCP server must be running for the agent to access the tools.
Finally, deploy the MCP Toolbox and the agent to Cloud Run.
-
Navigate to your
mcp-toolboxdirectory, define yourPROJECT_ID, and enable the necessary services:export PROJECT_ID="YOUR_GOOGLE_CLOUD_PROJECT_ID" gcloud services enable run.googleapis.com \ cloudbuild.googleapis.com \ artifactregistry.googleapis.com \ secretmanager.googleapis.com
-
Create a service account:
gcloud iam service-accounts create toolbox-identity gcloud projects add-iam-policy-binding $PROJECT_ID \ --member="serviceAccount:toolbox-identity@$PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/secretmanager.secretAccessor" gcloud projects add-iam-policy-binding $PROJECT_ID \ --member="serviceAccount:toolbox-identity@$PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/cloudsql.client"
-
Upload the
tools.yamlfile as a secret and set the image variable:gcloud secrets create tools --data-file tools.yaml \ --replication-policy="user-managed" --locations="us-central1" export IMAGE=us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:latest
-
Deploy to Cloud Run:
gcloud run deploy toolbox \ --image $IMAGE \ --service-account toolbox-identity \ --region us-central1 \ --set-secrets "/app/tools.yaml=tools:latest" \ --args="--tools_file=/app/tools.yaml","--address=0.0.0.0","--port=8080" \ --allow-unauthenticated
-
In your
my-agents/looker-agent/agent.pyfile, update theToolboxSyncClientURL to your new Cloud Run service URL. -
Navigate to the
my-agentsdirectory and define the following variables:export GOOGLE_CLOUD_PROJECT="YOUR PROJECT ID" export GOOGLE_CLOUD_LOCATION="YOUR REGION" export AGENT_PATH="looker-agent/" export SERVICE_NAME="looker-service" export APP_NAME="looker-app" export GOOGLE_GENAI_USE_VERTEXAI=True
-
Deploy the agent application to Cloud Run:
adk deploy cloud_run \ --project=$GOOGLE_CLOUD_PROJECT \ --region=$GOOGLE_CLOUD_LOCATION \ --service_name=$SERVICE_NAME \ --app_name=$APP_NAME \ --with_ui \ $AGENT_PATH
Mission Accomplished! 🚀 You have successfully created and deployed your agent. You can now use it anytime from the Cloud Run URL provided by the final deployment command.