Appearance
Querying your data over MCP
Four tools reach the BigQuery data sources of your organization. They are read-only: nothing they run can change data. A data connection used for event tracking only is never offered to them, nor to agents or playbook steps: it is a place Studio writes to, not a source to answer questions from.
| Tool | Use it when |
|---|---|
list_data_sources | You want to know which tables exist, their columns and how fresh the data is |
describe_table | You are about to query a table and need its meaning, reporting rules and pitfalls |
query_insights | You have a plain-language question and want the server to write the SQL |
query_sql | You can write BigQuery SQL yourself and have read the table with describe_table |
How query_insights answers
- If your organization has more than one data connection and you passed no
data_source, a small, fast model picks the connection. - The server builds the prompt: the column schema, the date anchors, and the rules from the table pages of the tables your question is about. Tables named in the question, then tables with columns the question uses, come first.
- A fast model writes the SQL.
- The SQL goes through the checks below. BigQuery plans the query first, which is free.
- If the SQL is rejected, or fails fast with a fixable error such as a division by zero, a stronger model rewrites it. It sees the SQL it wrote and the error. This happens at most twice, and the query runs at most twice, so a slow, legitimate query keeps its time.
- For small results, a last call to the same fast model suggests follow-up questions, within a few seconds. If it is slow or fails, the answer is returned without suggestions.
- The rows come back with the interpretation, the assumptions, the suggestions and the freshness of the data.
Every model call above (routing, writing, repair and suggestions) falls back to an alternative model when the primary model is overloaded or unavailable, unless fallback is switched off for your organization. A repair after a failed attempt is a separate step on the stronger model; the fallback only covers outages.
Every query, whether from query_insights, query_sql, an agent or a playbook step, passes the same checks before it executes:
- BigQuery itself must classify the statement as a
SELECT. Anything else, such as creating a table or exporting data, is refused. - Every table the query would read must be one of your allowed tables, or a table behind an allowed view. A table outside them is refused, however it is written.
- The estimated scan must fit the byte limit of the data source.
- If the check itself cannot be performed, the query is refused rather than run.
schema_question
A question about the catalogue ("which tables exist?", "is there a table with discounts?") is not a question about the data. query_insights answers it with error_code: "schema_question" and a message that points to list_data_sources and describe_table. Nothing is queried. It is not a failure: use the two tools instead.
query_sql
Send one SELECT statement and, when your organization has more than one data connection, a data_source. A table name without a dataset is qualified for you.
| Parameter | Required | Description |
|---|---|---|
sql | yes | One BigQuery SELECT statement |
data_source | with 2+ connections | A source name from list_data_sources |
limit | no | Maximum rows (default 500, maximum 5000) |
A refused or invalid query returns an error carrying BigQuery's own message, for example Unrecognized name: x at [1:8]. Fix the SQL and call again. Rows, truncated, data_freshness and warnings are returned as for query_insights; pass the warnings on with the answer.