BigQuery MCP server
Connect Claude, ChatGPT or Claude Code to BigQuery over MCP (Model Context Protocol), without handing out a service account key. The assistant reads the dataset, writes SQL and runs it, and Thunderduck checks every query before it reaches BigQuery.
The problem: an assistant with a service account key
The usual way to give an assistant BigQuery is a local MCP server started with a service account key file. It works on day one, and it leaves you with three problems once the data is real:
- The key file sits on every machine that uses it. A BigQuery service account key does not expire on its own, and it often has more access than the assistant needs.
- BigQuery bills by the data a query reads. An assistant exploring a table
it does not know will happily run a
SELECT *over a large table, and you pay for every byte it scans. - The assistant only sees names and types.
revenuecould include tax or not, andevent_tscould be UTC or local time, so plausible SQL returns wrong numbers.
How Thunderduck solves it
Thunderduck runs a hosted MCP server in front of BigQuery, at
https://mcp.thunderduck.ai/mcp.
- No key file on any laptop. The service account key goes to a secrets manager when you add the dataset. People sign in to the assistant with their own Thunderduck account (OAuth), and the assistant never sees the key.
- Read-only in three places. The service account's IAM roles, the catalog's read-only flag and the user's token scope each block writes on their own.
- Every query is checked before it runs. Thunderduck plans the SQL first and refuses it above the per-query or daily limit, or when it would scan a large table with no selective filter. See Scopes & costs.
- Filters run in BigQuery. Filters on constant values and on
current_datearithmetic are pushed down, and so areGROUP BY,ORDER BYandLIMITwhen the query reads one table, so only the result crosses the wire. Each statement carries a comment naming the Thunderduck user, so you can find it in BigQuery's job history. - Columns come with meanings. Thunderduck infers a description and a unit for each column and lets your team correct them. The assistant reads them before it writes SQL. See Column meanings.
- One server for every source. The same connection reaches your PostgreSQL, MySQL and S3 data, and one query can join them with BigQuery.
Set it up
1. Create a service account
In Google Cloud, create a service account for Thunderduck, give it these roles, and download a JSON key:
| Role | Scope | Why |
|---|---|---|
roles/bigquery.dataViewer | the dataset | read the tables |
roles/bigquery.jobUser | the project | run a query at all |
roles/bigquery.readSessionUser | the project | read through the Storage Read API |
Without the last role, queries and metadata collection fail with the user does not have 'bigquery.readsessions.create' permission. Leave out
roles/bigquery.dataEditor and the account cannot write.
2. Add the dataset as a catalog
In the console, Catalogs → Create catalog → BigQuery. Give it a short
lowercase name such as bq_sales, enter the project id and the dataset,
paste the JSON key, and turn on Read-only.
Always set the dataset. Without it, Thunderduck lists every dataset and table in the project each time a query is planned, which on a real project took 62 seconds instead of 0.9. Add one catalog per dataset.
All fields are on the BigQuery page.
3. Connect your assistant
Claude (claude.ai and Claude Desktop): Settings → Connectors → Add custom connector, paste the URL below, and sign in.
https://mcp.thunderduck.ai/mcpClaude Code:
claude mcp add --transport http thunderduck https://mcp.thunderduck.ai/mcp \
--client-id thunderduck-mcp-cli --callback-port 33418ChatGPT: add a connector with the same URL.
More on each client in Connecting Claude & ChatGPT.
4. Ask a question
What was revenue per country over the last 30 days, and which countries grew fastest compared with the 30 days before?
The assistant calls get_catalog_context('bq_sales') to read the tables, keys
and column meanings, checks the price with estimate_query_cost, then runs
something like:
SELECT country,
sum(amount) FILTER (WHERE order_date >= current_date - 30) AS last_30,
sum(amount) FILTER (WHERE order_date < current_date - 30) AS prior_30
FROM bq_sales.sales.orders
WHERE order_date >= current_date - 60
GROUP BY country
ORDER BY last_30 DESC;Tables are addressed as catalog.dataset.table. The date filter runs inside
BigQuery, so on a table partitioned by order_date it reads 60 days of data,
not the whole table.
What the assistant can do
| With a read-only setup | |
|---|---|
| List tables and columns in the dataset | Yes |
| Read column meanings, keys and joins | Yes |
Run SELECT | Yes, within the cost limits |
| Export a large result to Parquet or CSV | Only with the export scope |
INSERT, UPDATE, DELETE, DDL | No: refused by IAM, the catalog and the token |
| Schedule a query | Only with the query:write scope |
The full list is on the Tools page.
BigQuery still bills you. Thunderduck's cost limits cover its own compute. BigQuery bills your project for what it reads, which is why the pushdown and the dataset pin matter. To stop paying BigQuery for tables you read often, move them into Iceberg: see Migrating from BigQuery.
Compared with other BigQuery MCP servers
Google's MCP Toolbox for Databases and other open-source servers run on your
own machine with your Google credentials. If you are the only user and you
already have gcloud set up, that is the simpler choice: no account, nothing
hosted.
Thunderduck fits when more than one person will connect, when keys should not sit on laptops, when queries need a cost check before they run, or when the questions span BigQuery and your other databases.
Related
- BigQuery catalogs: every connection field and IAM role
- Scopes & costs: limits, row caps and refusals
- Column meanings: how the assistant learns what columns mean
- PostgreSQL MCP server · MySQL MCP server · ClickHouse MCP server · SQL Server MCP server