
Getting started with Agents that interact with Google Cloud Databases using natural language.
Google cloud recently made updates to the MCP Toolbox for databases to enable usage with IDE’s such as VS Code, Cursor and plugins such as Cline.
Essentially, the latest update adds 5 tools to the toolbox for BigQuery. The tools can execute sql, get information on dataset and tables, list datasets and tables for a BigQuery datasource. For other data sources such as Spanner or Cloud SQL the list of tools are a bit different, please see the documentation for the list. BigQuery AlloyDB CloudSQL Spanner
Now, the tools can be used not just by IDE’s but can also be leveraged by other MCP clients or Agent frameworks.
Let us look at a simple example of using the Toolbox with the Agent Development Kit — ADK from Google.
Follow the instructions to install the ADK and the Toolbox (BigQuery).
Let’s look at the example configuration for one of IDE’s,
{
"mcpServers": {
"bigquery": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","bigquery","--stdio"],
"env": {
"BIGQUERY_PROJECT": ""
}
}
}
}
We will be using this information to setup STDIO transport between our client and server. Plugin the path where the toolbox is installed and your BigQuery project name in the json.
An example configuration,
{
"mcpServers": {
"bigquery": {
"command" : "/usr/local/software/toolbox",
"args": ["--prebuilt","bigquery","--stdio"],
"env": {
"BIGQUERY_PROJECT": "mydemoproj"
}
}
}
}
Assuming ADK and the Toolbox have been setup successfully, we will get a simple basic agent going. The sample code is below,
from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParametersroot_agent = LlmAgent(
model="gemini-2.5-flash",
name="database_agent",
instruction="You are a database query agent. Use the tools available to get dataset metadata, table metadata, list tables and datasets. Next, get table information and identify the correct tables, then assemble the SQL statement. Finally execute the SQL against the data.",
tools=[
MCPToolset(
connection_params=StdioServerParameters(
command="/usr/local/software/toolbox",
args=["--prebuilt","bigquery","--stdio", "--log-level","DEBUG"],
env = {"BIGQUERY_PROJECT": "mydemoproj"}
)
)
],
)
Change the command and env parameters to reflect the location of where toolbox has been installed and the GCP project. Please change the model to the one you are using if needed. This example is using the gemini-2.5-flash model.
Next we will run the Agent using the built-in web interface that comes with the ADK, run ‘adk web’ from the command line. By default it spins up a web UI that listens on port 8000.
Shown below is an example of the UI interaction, the Agent lists the Tools capabilities available as part of the Toolbox.
The interaction below is querying a BigQuery table with data loaded from this Kaggle dataset which contains sample sales data. The table has details of sales with information such as Productline, Quantity, Price and Customer details.
Shown below are interactions that attempt to ask different questions in natural language which the Agent processes using the tools available as part of the Toolkit.
Below is a simple example that involves an aggregation and a filter. Notice that the Agent first invokes tool to get table information and subsequently the Agent constructs the SQL statement which is executed by the execute sql tool.
Verifying in the BQ Console,
Some more example interactions with the Agent below, involving more complexity in the queries
In this case, the LLM picks out the two rows with the query returning all the candidate results,
This setup above illustrates how using the tools provided by the MCP Toolkit for databases, a simple NL2SQL can be assembled. The Agent can be modified to accommodate advanced scenarios, but this article should help in getting started.
To deploy the Agent to Agent Engine which is a fully managed runtime for ADK in GCP, please see this link.
Source Credit: https://medium.com/google-cloud/query-your-database-using-natural-language-using-the-mcp-toolbox-from-gcp-bd186e5fe342?source=rss—-e52cf94d98af—4