chore: import upstream snapshot with attribution
Continuous Integration / Pre-commit Linter (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.10) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.11) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.12) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.10) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.11) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.12) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.14) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.10) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.11) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.12) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.13) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.14) (push) Waiting to run
Copybara PR Handler / close-imported-pr (push) Waiting to run
Continuous Integration / Pre-commit Linter (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.10) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.11) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.12) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.10) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.11) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.12) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.14) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.10) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.11) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.12) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.13) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.14) (push) Waiting to run
Copybara PR Handler / close-imported-pr (push) Waiting to run
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# BigQuery MCP Toolset Sample
|
||||
|
||||
## Introduction
|
||||
|
||||
This sample agent demonstrates using ADK's `McpToolset` to interact with
|
||||
BigQuery's official MCP endpoint, allowing an agent to access and execute
|
||||
tools by leveraging the Model Context Protocol (MCP). These tools include:
|
||||
|
||||
1. `list_dataset_ids`
|
||||
|
||||
Fetches BigQuery dataset ids present in a GCP project.
|
||||
|
||||
2. `get_dataset_info`
|
||||
|
||||
Fetches metadata about a BigQuery dataset.
|
||||
|
||||
3. `list_table_ids`
|
||||
|
||||
Fetches table ids present in a BigQuery dataset.
|
||||
|
||||
4. `get_table_info`
|
||||
|
||||
Fetches metadata about a BigQuery table.
|
||||
|
||||
5. `execute_sql`
|
||||
|
||||
Runs or dry-runs a SQL query in BigQuery.
|
||||
|
||||
## How to use
|
||||
|
||||
Set up your project and local authentication by following the guide
|
||||
[Use the BigQuery remote MCP server](https://docs.cloud.google.com/bigquery/docs/use-bigquery-mcp).
|
||||
This agent uses Application Default Credentials (ADC) to authenticate with the
|
||||
BigQuery MCP endpoint.
|
||||
|
||||
Set up environment variables in your `.env` file for using
|
||||
[Google AI Studio](https://google.github.io/adk-docs/get-started/quickstart/#gemini---google-ai-studio)
|
||||
or
|
||||
[Google Cloud Vertex AI](https://google.github.io/adk-docs/get-started/quickstart/#gemini---google-cloud-vertex-ai)
|
||||
for the LLM service for your agent. For example, for using Google AI Studio you
|
||||
would set:
|
||||
|
||||
- GOOGLE_GENAI_USE_ENTERPRISE=FALSE
|
||||
- GOOGLE_API_KEY={your api key}
|
||||
|
||||
Then run the agent using `adk run .` or `adk web .` in this directory.
|
||||
|
||||
## Sample prompts
|
||||
|
||||
- which weather datasets exist in bigquery public data?
|
||||
- tell me more about noaa_lightning
|
||||
- which tables exist in the ml_datasets dataset?
|
||||
- show more details about the penguins table
|
||||
- compute penguins population per island.
|
||||
@@ -0,0 +1,15 @@
|
||||
# Copyright 2026 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from . import agent
|
||||
@@ -0,0 +1,55 @@
|
||||
# Copyright 2026 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from google.adk.agents.llm_agent import LlmAgent
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_toolset import McpToolset
|
||||
from google.adk.utils import _mtls_utils
|
||||
import google.auth
|
||||
|
||||
BIGQUERY_AGENT_NAME = "adk_sample_bigquery_mcp_agent"
|
||||
BIGQUERY_MCP_ENDPOINT = _mtls_utils.get_api_endpoint(
|
||||
location="",
|
||||
default_template="https://bigquery.googleapis.com/mcp",
|
||||
mtls_template="https://bigquery.mtls.googleapis.com/mcp",
|
||||
)
|
||||
BIGQUERY_SCOPE = "https://www.googleapis.com/auth/bigquery"
|
||||
|
||||
# Initialize the tools to use the application default credentials.
|
||||
# https://cloud.google.com/docs/authentication/provide-credentials-adc
|
||||
credentials, project_id = google.auth.default(scopes=[BIGQUERY_SCOPE])
|
||||
credentials.refresh(google.auth.transport.requests.Request())
|
||||
oauth_token = credentials.token
|
||||
|
||||
bigquery_mcp_toolset = McpToolset(
|
||||
connection_params=StreamableHTTPConnectionParams(
|
||||
url=BIGQUERY_MCP_ENDPOINT,
|
||||
headers={"Authorization": f"Bearer {oauth_token}"},
|
||||
)
|
||||
)
|
||||
|
||||
# The variable name `root_agent` determines what your root agent is for the
|
||||
# debug CLI
|
||||
root_agent = LlmAgent(
|
||||
name=BIGQUERY_AGENT_NAME,
|
||||
description=(
|
||||
"Agent to answer questions about BigQuery data and models and execute"
|
||||
" SQL queries using MCP."
|
||||
),
|
||||
instruction="""\
|
||||
You are a data science agent with access to several BigQuery tools provided via MCP.
|
||||
Make use of those tools to answer the user's questions.
|
||||
""",
|
||||
tools=[bigquery_mcp_toolset],
|
||||
)
|
||||
Reference in New Issue
Block a user