Challenge 9: Exposing Database Tools via MCP
Previous Challenge Next Challenge
| Target Persona: Platform Engineer / DBA | Estimated Duration: 30 minutes | Prerequisites: Challenges 2, 7, and 8 must be completed. |
Introduction
Now that all operational and analytical data resides locally in AlloyDB, you will expose these capabilities as tools using the MCP Toolbox for databases. This allows any downstream AI agent to securely and efficiently interact with the database.
Description
Task 9.1: Install MCP Toolbox
In your Cloud Shell terminal, download and make the toolbox executable:
export VERSION=1.1.0
curl -L -o toolbox https://storage.googleapis.com/mcp-toolbox-for-databases/v$VERSION/linux/amd64/toolbox
chmod +x toolbox
Task 9.2: Configure tools.yaml
Create a tools.yaml file outlining all the tools.
==========================================
SOURCES
==========================================
Source 1: Standard Postgres Connection (used for Tools 1-5)
kind: source
name: disney-db
type: alloydb-postgres
project: "[YOUR_PROJECT_ID]"
region: "europe-west1"
cluster: "[YOUR_CLUSTER]"
instance: "[YOUR_INSTANCE]"
ipType: "public"
database: "disney"
user: "postgres"
password: "buildwithgemini2026"
---
Source 2: Gemini Data Analytics API (used for QueryData)
kind: source
name: gda-api-source
type: cloud-gemini-data-analytics
projectId: "[YOUR_PROJECT_ID]"
==========================================
TOOLS
==========================================
---
Tool 1: Hybrid Search using ScaNN and Full-Text Search
kind: tool
name: search_attractions_hybrid
type: postgres-sql
source: disney-db
description: "Performs a high-performance hybrid (vector + keyword) search on park attractions based on user interests."
parameters:
- name: vector_query
type: string
description: "Semantic search term (e.g., 'thrilling space roller coaster')"
- name: text_query
type: string
description: "Keyword search term (e.g., 'Space Mountain')"
statement: |
-- TODO: Write the hybrid search query utilizing AlloyDB's ai.hybrid_search operator,
-- combining the vector cosine similarity index and the full-text search index.
-- (Hint: Pass the vector query embedded via google_ml.embedding)
---
Tool 2: Semantic Filtering using AlloyDB AI operator (google_ml.if)
kind: tool
name: check_ride_suitability
type: postgres-sql
source: disney-db
description: "Evaluates if a specific attraction is safe or suitable based on a guest's profile (e.g., 'pregnant women' or 'toddlers')."
parameters:
- name: attraction_name
type: string
description: "Name of the attraction"
- name: suitability_profile
type: string
description: "Profile of the guest (e.g., 'pregnant women', 'toddlers')"
statement: |
-- TODO: Call your check_attraction_suitability function with the appropriate parameters
---
Tool 3: Transactional Tool to record new reviews
kind: tool
name: add_attraction_review
type: postgres-sql
source: disney-db
description: "Saves a new customer review for an attraction into the operational database."
parameters:
- name: rating
type: integer
description: "Numerical rating out of 5"
- name: review_text
type: string
description: "Customer review text"
- name: branch
type: string
description: "The park branch location"
statement: |
-- TODO: Write an INSERT statement that records a new review into the disneyland_reviews table.
---
Tool 4: Analytical Tool checking Wait Time Forecasts (Local Table)
kind: tool
name: get_wait_time_forecast
type: postgres-sql
source: disney-db
description: "Queries the local database to get forecasted wait times for a specific attraction."
parameters:
- name: attraction_id
type: integer
description: "Unique ID of the attraction"
statement: |
-- TODO: Query the local table public.forecasted_waiting_times for the attraction's predicted wait time
---
Tool 5: Analytical Tool checking Graph Recommendations (Local Table)
kind: tool
name: get_next_ride_recommendation
type: postgres-sql
source: disney-db
description: "Gets next-ride routing recommendations for a guest leaving a specific attraction to avoid queues."
parameters:
- name: attraction_id
type: integer
description: "Unique ID of the attraction"
statement: |
-- TODO: Query the local table public.graph_recommendations to retrieve recommendations
---
Tool 6: QueryData Natural Language Search
kind: tool
name: query_disney_data
type: cloud-gemini-data-analytics-query
source: gda-api-source
description: "Use this tool to ask natural language questions about the Disneyland reviews, attractions, and wait times. It will translate your question into SQL, execute it, and return the answer."
location: "europe-west1"
context:
datasourceReferences:
alloydb:
databaseReference:
projectId: "[YOUR_PROJECT_ID]"
region: "europe-west1"
clusterId: "[YOUR_CLUSTER]"
instanceId: "[YOUR_INSTANCE]"
databaseId: "disney"
agentContextReference:
# Tip: You can find this ID in AlloyDB Studio by clicking on 'Edit Context'
# It should be in this format: projects/[YOUR_PROJECT_ID]/locations/[LOCATION]/contextSets/[CONTEXT_NAME]
contextSetId: "projects/[YOUR_PROJECT_ID]/locations/europe-west4/contextSets/disney-context"
generationOptions:
generateQueryResult: true
generateNaturalLanguageAnswer: true
generateExplanation: true
generateDisambiguationQuestion: true
---
==========================================
TOOLSET
==========================================
kind: toolset
name: disneyland_operational_tools
tools:
- search_attractions_hybrid
- check_ride_suitability
- add_attraction_review
- get_wait_time_forecast
- get_next_ride_recommendation
- query_disney_data
Task 9.3: Start and Validate the Server
Start the toolbox
./toolbox --config tools.yaml --ui
Open the visual web interface in Cloud Shell (default port is 5000), execute each of the tools, and verify that they are pulling/pushing data successfully.
Tip When using the Cloud Shell web preview, be sure to append
/uito the end of the URL in your browser to access the MCP toolbox interface.
Success Criteria
To validate this challenge, you must demonstrate the following:
- Show the MCP Toolbox UI with the six tools (
search_attractions_hybrid,check_ride_suitability,add_attraction_review,get_wait_time_forecast,get_next_ride_recommendation, andquery_disney_data) defined and tested successfully (all showing a green status).