BigQuery Analytics MCP
# BigQuery Analytics MCP
[Документация на русском](README.ru.md)
A stdio MCP server for querying BigQuery, including Firebase Analytics / GA4 event exports, and guiding teammates through setup. It runs `bq` in Google Cloud Shell under the Google account configured for the OS user that runs the server.
## Setup
1. Install Node.js 22+ and the [Google Cloud CLI](https://cloud.google.com/sdk/docs/install).
2. Clone this repository and run `npm ci`.
3. Run `gcloud auth login` as the OS user that will run MCP. Open [Cloud Shell](https://shell.cloud.google.com/) and complete its initial setup. For organization-managed projects, use an execution environment approved by your administrator.
4. Request **BigQuery Job User** on the billing project and **BigQuery Data Viewer** on the datasets you need. Use a least-privilege identity.
5. Add this server to your MCP client and start a fresh session. Replace the path and sample GCP values with your own.
```json
{
"mcpServers": {
"bigquery-analytics-mcp": {
"command": "node",
"args": ["/absolute/path/bigquery-analytics-mcp/src/mcp.js"],
"env": {
"BIGQUERY_BILLING_PROJECT": "my-billing-project",
"BIGQUERY_LOCATION": "US",
"BIGQUERY_SOURCES": "{\"beta\":\"my-data-project.analytics_123456789\"}"
}
}
}
}
```
In meta-agent, add an entry with `id`, `command`, `args`, and `env` to the space's `mcpServers` array. Use absolute paths to Node and the entry point when the portal runs with a different PATH.
`BIGQUERY_BILLING_PROJECT` pays for query jobs. Tables in SQL should use fully qualified names, so the data can live in another project in the same location. `BIGQUERY_SOURCES` is an optional JSON map of dataset labels for the agent's guidance. Google IAM determines data access. `BIGQUERY_MAX_BYTES_BILLED` defaults to 10 GiB per query and `BIGQUERY_TIMEOUT_MS` defaults to 180 seconds per CLI invocation.
## Ask the agent
> Open BigQuery setup and tell me which access I need. Then check access with SELECT 1 and count daily events in my beta dataset for a completed date.
- `bigquery_setup` returns the connection checklist, configured datasets, sample SQL and troubleshooting. It works before authentication.
- `bigquery_query` accepts one GoogleSQL SELECT or WITH statement. The default result limit is 100 rows, with a maximum of 1,000. The per-call byte cap can only lower the configured cap. Running a query creates a billable BigQuery job. Results are returned to the calling MCP client.
Prefer the completed GA4 daily export when both daily and intraday tables exist for the same date. Use intraday data as provisional when no daily table is available. Restrict date ranges and select only the fields needed.
Run `npm test` to verify MCP discovery and the query runner with a simulated Cloud Shell.
TDQS
Scored across 2 tools
The two tools have clearly distinct roles: bigquery_setup handles configuration, access, and onboarding, while bigquery_query executes SQL. The setup description's mention of a first query is instructional, not an overlapping execution capability, so an agent can easily choose correctly.
Both tools use the same bigquery_ prefix and snake_case noun/action style. The naming pattern is predictable and consistent.
Two tools is thin for a BigQuery analytics server, even a minimal read-only one. Setup plus query covers the core flow, but the surface feels under-scoped compared with typical 3-15 tool servers.
The server covers the essential read-only analytics lifecycle: configure access, discover sources, and run SELECT/WITH queries. Minor gaps exist around schema introspection and dry-run/validation, though agents can work around these using INFORMATION_SCHEMA queries.