Obtain a short-lived OAuth2 access token for a service account with bigquery.jobs.create and bigquery.tables.getData permissions.
POST to https://bigquery.googleapis.com/bigquery/v2/projects/{projectId}/queries with body {"query": "SELECT ...", "useLegacySql": false, "timeoutMs": 30000}.
If the response jobComplete is true, rows are returned inline; if false, use the returned jobReference.jobId to poll jobs.getQueryResults.
Call GET /bigquery/v2/projects/{projectId}/queries/{jobId}?timeoutMs=10000 in a loop until jobComplete is true, then paginate through rows using pageToken if present.
Parse the schema field from the response alongside rows; each row is an array of f objects with a v value field matching the schema columns in order.
Known gotchas
jobs.query is intended for interactive queries; for very large results use jobs.insert with a destination table and then tabledata.list to avoid response size limits.
useLegacySql defaults to true in some older client versions; always explicitly set it to false to use standard SQL syntax.
The access token must be refreshed before expiry; a 401 mid-pagination will abort result retrieval.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp