Skip to main content
Back to the BigQuery MCP server

MCP Gateway · Codex

BigQuery icon

Connect BigQuery to Codex

A pull request that changes SQL is hard to review without the tables it touches. With BigQuery behind the Speakeasy MCP Gateway, Codex can confirm that referenced columns exist, read dataset metadata and run read-only comparisons while it reviews. Spend limits can block Codex traffic once a budget is reached, which helps when review runs many queries.

Category
Data & analytics
Tools
6
Authentication
OAuth
Codex
CLI and ChatGPT desktop app

Behind the MCP Gateway

Run BigQuery MCP behind the MCP Gateway

One URL for every agent, sign-in through your IdP, RBAC down to the tool, and every BigQuery call inspected and logged.

Deploy on MCP Gateway

Before you start

What BigQuery needs first

A Google Cloud project administrator with IAM admin access does the BigQuery side of the setup.

  • You need a Google Account that can administer the project and create OAuth credentials.
  • Granting roles needs IAM admin access, such as Project IAM Admin.
  • Billing is optional for initial setup.
  • External apps in Testing allow at most 100 test users, and authorizations expire after seven days.

In BigQuery

  1. Enable the BigQuery API in the project.
  2. Grant each user MCP Tool User, BigQuery Job User, and BigQuery Data Viewer.
  3. Configure the OAuth consent screen as Internal or External.
  4. For External apps, add the BigQuery scope and test users, or publish the app.
  5. Create an OAuth client and copy its credentials.
Full BigQuery setup guide in the docs

Set up

Add BigQuery to Codex in 4 steps

  1. 01

    Add BigQuery from the catalog

    An admin finds BigQuery in the MCP Catalog (MCP Gateway > MCP > Catalog) and clicks Add. Speakeasy registers the vendor's server as a remote MCP server and proxies sessions to it. Nothing is copied or re-hosted.

    BigQuery uses OAuth. Servers that support dynamic client registration get their OAuth configuration applied automatically.

    Where MCP-scoped policies are enabled, the install offers a recommended risk policy for the new server that detects secrets and PII and inspects tool requests and responses.

  2. 02

    Choose who can use BigQuery

    Give teams the mcp:connect scope on the BigQuery server through team access or a role. The organization gateway works out each person's servers from their live access, so granting access adds BigQuery to their gateway on the next call, and removing it takes it away.

  3. 03

    Connect Codex

    Add the gateway as an MCP server, then log in.

    Run the first command with your organization gateway URL.

    Run the second command to sign in.

    codex mcp add 'speakeasy' \
      --url 'https://<organization host>/mcp/gateway/<organization slug>'
    codex mcp login 'speakeasy'
  4. 04

    Sign in and use BigQuery from Codex

    The first time Codex connects, it opens a browser so the person can sign in to Speakeasy through your identity provider.

    BigQuery needs its own OAuth grant, so each person connects it once. Until they do, BigQuery calls fail while the rest of the gateway keeps working.

    From then on, BigQuery's tools appear in Codex, limited to what the person's access allows, and every call lands in the gateway's tool logs.

To roll it out to a team, a ChatGPT workspace admin imports the plugin marketplace under Admin > Plugins and sets an installation policy per role. Imported plugins reach nobody until a policy is set.

Use cases

What Codex users do with BigQuery

Review SQL against the real schema

Codex reads the metadata for each table a changed query references and flags columns or tables that aren't there before the change merges.

get_table_infolist_table_ids

Check a dataset's metadata

When a change moves data into a new dataset, Codex reads that dataset's metadata so reviewers can see what they're approving.

get_dataset_info

Compare old and new query output

Codex runs the old and new versions of a query read-only and summarizes how the results differ, so the reviewer sees the effect, not just the diff.

execute_sql_readonly

Tools

6 tools

Each BigQuery tool can be allowed or denied per team and role at the MCP Gateway before Codex sees it.

list_dataset_ids

List BigQuery dataset IDs in a Google Cloud project.

get_dataset_info

Get metadata information about a BigQuery dataset.

list_table_ids

List table ids in a BigQuery dataset.

get_table_info

Get metadata information about a BigQuery table.

execute_sql_readonly

Run a read-only SQL query in the project and return the result. Prefer this tool over execute_sql if possible.

execute_sql

Run a SQL query in the project and return the result. Prefer the execute_sql_readonly tool if possible.

Control

What Speakeasy can see and stop in Codex

The gateway covers every client the same way. The rest depends on what Codex exposes to Speakeasy.

Tool logs

Gateway

Every BigQuery call is logged with the person and the client that made it.

Access by role

Gateway

People reach only the BigQuery tools their team or role allows.

Request and response blocking

Gateway

A risk policy scoped to BigQuery can reject a tool request before it reaches the server, or withhold a result from Codex. MCP-scoped policies are enabled per organization.

Prompt and tool-call blocking

Codex

Agent hooks send each prompt and tool call to Speakeasy, which allows or denies it before Codex runs it.

User attribution

Codex

An [otel] block in ~/.codex/config.toml sends telemetry to Speakeasy. Export is off by default.

Budgets

Codex

Spend limits can block Codex traffic once a budget is reached.

Device agent and MDM

Codex

The device agent keeps Codex's configuration in sync on managed laptops.

  • Codex cloud tasks and GitHub code review run off the device. Neither the plugin nor OpenTelemetry covers them; OpenAI's Compliance Logs record them after the fact.
  • The workspace rollout needs a ChatGPT Business, Enterprise or Edu admin.

Questions

Frequently asked questions

Does Codex need its own Google credentials for BigQuery?
No. Agents never hold a BigQuery credential. Each session signs in through your identity provider, and access ends when the employee leaves the directory.
Are BigQuery queries from Codex cloud tasks covered?
Codex cloud tasks and GitHub code review run off the device, so neither the plugin nor OpenTelemetry covers them. OpenAI's Compliance Logs record them after the fact.
How do Codex users get BigQuery?
An admin adds BigQuery from the Speakeasy MCP Catalog and grants access by team or role. Add the gateway as an MCP server, then log in. Each person then sees only the BigQuery tools their access allows.
Are BigQuery calls from Codex logged?
Yes. BigQuery calls go through the MCP Gateway, which logs each tool call and attributes it to the person and the client that made it.

Connect more

BigQuery in other clients

AI everywhere.

Control here.