How to Configure OpenAI Agents SDK Bigquery MCP Server

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up an openai agents sdk bigquery mcp server workflow, attach the tool server to your agent and pass cloud credentials. The agent then sends natural language prompts that turn into SQL queries against your warehouse. Most engineering teams start by creating one cloud service account for the tool server. They give that account broad read access across datasets so the agent can explore tables. This broad access creates a clear risk when the model builds and runs queries on its own. How the

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

To set up an openai agents sdk bigquery mcp server workflow, attach the tool server to your agent and pass cloud credentials. The agent then sends natural language prompts that turn into SQL queries against your warehouse. Most engineering teams start by creating one cloud service account for the tool server. They give that account broad read access across datasets so the agent can explore tables. This broad access creates a clear risk when the model builds and runs queries on its own.

How the openai agents sdk bigquery mcp server setup works

The agent framework uses the Model Context Protocol to talk to external data tools. In this setup, the agent runs in your app process and connects to the tool server. You register the server with the agent before starting a run. When a user asks a data question, the agent picks the database tool from its list. The server reads the table schemas so the model knows the column names and types. Then the model writes a SQL statement and sends it back through the protocol.

The tool server holds the cloud service account key or uses local default credentials. It logs in to the data warehouse as that single service identity. The warehouse checks if that service account can read the dataset in the query. If the role allows it, the warehouse runs the SQL and returns the rows. The tool server passes those raw rows right back into the agent context window. Finally, the model reads the data and writes an answer for the user.

What native roles solve and what they leave open

Cloud identity roles are built to control which service account can log in to a project. You can restrict the tool server account to read-only roles on specific datasets. This stops the agent from dropping tables or changing production records by mistake. You can also separate test datasets from production datasets using project boundaries. These steps are important for any team running automated queries.

Still, static cloud roles only check who logs in at the start of the request. They do not inspect what individual SQL statements do while in flight. Once a service account has read access to a table, every query can pull every row. An agent can write a query that scans millions of rows or pulls sensitive columns. If a table holds customer emails, phone numbers, or card numbers, the query returns them. The raw values go straight into the model prompt and third-party model logs.

BigQuery IAM + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why shared agent credentials complicate audits and data privacy

A shared service account also makes audit logs hard to read for security teams. When twenty users talk to the same agent, every query shows the same service account name. You cannot see which human user or task triggered a specific warehouse scan. If a bad prompt causes a massive data dump, you only see the server identity.

Teams often try to fix this by creating many custom views inside the warehouse. They build stripped-down views that leave out national IDs, emails, and phone numbers. Over time, maintaining dozens of views for different agents takes too much engineering work. When schema changes happen, these custom views break and stop the agent from working. Teams need a way to inspect queries and mask sensitive fields in results per request.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

How does the agent get permission to query tables?

The agent does not hold database permissions itself. Instead, the tool server uses a cloud service account role to log in and run queries.

Can a read-only role stop an agent from reading sensitive columns?

A standard dataset read role lets the server read all columns in those tables by default. Unless you set up column rules or masking, queries will return emails and card numbers.

Why do agent queries all look the same in warehouse logs?

The tool server uses one static credential for every request it sends to the warehouse. The database logs record that single service account instead of the person asking the question.

The query runs. The emails stay hidden.