GCP – BigQuery meets ADK & MCP: Accelerate agent development with BigQuery’s new first-party toolset
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
- <ListValue: [StructValue([(‘code’, ‘adk create bq-agent-app’), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x3e0fdb7fb8e0>)])]>
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(rn model=”gemini-2.0-flash”,rn name=”bigquery_agent”,rn description=(rn “Agent that answers questions about BigQuery data by executing SQL queries”rn ),rn instruction=””” You are a data analysis agent with access to several BigQuery tools. Make use of those tools to answer the user’s questions.rnrn “””,rn tools=[bigquery_toolset],rn)’), (‘language’, ‘lang-py’), (‘caption’, <wagtail.rich_text.RichText object at 0x3e0fdb7fb0d0>)])]>
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 BigQueryCredentialsConfigrnfrom google.adk.tools.bigquery import BigQueryToolsetrnimport google.authrnrn# Define an appropriate credential typernCREDENTIALS_TYPE = AuthCredentialTypes.OAUTH2rnrn# Write modes define BigQuery access control of agent:rn# ALLOWED: Tools will have full write capabilites.rn# BLOCKED: Default mode. Effectively makes the tool read-only.rn# PROTECTED: Only allows writes on temporary data for a given BigQuery session.rnrnrntool_config = BigQueryToolConfig(write_mode=WriteMode.ALLOWED)rnrnif CREDENTIALS_TYPE == AuthCredentialTypes.OAUTH2:rn # Initiaze the tools to do interactive OAuthrn credentials_config = BigQueryCredentialsConfig(rn client_id=os.getenv(“OAUTH_CLIENT_ID”),rn client_secret=os.getenv(“OAUTH_CLIENT_SECRET”),rn )rnelif CREDENTIALS_TYPE == AuthCredentialTypes.SERVICE_ACCOUNT:rn # Initialize the tools to use the credentials in the service account key.rn creds, _ = google.auth.load_credentials_from_file(“service_account_key.json”)rn credentials_config = BigQueryCredentialsConfig(credentials=creds)rnelse:rn # Initialize the tools to use the application default credentials.rn application_default_credentials, _ = google.auth.default()rn credentials_config = BigQueryCredentialsConfig(rn credentials=application_default_credentialsrn )rnrnbigquery_toolset = BigQueryToolset(credentials_config=credentials_config, tool_filter=[rn’list_dataset_ids’,rn’get_dataset_info’,rn’list_table_ids’,rn’get_table_info’,rn’execute_sql’,rn ])’), (‘language’, ‘lang-py’), (‘caption’, <wagtail.rich_text.RichText object at 0x3e0fdb7fb5b0>)])]>
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 0x3e0fdb7fb5e0>)])]>
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 0x3e0fdb7fbc10>)])]>
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 0x3e0fdb7fb640>)])]>
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 ToolboxSyncClientrnrnbigquery_toolbox = ToolboxSyncClient(“http://127.0.0.1:5000”)rnbigquery_toolset = bigquery_toolbox.load_toolset()’), (‘language’, ‘lang-py’), (‘caption’, <wagtail.rich_text.RichText object at 0x3e0fdb7fb6d0>)])]>
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(rn model=”gemini-2.0-flash”,rn name=”bigquery_agent”,rn description=(rn “Agent that answers questions about BigQuery data by executing SQL queries”rn ),rn instruction=””” You are a data analysis agent with access to several BigQuery tools. Make use of those tools to answer the user’s questions.rn “””,rn tools=[bigquery_toolset]rn)’), (‘language’, ”), (‘caption’, <wagtail.rich_text.RichText object at 0x3e0fdb7fb9d0>)])]>
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:
Read More for the details.