Source URL: https://cloud.google.com/blog/products/ai-machine-learning/bigquery-meets-google-adk-and-mcp/
Source: Cloud Blog
Title: BigQuery meets ADK & MCP: Accelerate agent development with BigQuery’s new first-party toolset
Feedly Summary: As the excitement around AI agents reaches enterprise customers, a critical question emerges: How can we empower these agents to securely and intelligently interact with enterprise data systems like Google Cloud BigQuery?
Currently, the developers building agentic applications have been forced to build and maintain their own custom tools, a process that is slow, risky, and distracts from building innovative applications. This introduces considerable development overhead and risk, as they become responsible for everything from authentication and error handling to keeping pace with BigQuery’s evolving capabilities.
To solve this, we are introducing a new, first-party toolset for BigQuery that includes tools to fetch metadata and execute queries (and we have more on the way):
list_dataset_ids: Fetches BigQuery dataset ids present in a GCP project.
get_dataset_info: Fetches metadata about a BigQuery dataset.
list_table_ids: Fetches table ids present in a BigQuery dataset.
get_table_info: Fetches metadata about a BigQuery table.
execute_sql: Runs a SQL query in BigQuery and fetch the result.
These official, Google-maintained tools provide a secure and reliable bridge to your data, and you can use them in two powerful ways: a built-in toolset in Google’s Agent Development Kit (ADK) or through the flexible, open-source MCP Toolbox for Databases. This frees you to focus on creating value, not on building foundational plumbing.
In this post, we’ll explore these first-party tools for BigQuery and walk you through how they can be used to build a conversational analytics agent in ADK that can answer natural language questions.
Tutorial: Build a Conversational Analytics Agent using BigQuery’s first-party tools
Our agent will query BigQuery’s public dataset: thelook_ecommerce, a synthetic e-commerce dataset that includes customer details, product inventories, and order histories. The agent’s primary role will be to generate SQL queries and provide meaningful responses to common business questions, such as: What are the top-selling products? Which products are frequently ordered together? And how many customers do we have in Colombia?
If you’re new to ADK, this page provides an overview of its core concepts and components; otherwise, let’s dive in!
You first need to create a python environment and install ADK.You can then invoke the adk utility to create a new bq-agent-app ADK application in the current folder:
code_block
Choose your model, select Vertex AI as the backend, and confirm your project id and region:
You should now have a new folder named bq-agent-app. Navigate to agent.py and update the root LLM-Agent to reflect our conversational analytics agent:
code_block
<ListValue: [StructValue([(‘code’, ‘root_agent = Agent(\r\n model=”gemini-2.0-flash",\r\n name="bigquery_agent",\r\n description=(\r\n "Agent that answers questions about BigQuery data by executing SQL queries"\r\n ),\r\n instruction=""" You are a data analysis agent with access to several BigQuery tools. Make use of those tools to answer the user\’s questions.\r\n\r\n """,\r\n tools=[bigquery_toolset],\r\n)’), (‘language’, ‘lang-py’), (‘caption’, <wagtail.rich_text.RichText object at 0x3e776eabc5b0>)])]>
When defining your agent, you provide a unique name, specify the underlying LLM model, and can optionally include a description that helps other agents understand its purpose. The agent’s core task or goal is defined in the instructions.
Finally, to enable the agent to interact with your data, it must be equipped with tools that allow it to interact with BigQuery so it can understand the available datasets and tables, and of course, execute queries. Let’s consider our options when it comes to using BigQuery’s first-party toolset.
Option 1: Use ADK’s new built-in toolset for BigQuery
This first-party toolset is owned and maintained by Google. To assign these tools to your agent, you need to import the BigQueryToolset from the agents.tools module and then initialize the toolset:
code_block
<ListValue: [StructValue([(‘code’, ‘from google.adk.tools.bigquery import BigQueryCredentialsConfig\r\nfrom google.adk.tools.bigquery import BigQueryToolset\r\nimport google.auth\r\n\r\n# Define an appropriate credential type\r\nCREDENTIALS_TYPE = AuthCredentialTypes.OAUTH2\r\n\r\n# Write modes define BigQuery access control of agent:\r\n# ALLOWED: Tools will have full write capabilites.\r\n# BLOCKED: Default mode. Effectively makes the tool read-only.\r\n# PROTECTED: Only allows writes on temporary data for a given BigQuery session.\r\n\r\n\r\ntool_config = BigQueryToolConfig(write_mode=WriteMode.ALLOWED)\r\n\r\nif CREDENTIALS_TYPE == AuthCredentialTypes.OAUTH2:\r\n # Initiaze the tools to do interactive OAuth\r\n credentials_config = BigQueryCredentialsConfig(\r\n client_id=os.getenv("OAUTH_CLIENT_ID"),\r\n client_secret=os.getenv("OAUTH_CLIENT_SECRET"),\r\n )\r\nelif CREDENTIALS_TYPE == AuthCredentialTypes.SERVICE_ACCOUNT:\r\n # Initialize the tools to use the credentials in the service account key.\r\n creds, _ = google.auth.load_credentials_from_file("service_account_key.json")\r\n credentials_config = BigQueryCredentialsConfig(credentials=creds)\r\nelse:\r\n # Initialize the tools to use the application default credentials.\r\n application_default_credentials, _ = google.auth.default()\r\n credentials_config = BigQueryCredentialsConfig(\r\n credentials=application_default_credentials\r\n )\r\n\r\nbigquery_toolset = BigQueryToolset(credentials_config=credentials_config, tool_filter=[\r\n\’list_dataset_ids\’,\r\n\’get_dataset_info\’,\r\n\’list_table_ids\’,\r\n\’get_table_info\’,\r\n\’execute_sql\’,\r\n ])’), (‘language’, ‘lang-py’), (‘caption’, <wagtail.rich_text.RichText object at 0x3e776eabc610>)])]>
You can use the tool_filter parameter to filter the tools you’d like to expose to the agent.
A note on authentication…
You currently have three options for authenticating with BigQuery:
Use the application default credentials that are associated with the environment where the code is running.
Use service account credentials by loading them from a service account key file.
Provide an OAuth 2.0 client_id and secret. This approach is typically used when an application needs a user to grant it permission to access their BigQuery data.
For more granular control over your interaction with BigQuery, you can of course create your own custom function tools, which are implemented as Python functions that you expose to your agent.
When tools are implemented directly within an agent, even with built-in toolsets, the agent or application is responsible for managing its authentication to BigQuery, as well as the logic and implementation for each tool. This tight coupling creates challenges: updates to a tool or changes in its BigQuery connection method will require manual modification and redeployment for every agent, which can lead to inconsistencies and maintenance overhead.
Option 2: Use BigQuery’s pre-built tools in MCP Toolbox for Databases
The MCP (Model Context Protocol) Toolbox for Databases is an open-source server that centralizes the hosting and management of toolsets, decoupling agentic applications from direct BigQuery interaction. Instead of managing tool logic and authentication themselves, agents act as MCP clients, requesting tools from the Toolbox. The MCP Toolbox handles all the underlying complexities, including secure connections to BigQuery, authentication and query execution.
This centralized approach simplifies tool reuse across multiple agents, streamlines updates (tool logic can be modified and deployed on the Toolbox without requiring changes to every agent), and provides a single point for enforcing security policies.
The MCP Toolbox for Databases natively supports BigQuery’s pre-built toolset. To access these tools, you first need to create a new mcp-toolbox folder in the same directory as your ADK application, and then install the MCP Toolbox:
Set the BIGQUERY_PROJECT environment variable, this represents the project where your BigQuery jobs will be created, executed and billed:
code_block
<ListValue: [StructValue([(‘code’, ‘export BIGQUERY_PROJECT=<YOUR_PROJECT_NAME>’), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x3e776eabc670>)])]>
Run this command to start the toolbox and include the BigQuery toolset:
code_block
<ListValue: [StructValue([(‘code’, ‘./toolbox –prebuilt bigquery’), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x3e776eabc6d0>)])]>
You can also configure the MCP client within your IDE.
Want to host your own custom tools in MCP Toolbox for Databases?
You can define your own custom tools in SQL within a tools.yaml configuration file and provide the –tools-file option when starting your server. You cannot, however, use the –prebuilt and –tools-file option together. If you want to use custom tools alongside prebuilt tools, you must use the –tool-file option and manually specify the prebuilt tools you want to include in the configuration file, like so.
To connect your ADK application to the MCP Toolbox for Databases, you need to install toolbox-core:
code_block
<ListValue: [StructValue([(‘code’, ‘pip install toolbox-core’), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x3e776eabc730>)])]>
With your server up and running, you can retrieve your toolset using ToolboxSyncClient and its load_toolset() function:
code_block
<ListValue: [StructValue([(‘code’, ‘from toolbox_core import ToolboxSyncClient\r\n\r\nbigquery_toolbox = ToolboxSyncClient("http://127.0.0.1:5000")\r\nbigquery_toolset = bigquery_toolbox.load_toolset()’), (‘language’, ‘lang-py’), (‘caption’, <wagtail.rich_text.RichText object at 0x3e776eabc790>)])]>
Run your Conversational Analytics Agent
Assign either the built-in ADK toolset, or the MCP toolset to your agent, and you’re ready to go!
code_block
<ListValue: [StructValue([(‘code’, ‘root_agent = Agent(\r\n model="gemini-2.0-flash",\r\n name="bigquery_agent",\r\n description=(\r\n "Agent that answers questions about BigQuery data by executing SQL queries"\r\n ),\r\n instruction=""" You are a data analysis agent with access to several BigQuery tools. Make use of those tools to answer the user\’s questions.\r\n """,\r\n tools=[bigquery_toolset]\r\n)’), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x3e776eabc7f0>)])]>
You can now run your agent using the adk run or adk web command and start asking questions about your data!
Your agent will leverage pre-built tools to extract dataset metadata, and then generate and execute a SQL query in BigQuery to retrieve your result:
Get started
Dive into these tutorials and start building your conversational analytics agent today:
Repo with sample agent using first-party toolset in ADK
MCP Toolbox for BigQuery Codelab
10 tips to safeguard your data (and wallet) when building BigQuery agents
AI Summary and Description: Yes
**Summary:**
This text is focused on enhancing security and efficiency in AI-driven applications that interact with Google Cloud BigQuery. It introduces first-party tools and frameworks designed to simplify the development of data-centric AI agents while ensuring secure access to enterprise data systems. This is particularly relevant for professionals in AI, cloud, and infrastructure security by addressing risks associated with developing custom tools and emphasizing secure interactions with data.
**Detailed Description:**
The text explores the launch of a suite of first-party tools for Google Cloud BigQuery aimed at facilitating the development of AI agents. Here are the main points emphasized:
– **Introduction of First-Party Tools:**
– The tools provided enhance developers’ ability to interact securely and efficiently with BigQuery, focusing on automation and reducing the complexity of agent development.
– **Key Functionalities of the Toolset:**
– **`list_dataset_ids`:** Fetches BigQuery dataset IDs for the selected GCP project.
– **`get_dataset_info`:** Retrieves metadata about specific datasets.
– **`list_table_ids`:** Lists table IDs within a dataset.
– **`get_table_info`:** Gathers metadata for specific tables.
– **`execute_sql`:** Runs SQL queries and returns results.
– **Benefits of Using Google’s Tools:**
– The official toolset ensures a secure and reliable means for agents to access data while offloading the burden of maintaining custom implementations.
– Builds integrate seamlessly with mainstream AI developments, allowing developers to focus more on problem-solving than foundational integrity.
– **Platform Integration:**
– The tools can be accessed through two main conduits: Google’s Agent Development Kit (ADK) and the open-source MCP Toolbox for Databases.
– The ADK aids in developing applications with built-in toolsets, while the MCP Toolbox offers a centralized service for managing toolsets, thereby simplifying updates and enhancing security compliance.
– **Security and Authentication:**
– Discusses various authentication options (application default credentials, service account credentials, and OAuth 2.0) to connect securely to BigQuery.
– Highlights the importance of maintaining secure communication between agent applications and data sources.
– **Example Use Case: Creating a Conversational Analytics Agent:**
– Illustrates a practical application where an agent leverages these tools to query public datasets and address business questions through natural language processing.
– **Challenges and Solutions:**
– Recognizes the complexity of custom-built tools leading to inefficiencies and maintenance overhead, advocating for standardized tools that enhance security and simplify development efforts.
– **Final Steps:**
– Guides readers through initial setup, tool configuration, and running the agent, encouraging best practices in agent development and data security.
This summary emphasizes the significance of these advancements for AI, cloud computing, and security professionals focused on building reliable and secure data-driven applications. The integration of first-party tools significantly lowers the barrier to entry for developing complex AI agents while prioritizing security in data interactions.