Google Cloud bills are larger and more complex to understand. You get a PDF summary that says "Compute Engine: $5,000", but when you ask why, you're tasked with downloading a massive CSV or wrestling with the Google Cloud Billing Console's filters (at SKU's level).
For true FinOps visibility, most engineering teams turn to the Cloud Billing Export. This feature dumps every line item of your usage down to the SKU and timestamp into a BigQuery dataset. It is the single source of truth.
But here is the catch: querying that data requires complex SQL. You need to know that cost is in one column, credits are nested in a JSON array, and project.labels requires unnesting.
We need a better way. A user can just ask: "Why is the dev environment costing 20% more this week?"
To build this, we do not write 1,000 lines of SQL-generation code. Instead, we can use Google's Native BigQuery MCP Server with Gemini. Here is how I built a "FinOps for Everyone" agent (architecture design) that lets you chat directly with your raw billing data.
Native MCP:
The Model Context Protocol (MCP) is becoming the standard for connecting LLMs to data. Usually, you have to build an "MCP Server", a small app that sits between the LLM and your database.
But Google has done something different. They published a Native BigQuery MCP Server.
You don't deploy this server. You don't manage it. It is a public endpoint (https://bigquery.googleapis.com/mcp) that your agent connects to. It exposes BigQuery's capabilities (schema inspection, querying, job management) directly to the LLM as tools.
This changes everything. It means our FinOps agent is just a lightweight Python script. The heavy lifting of understanding the database structure is handled by the native protocol.
The Architecture:
Step 1: The Data Foundation (Billing Export)
Before writing code, you need the data.
- Go to the Google Cloud Console > Billing > Billing Export.
- Enable BigQuery Export.
- This creates a dataset (e.g.,
billing_export_v1_XXXX) that fills with raw usage data every few hours.
This is your gold mine. It contains every CPU cycle and storage byte you are paying for.
Step 2: The Agent Code
I used the Google Gen AI Agent Development Kit (google-adk). The critical piece is connecting to the native MCP URL.
Connecting to the Native Server
We don't need to define tools like execute_sql. We just tell the ADK to talk to the BigQuery MCP URL.
The "Anti-Hallucination" Prompt
The Billing Export schema is huge. If you ask Gemini to "show me costs," it might guess a column name like total_cost when the actual column is cost or usage.amount_in_pricing_units.
To fix this, I set strict instructions in the agent's system prompt:
System Instruction:
You are a FinOps Analyst. You have access to the BigQuery MCP tools.
Rule 1: Never guess column names.
Rule 2: Before answering a question, uselist_tablesto find the billing table, then useget_table_schemato see the actual columns.
Rule 3: Only then, write and execute the SQL query.
This "Look before you Leap" pattern makes the agent incredibly robust. If Google updates the export schema tomorrow, my agent adapts instantly because it reads the schema at runtime.
Step 3: Deployment (Local & Prod)
Running Locally (The "Analyst" Mode)
For ad-hoc analysis, I run this script on my laptop.
-
gcloud auth application-default login(This gives the script my user permissions). -
python agent.py - I chat with it: "Break down the cost of our AI/ML projects for the last 10 days by SKU."
Deploying to Prod (The "Team" Mode)
To let the whole team use it:
- Wrap the script in a Docker container.
- Deploy to Cloud Run.
- Use the cloud run endpoint as an endpoint MCP server (also, we can leverage Agent Engine pattern for this deployment)
Now, anyone in the internal slack/chat portal can ask cost questions without needing BigQuery IAM access—the agent acts as the secure gateway.
Why This is the Future of FinOps
We are moving past static dashboards. Dashboards answer questions you asked yesterday. Agents answer the questions you have today.
By using the Native BigQuery MCP Server, we get:
- Security: No database credentials stored in the app. It uses standard OAuth/IAM.
- Maintainability: Zero SQL parsing code. The MCP protocol handles the tool definitions.
- Depth: You aren't limited to pre-aggregated views. You are querying the raw export. If you want to know how much you spent on "Network Egress to Australia" at 2 AM on a Sunday, the data is there, and the agent can write the SQL to find it.
This is FinOps for everyone—democratizing cost data so engineers can own their cloud spend.
Tech Stack:
- Google Cloud Platform (GCP)
- BigQuery (BQ): Data warehouse for billing exports.
- Google Cloud Billing Export: Source of raw financial data.
- Model Context Protocol (MCP): Standard for LLM-tool interaction.
- Native BigQuery MCP Server: Google-managed endpoint exposing BigQuery capabilities.
- Gemini (e.g., Gemini 2.5 Flash): The Large Language Model powering the agent.
- Google ADK (Agent Development Kit): Python library for building agents and MCP client interactions.

Top comments (0)