MCP
data
BigQuery
Run read-only SQL against Google BigQuery datasets from inside your Leash app.
Requires Growth plan or above.
Connect BigQuery
Create a service account JSON key in Google Cloud Console → IAM → Service Accounts (grant BigQuery Data Viewer + BigQuery Job User), then paste the JSON on the BigQuery card at /dashboard/connections.
Example
Run a SQL query against a BigQuery public dataset and return rows.
app/api/top-names/route.ts
export async function GET() {const res = await fetch('https://leash.build/api/integrations/bigquery/query', {method: 'POST',headers: {'x-api-key': process.env.LEASH_API_KEY!,'content-type': 'application/json',},body: JSON.stringify({sql: `SELECT name, SUM(number) AS totalFROM \`bigquery-public-data.usa_names.usa_1910_2013\`WHERE state = 'CA' AND year >= 2000GROUP BY nameORDER BY total DESCLIMIT 5`,}),})const { data } = await res.json()// data =>// {// schema: [// { name: 'name', type: 'STRING' },// { name: 'total', type: 'INTEGER' }// ],// rows: [// { name: 'Daniel', total: 42117 },// { name: 'Anthony', total: 41008 },// ...// ],// totalRows: 5,// totalBytesProcessed: 7340032// }return Response.json(data)}
Available tools
query— run a read-only SQL statement and return rows.
Common gotchas
- Read-only by design.
INSERT,UPDATE,CREATE TABLEare rejected — service account scopes prevent writes. - Fully-qualify tables. Always use
`project.dataset.table`; default dataset is not set. - You pay per byte scanned. Filter on partition columns (
_PARTITIONDATE) and avoidSELECT *on large tables.
See the BigQuery SQL reference for the underlying provider docs.
Other languages: see SDK overview.