Google BigQuery
Let your AI explore and query Google BigQuery: list projects, datasets and tables, read schemas, preview rows for free, estimate a query's cost with a dry run before running it, page through results and check the job history. Signs in with your Google account.
7 天免费 · 无需信用卡 · EU 托管
问 Google 任何事
通过 AnythingMCP 对 Google BigQuery 试一个真实提示 — Claude 调用工具并返回答案。在你的消息上按 Enter 即可在 Cloud 安装。
在 Cloud 上安装 GoogleClaude 是 AI,可能会出错。请核对回答。
2 分钟设置
- 1在 cloud.anythingmcp.com 开始免费试用。
- 2在连接器商店点击 Google BigQuery。提示时粘贴凭据。
- 3生成 MCP API 密钥,将 AI 客户端指向生成的 MCP URL。
配置 Google BigQuery
直接来自连接器定义:在哪里获取凭据、需要哪些权限,以及该适配器调用的是哪个 API。 由连接器作者以英文提供。
Google BigQuery
This connector works with Google BigQuery through the BigQuery REST API v2 (https://bigquery.googleapis.com/bigquery/v2): projects, datasets, tables and their schemas, free row previews, SQL queries with a cost estimate first, query results page by page, and the job history. It signs in with your Google account (OAuth), so the AI sees exactly what that account may see in BigQuery.
Setup (one-time, about 10 minutes)
- Open https://console.cloud.google.com, pick or create a project, then APIs & Services → Library → enable BigQuery API.
- APIs & Services → OAuth consent screen: choose Internal if you are on Google Workspace (simplest), otherwise External. For External, set the publishing status to In production: while an app is in Testing, Google revokes its refresh tokens after 7 days and the connector stops working every week. For your own use, the "unverified app" warning can be clicked through.
- APIs & Services → Credentials → Create credentials → OAuth client ID → application type Web application → add the authorized redirect URI
<your AnythingMCP URL>/api/mcp-oauth/callback(on AnythingMCP Cloud:https://cloud.anythingmcp.com/api/mcp-oauth/callback). - Paste the client ID and secret into
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETand install the connector. - On the connector page, click Authorize with Provider and sign in with the Google account whose BigQuery data the AI should use. The refresh token is stored encrypted and access tokens are renewed automatically.
One Google client for all Google connectors: the same Cloud project and OAuth client can serve every Google connector. Enable each API in that project, reuse the same GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET, and authorize each connector once.
Permissions and scope
- The connector asks for
https://www.googleapis.com/auth/bigquery(view and manage BigQuery data). What the AI can actually read, query or change is decided by the signed-in account's IAM roles. To run queries the account needs BigQuery Job User on the project that runs them and BigQuery Data Viewer on the data. - Read-only setup: Google publishes no
bigquery.readonlyscope for this API. Usehttps://www.googleapis.com/auth/cloud-platform.read-onlyinstead (it allows listing, reading and running query jobs) in the connector's OAuth settings, authorize again, and give the account only BigQuery Data Viewer and BigQuery Job User: without write roles on the data, statements that change data fail with 403. Also disablebigquery_cancel_job.
Exploring (free, no bytes scanned): bigquery_list_projects → bigquery_list_datasets → bigquery_list_tables → bigquery_get_table (schema, size, partitioning). bigquery_get_dataset shows a dataset's location and settings. Always read the schema before writing SQL.
Queries cost money: dry-run first. On on-demand pricing BigQuery bills the bytes a query scans, about US$6.25 per TiB in most regions (the first 1 TiB each month is free; at least 10 MB per table referenced). Capacity (editions) pricing bills slots instead.
- Before running a query on a table you have not sized, call
bigquery_run_querywithdryRun: true. It costs nothing and returnstotalBytesProcessed(the estimate) andstatementType. - Tell the user the estimate in GB and the approximate cost. If it is above 10 GB (about 6 US cents), ask the user to confirm before running it, and suggest narrowing it first: select only the needed columns (
SELECT *reads every column), filter on the partition column, use a smaller date range. - Then run it without
dryRun. PassmaximumBytesBilledslightly above the estimate as a safety net: a query that would bill more fails without charge.
LIMITdoes not reduce the bytes scanned. To look at sample rows usebigquery_preview_table_rows, which is free.- Check
bigquery_get_tablefirst:numBytesshows the table size,timePartitioningandrequirePartitionFiltershow whether a partition filter is needed.
Statements that change data need confirmation. bigquery_run_query runs any GoogleSQL statement the account is allowed to run, including INSERT, UPDATE, DELETE, MERGE, CREATE, ALTER and DROP. Before running anything other than a SELECT, show the user the exact statement and its effect and wait for an explicit yes. A dry run returns the statementType, which tells you what a statement does.
Writing queries
- The connector always uses GoogleSQL (
useLegacySql: false). Qualify tables as`project.dataset.table`with backticks, e.g.`bigquery-public-data.samples.shakespeare`, or setdefaultDataset. - Use query parameters for user-supplied values:
@namein the SQL plusparameterMode: "NAMED"andqueryParameters, e.g.[{"name": "country", "parameterType": {"type": "STRING"}, "parameterValue": {"value": "DE"}}]. - Run queries in the project the user pays for; data in another project (such as
bigquery-public-data) is read across projects.
Reading results
rowscome back as a list of{"values": [...]}, one value per column in the order ofschema. Every value is a string (numbers too),nullstays null; TIMESTAMP values are seconds since 1970 (e.g."1.7290944E9"), RECORD values are nested{"f": [{"v": ...}]}.bigquery_run_queryreturns up to 100 rows by default (maxResults, at most 1,000). WhenpageTokenis present, more rows exist: callbigquery_get_query_resultswith thejobIdandlocationfromjobReferenceand thatpageToken. Summarise or aggregate in SQL rather than paging through large results.- Long queries: when
jobCompleteis false, the query keeps running. Wait a few seconds and callbigquery_get_query_resultswith the samejobIduntiljobCompleteis true, orbigquery_get_jobto see its state.bigquery_cancel_jobstops it (ask the user first; bytes already scanned may still be billed).
History: bigquery_list_jobs lists recent jobs of a project (your own by default, allUsers: true for everyone's with the right permission) and bigquery_get_job shows one job's SQL, state, bytes processed and billed and errors.
Common errors
- 401: the authorization expired or was revoked (always after 7 days while the consent screen is in Testing). Click Authorize with Provider again.
- 403
accessDenied: the account lacks a role (Job User on the query project, Data Viewer on the data), or a read-only scope was used for a change. 403BigQuery API has not been used in project: enable the BigQuery API in the Cloud project of the OAuth client. - 403
bytesBilledLimitExceeded: the query would scan more thanmaximumBytesBilled; nothing was charged. - 400
invalidQuery: SQL error, the message names the position. 404notFound: wrong project, dataset or table id, or a job queried without itslocation. - 403
quotaExceeded/rateLimitExceeded: wait and retry.
Out of scope here: loading or exporting data, copying tables, creating or deleting datasets and tables through the API (DDL statements in a query can do it, with confirmation), BigQuery ML model management, scheduled queries and the Storage Read API.