1. Ringkasan
Dalam codelab ini, Anda akan membangun Agen AI interaktif menggunakan Agent Development Kit (ADK) Google dan MCP Toolbox untuk database guna berinteraksi dengan instance Looker Anda.

Apa itu ADK dan MCP?
- Google ADK (Agent Development Kit): Framework ringan untuk membuat, menguji, dan mengorkestrasi agen LLM multi-alat yang didukung oleh Gemini.
- Model Context Protocol (MCP): Standar terbuka yang memungkinkan LLM terhubung secara aman ke alat, database, dan API eksternal tanpa kode adaptor kustom.
Yang akan Anda buat
- Agen lokal berbasis Python yang didukung oleh Gemini 3.8 Flash.
- Integrasi MCP toolbox untuk terhubung ke Looker.
- Agen yang berjalan dan diuji melalui UI web lokal ADK interaktif.
Prasyarat
- Instance Looker dengan izin admin atau developer untuk membuat kredensial API.
- Python 3.10+ terinstal.
- Go 1.21+ telah diinstal (untuk mem-build/menginstal biner
toolbox). - Kunci Google Gemini API atau project Google Cloud dengan Vertex AI yang diaktifkan.
2. Mengamankan Kredensial Looker API
Agar server MCP dapat melakukan autentikasi dengan instance Looker Anda, Anda harus mendapatkan kredensial API 3.
- Login ke instance Looker Anda.
- Buka Admin > Users (atau Account Settings jika pembuatan kredensial mandiri diaktifkan).
- Temukan akun pengguna Anda, lalu pilih Edit.
- Di bagian Kunci API 3, klik Kunci API Baru.
- Simpan Client ID dan Client Secret yang dihasilkan.
[WARNING] Jaga keamanan Rahasia Klien Anda. Jangan pernah commit file .env Anda ke kontrol versi.
3. Menyiapkan Lingkungan Pengembangan & Menginstal MCP Toolbox
Buat direktori project, siapkan lingkungan virtual Python, dan instal biner MCP Toolbox yang diperlukan menggunakan Go.
Membuat direktori project dan lingkungan virtual
mkdir looker-mcp-agent && cd looker-mcp-agent
python3 -m venv .venv
source .venv/bin/activate
Menginstal dependensi Python
Instal Google ADK, SDK klien MCP, dan pengelola lingkungan Python:
pip install google-adk mcp python-dotenv
Menginstal Biner MCP Toolbox menggunakan Go
Koneksi MCP mengandalkan biner MCP toolbox (toolbox). Anda dapat menginstalnya langsung menggunakan go install:
# Install the MCP toolbox binary from source
go install github.com/googleapis/genai-toolbox/cmd/toolbox@latest
Pastikan biner telah diinstal ke direktori $(go env GOPATH)/bin Anda:
# Check if MCP toolbox is in your Go bin
ls $(go env GOPATH)/bin/toolbox
Agar skrip Anda mudah mereferensikan, pastikan $(go env GOPATH)/bin ada di $PATH, atau salin/buat symlink biner ke direktori project Anda:
# Symlink or copy the MCP toolbox into your current project directory
cp $(go env GOPATH)/bin/toolbox ./toolbox
chmod +x ./toolbox
4. Mengonfigurasi Variabel Lingkungan
Buat file .env di root looker-mcp-agent/:
LOOKER_BASE_URL="https://your-looker-instance.com"
LOOKER_CLIENT_ID="your_client_id"
LOOKER_CLIENT_SECRET="your_client_secret"
GEMINI_API_KEY="your_gemini_api_key"
Pastikan .env tercantum dalam file .gitignore Anda.
Catatan: Anda juga dapat terhubung ke Looker melalui Oauth
5. Menentukan Alat di tools.yaml
Apa itu tools.yaml?
tools.yaml adalah manifes konfigurasi deklaratif untuk MCP Toolbox (toolbox). Alih-alih menulis boilerplate kustom atau pengendali HTTP manual untuk berinteraksi dengan Looker API, MCP Toolbox menggunakan tools.yaml untuk mengekspos kemampuan Looker secara dinamis sebagai alat Model Context Protocol (MCP) standar untuk agen LLM Anda.
Hal ini memiliki dua tujuan utama:
- Mengonfigurasi koneksi ke instance Looker Anda (URL endpoint, kredensial autentikasi, project, lokasi, dan waktu tunggu).
- Menentukan kemampuan Looker (misalnya, mencantumkan koneksi, membuat dasbor, menjalankan kueri) yang akan diekspos oleh server MCP ke Gemini, lengkap dengan deskripsi bahasa alami yang digunakan Gemini untuk pemilihan alat dan pembuatan argumen.
Lokasi File: Menempatkan tools.yaml di Root Project
File tools.yaml harus berada di direktori utama project (direktori induk basic_looker_agent/), bukan di dalam subdirektori basic_looker_agent/.
Berikut struktur direktori project yang diharapkan:
looker-mcp-agent/ <-- Project root directory
├── tools.yaml <-- Place tools.yaml here!
├── toolbox <-- MCP Toolbox binary executable
└── basic_looker_agent/ <-- Agent package directory created by ADK
├── .env <-- Local environment variables (keys & credentials)
├── __init__.py
└── agent.py <-- Agent code (references ../tools.yaml)
Mengapa di root project? Di agent.py, agen menyelesaikan konfigurasi server MCP melalui ../tools.yaml (satu direktori di atas basic_looker_agent/). Menjaga tools.yaml di root project akan memisahkan definisi alat MCP dan sumber data Anda dari kode agen Python dengan rapi. Jika Anda menempatkan tools.yaml di dalam basic_looker_agent/, agen tidak akan dapat menemukannya.
sources:
my-looker-source:
kind: looker
base_url: https://your-looker-instance.com
client_id: $LOOKER_CLIENT_ID
client_secret: $LOOKER_CLIENT_SECRET
project: your-looker-project
location: us-east1
verify_ssl: true
timeout: 600s
tools:
get_connections:
kind: looker-get-connections
source: my-looker-source
description: |
This tool retrieves a list of all database connections configured in the Looker system.
Parameters:
This tool takes no parameters.
Output:
A JSON array of objects, each representing a database connection.
create_dashboard:
kind: looker-make-dashboard
source: my-looker-source
description: |
This tool creates a dashboard from a prompt.
Catatan: Placeholder $LOOKER_CLIENT_ID dan $LOOKER_CLIENT_SECRET akan otomatis di-resolve dari lingkungan yang diteruskan ke proses server MCP.
6. Mengimplementasikan Agen
Buat file bernama agent.py. Skrip ini menghubungkan proses server MCP ke LlmAgent ADK.
import os
from dotenv import load_dotenv
from mcp import StdioServerParameters
from google.adk.agents import LlmAgent
from google.adk.tools import MCPToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
# Load environment variables
load_dotenv()
# Configure MCP Stdio server parameters
base_dir = os.path.dirname(os.path.abspath(__file__))
# Reference the toolbox binary in your project root or from GOPATH
toolbox_path = os.path.abspath(os.path.join(base_dir, "toolbox"))
tools_path = os.path.abspath(os.path.join(base_dir, "tools.yaml"))
looker_server = StdioServerParameters(
command=toolbox_path,
args=["--stdio", "--tools-file", tools_path],
env={
"LOOKER_BASE_URL": os.getenv("LOOKER_BASE_URL"),
"LOOKER_CLIENT_ID": os.getenv("LOOKER_CLIENT_ID"),
"LOOKER_CLIENT_SECRET": os.getenv("LOOKER_CLIENT_SECRET"),
},
)
# Create the ADK MCP Toolset
looker_toolset = MCPToolset(
connection_params=StdioConnectionParams(server_params=looker_server)
)
# Define the root LLM Agent
root_agent = LlmAgent(
model="gemini-3.8-flash",
name="looker_pro",
description="A helpful assistant that queries Looker and uses mcp-toolbox-for-databases.",
instruction="You are a helpful assistant that retrieves Looker connection information and assists users with available Looker tools.",
tools=[looker_toolset],
)
7. Menjalankan dan Menguji Agen
ADK menyertakan antarmuka web pengembangan bawaan.
Meluncurkan Server Web ADK
Jalankan perintah berikut dari direktori project Anda:
adk web
``` This will spin up a lightweight locally hosted server to
review your agent.
### Interact with Your Agent
1. Open the URL printed in the terminal (typically `http://localhost:8080` or
`http://127.0.0.1:8000`).
2. Test tool discovery by prompting the agent:
Alat apa saja yang Anda miliki?
inspect its toolset and report the `get_connections` and the
`create_dashboard` tool.
3. Test tool execution:
Dapatkah Anda menunjukkan koneksi database di Looker?
" class="language->"> Response: The agent will invoke `get_connections` over MCP and list your
instance's active database connections.
---
## Congratulations & Next Steps
Duration: 1:00
You have built an AI agent using Google ADK connected to Looker via the Model
Context Protocol (MCP).
### What you learned:
* How to install and configure `toolbox` using `go install`.
* How to configure Looker API credentials for external integrations.
* How to define MCP sources and tools in `tools.yaml`.
* How to link an MCP toolset to an ADK `LlmAgent`.
* How to test tool invocation in the ADK web interface.
### Next Steps:
* Create a dashboard with the agent defined in the codelab.
* Add more [Looker tools](https://mcp-toolbox.dev/integrations/looker/source/)
to `tools.yaml` (such as `looker-query`, `looker-run-look`).
* Check out [Google ADK Documentation](https://github.com/google/adk) for
multi-agent routing and state persistence.