Build and Deploy an AI Agent with Google ADK, Gemini and BigQuery MCP Server on Cloud Run

AI agents become far more useful when they can work with real data. In this step-by-step tutorial, we build an AI agent using Google's Agent Development Kit (ADK) and Gemini that can securely access and analyze structured data in BigQuery through the BigQuery MCP Server, and then deploy it to Google Cloud Run.

Watch the full walkthrough below, then use this post as a reference while you follow along.


📌 Introduction

Large Language Models are powerful, but on their own they can't see your business data. To build agents that answer real questions about sales, customers, or operations, they need a safe way to connect to data sources and tools.

This tutorial shows one way to do that: an ADK agent powered by Gemini uses the BigQuery MCP server to query structured data, and the whole application runs as a live service on Cloud Run. It is based on the Google Cloud codelab "Build and Deploy AI Agents with Gemini and BigQuery MCP server in Cloud Run."

🎯 What You'll Learn

  • Build an AI agent with the Agent Development Kit (ADK)
  • Use Gemini to power your AI agent
  • Connect an AI agent to BigQuery
  • Use the BigQuery MCP Server to query structured data
  • Understand how Model Context Protocol (MCP) connects AI agents with external tools and data
  • Configure Google Cloud authentication and permissions
  • Deploy the AI agent to Cloud Run
  • Test your deployed AI agent

🧠 What is Google Agent Development Kit (ADK)?

The Agent Development Kit (ADK) is a framework from Google for building AI agents. You define the agent's instructions, the model it uses, and the tools it can call, then run and test it locally before deploying it to the cloud.

♊ What is Gemini's Role?

Gemini is the model that powers the agent's reasoning. It reads the user's question, decides which tool to use, and turns the returned data into a clear answer in natural language.

🔌 What is Model Context Protocol (MCP)?

Model Context Protocol (MCP) is an open standard that defines how AI applications connect to external tools and data sources. Instead of writing a custom integration for every service, an agent can talk to any MCP server in a consistent way.

The BigQuery MCP Server exposes BigQuery capabilities to the agent as tools, so the agent can explore and query your datasets without you hand-coding each integration.

User Question
      │
      ▼
ADK Agent (powered by Gemini)
      │
      ▼
BigQuery MCP Server
      │
      ▼
BigQuery (Structured Data)
      │
      ▼
Answer in Natural Language

🛠️ Steps Covered in the Tutorial

Step 1: Set Up Your Google Cloud Project

Select or create a Google Cloud project, enable billing, and enable the APIs required for BigQuery, Cloud Run, and Gemini.

Step 2: Configure Authentication and Permissions

The agent needs permission to access BigQuery securely. We set up authentication and grant the required IAM roles so the agent can query data without exposing credentials in code.

Step 3: Build the AI Agent with ADK

Using Python and ADK, we create the agent, choose a Gemini model, and write instructions that tell the agent how to behave when answering data questions.

Step 4: Connect the Agent to the BigQuery MCP Server

Next, we connect the agent to the BigQuery MCP server so it can use BigQuery tools to look up and analyze structured data.

Step 5: Test the Agent Locally

Before deploying, we run the agent locally and ask data questions to confirm it queries BigQuery correctly. Testing locally first makes deployment problems much easier to separate from application bugs.

Step 6: Deploy the Agent to Cloud Run

We then deploy the agent to Cloud Run so it becomes a live web service. A source-based deployment generally looks like this (example only, values will differ in your setup):

gcloud run deploy YOUR_SERVICE_NAME \
  --source . \
  --region YOUR_REGION

Step 7: Test the Deployed Agent

Finally, we open the deployed service and ask questions to confirm the agent works the same way in the cloud as it did locally.

⚠️ Troubleshooting Tips

  • Permission errors: check that the account or service account has the right BigQuery and Cloud Run IAM roles
  • API not enabled: make sure the BigQuery, Cloud Run, Cloud Build, and Gemini-related APIs are enabled
  • Authentication problems: confirm you are signed in to the correct account and project
  • Deployment fails: read the full Cloud Build logs, as they usually point to the exact missing setting or permission

💻 Technologies Used

  • Google Cloud
  • Gemini
  • Agent Development Kit (ADK)
  • BigQuery
  • BigQuery MCP Server
  • Model Context Protocol (MCP)
  • Cloud Run
  • Python

💡 Key Takeaways

  • ADK gives you a clean structure for building AI agents
  • MCP provides a standard way to connect agents to tools and data
  • The BigQuery MCP server lets an agent query structured data without custom integration code
  • Good authentication and IAM setup is what makes the agent secure
  • Cloud Run makes it easy to turn an agent into a live service

✅ Conclusion

If you are learning Generative AI, AI agents, MCP, Google Cloud, or BigQuery, this project gives you practical experience building an agent that works with real structured data and runs in the cloud. From here, you can extend it with your own datasets, more tools, and more advanced agent behavior.

If this tutorial helped you, like the video, subscribe to the channel, and turn on notifications for more Google Cloud, AI agent, GenAI, and developer tutorials.

Disclaimer: This content is created for educational and learning purposes only. The cloud environment and resources shown are part of a controlled training/lab environment. Please use any commands or configurations only on cloud resources that you own or are authorized to access. This content is not affiliated with or endorsed by the respective cloud service provider unless explicitly stated.

Comments

Popular posts from this blog

Complete Guide to AWS IAM – AWS Academy Cloud Foundations Lab 1

Top 5 Budget Earbuds Under ₹1000 That Are Worth Buying

Top 5 Programming Languages to Learn in 2025