GCP Billing Export MCP Server Installation Tutorial

May 9, 2026 ยท View on GitHub

โ† Back to Tutorials | Home


GCP Billing Export MCP Server Installation Tutorial

Tutorial 6 of 7 | โฑ๏ธ Time: 35-45 minutes | ๐Ÿ’ป Level: Intermediate

Last Updated: May 2026


๐ŸŽฏ What You'll Learn

  • Build and install the community GCP Billing Export MCP server from source
  • Configure the server with VS Code (Gemini Code Assist)
  • Set up the server with Google Gemini CLI
  • Query BigQuery billing data using natural language across multiple AI clients
  • Customize MCP server implementation for specific FinOps workflows

Introduction

This tutorial walks you through setting up the krzko/google-cloud-mcp community MCP server, which enables you to query your GCP billing data directly from BigQuery using AI clients like VS Code (Gemini Code Assist) and Google Gemini.

Unlike Google's official MCP servers (BigQuery, GKE, GCE, Google Maps), this community server is specifically optimized for FinOps use cases โ€” analyzing cloud costs, generating billing reports, and identifying optimization opportunities.

Choosing Between Official and Community GCP MCP Servers

There are two approaches to accessing GCP billing data through MCP servers:

Official MCP Server: Uses Google's MCP Toolbox for Databases with the --prebuilt bigquery option. This is a production-ready, officially maintained solution that works with Claude Desktop and requires minimal setup. You install a single binary and configure it with your GCP credentials. See Tutorial 05

Community MCP Server (This Tutorial): Uses the krzko/google-cloud-mcp community project, which requires building from source with Node.js and pnpm. This approach offers more customization options and works with multiple AI clients (VS Code, Google Gemini) but requires more setup steps.

FeatureOfficial (Toolbox)Community (krzko)
MaintenanceGoogle-maintainedCommunity-maintained
InstallationSingle binary downloadBuild from source (Node.js)
Setup ComplexityLow (3 steps)Medium (5+ steps)
Production Readyโœ… Yesโš ๏ธ Beta
Claude Desktopโœ… Native supportโœ… Supported
VS Code/GeminiโŒ Not applicableโœ… Supported
CustomizationPre-built toolsFull source access
UpdatesAutomatic with new releasesManual rebuild required

Recommendation: Start with the official Toolbox approach (Tutorial 05) for production use with Claude Desktop. Consider the community server (this tutorial) if you need multi-client support or want to customize the implementation.


What you'll learn:

  • How to install and build the GCP Billing Export MCP server
  • How to configure it with VS Code (Gemini Code Assist)
  • How to configure it with Google Gemini
  • How to query your GCP billing data using natural language

Prerequisites you'll need:

  • A GCP project with Billing Export to BigQuery enabled
  • gcloud CLI installed and authenticated
  • Node.js and pnpm package manager
  • VS Code with Gemini Code Assist extension (optional)
  • Access to Google Gemini (optional)

Note: This tutorial includes instructions for both Windows (PowerShell) and Linux/Mac (bash).


Step 1: Prerequisites

a. Enable GCP Billing Export to BigQuery

What is Billing Export? GCP Billing Export automatically sends your billing data to a BigQuery dataset, where it can be queried and analyzed. The MCP server reads from this dataset.

Check if already enabled:

  1. Go to Google Cloud Console
  2. Navigate to Billing โ†’ Billing Export
  3. Look for BigQuery export section

If not enabled, follow this guide:

GCP Billing Export Settings

Expected: Billing Export configured with a BigQuery dataset


b. Install Google Cloud CLI (gcloud)

What is gcloud CLI? The Google Cloud CLI lets you manage GCP resources from the command line and authenticate your MCP server.

Check if installed:

Windows PowerShell:

gcloud --version

Linux/Mac:

gcloud --version

If not installed:

gcloud CLI installation


c. Authenticate with Google Cloud

Why authenticate? The MCP server needs permissions to access your BigQuery billing data.

Authenticate using Application Default Credentials (ADC):

Windows PowerShell / Linux / Mac:

gcloud auth application-default login

This will open your browser to sign in with your Google account. Grant the requested permissions.

Verify authentication:

gcloud auth application-default print-access-token

Expected: A valid access token is printed.

gcloud authentication browser flow


d. Set Active GCP Project

Why set a project? The MCP server needs to know which GCP project contains your billing export dataset.

List your projects:

gcloud projects list

Set your active project:

gcloud config set project YOUR_PROJECT_ID

Important: Use a project where you have Owner or Editor permissions, or at least:

  • roles/billing.viewer
  • roles/bigquery.dataViewer on the billing export dataset

If you encounter permission errors:

  • Try using your "Default Gemini Project" (often named gen-lang-client-*)
  • Or create a dedicated project for MCP operations

gcloud project list and selection


e. Enable Required APIs

Enable BigQuery API:

gcloud services enable bigquery.googleapis.com

Verify API is enabled:

Windows PowerShell:

gcloud services list --enabled | Select-String bigquery

Linux/Mac:

gcloud services list --enabled | grep bigquery

BigQuery API enabled


f. Install Node.js and pnpm

What is Node.js? Node.js is required to build and run the MCP server.

What is pnpm? pnpm is a fast, disk-efficient package manager for Node.js projects.

Check if Node.js is installed:

node -v
npm -v

If not installed:

  • Download from: https://nodejs.org (choose LTS version)
  • Run installer with default settings
  • Restart terminal

Install pnpm:

npm install -g pnpm

Verify pnpm installation:

pnpm -v

Node.js and pnpm version check


Step 2: Install GCP Billing Export MCP Server

a. Clone the Repository

Why clone? This community MCP server is not available via npm or uvx. You need to clone the source code and build it locally.

Clone the repository:

git clone https://github.com/krzko/google-cloud-mcp.git
cd google-cloud-mcp

Git clone google-cloud-mcp


b. Install Dependencies

Install dependencies using pnpm:

pnpm install

Expected: Dependencies are installed without errors.

pnpm install output


c. Build the MCP Server

Build the server:

pnpm build

Expected: Build completes successfully, creating a dist/ directory with compiled JavaScript files.

Verify build output:

Windows PowerShell:

Get-ChildItem dist

Linux/Mac:

ls -la dist

You should see index.js and other compiled files.

pnpm build success


Step 3: Configure with VS Code (Gemini Code Assist)

What is Gemini Code Assist? Gemini Code Assist is a VS Code extension that integrates Google Gemini into your IDE, providing AI-powered code suggestions and assistance.

a. Install Gemini Code Assist Extension

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X or Cmd+Shift+X)
  3. Search for "Gemini Code Assist"
  4. Click Install

VS Code Gemini Code Assist extension


b. Open VS Code Settings JSON

Open User Settings (JSON):

  1. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
  2. Type "Open User Settings (JSON)"
  3. Press Enter

VS Code command palette open settings


c. Add MCP Server Configuration

Add the following configuration to your settings.json:

Replace <your-user> with your actual username (the path where you cloned the repository).

{
  "geminicodeassist.mcpServers": {
    "google-cloud-mcp": {
      "command": "node",
      "args": [
        "/Users/<your-user>/code/google-cloud-mcp/dist/index.js"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/Users/<your-user>/.config/gcloud/application_default_credentials.json"
      }
    }
  }
}

For Windows users:

  • Use Windows path format: C:\\Users\\<your-user>\\code\\google-cloud-mcp\\dist\\index.js
  • ADC path: C:\\Users\\<your-user>\\AppData\\Roaming\\gcloud\\application_default_credentials.json

Example for Windows:

{
  "geminicodeassist.mcpServers": {
    "google-cloud-mcp": {
      "command": "node",
      "args": [
        "C:\\Users\\jean\\code\\google-cloud-mcp\\dist\\index.js"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "C:\\Users\\jean\\AppData\\Roaming\\gcloud\\application_default_credentials.json"
      }
    }
  }
}

VS Code settings.json with MCP configuration


d. Reload VS Code

Reload VS Code to activate the MCP server:

  1. Press Ctrl+Shift+P (or Cmd+Shift+P)
  2. Type "Reload Window"
  3. Press Enter

Or simply restart VS Code.

VS Code reload window


e. Verify MCP Server is Active

Check Gemini Code Assist output:

  1. Open the Output panel (Ctrl+Shift+U or Cmd+Shift+U)
  2. Select "Gemini Code Assist" from the dropdown
  3. Look for messages indicating the MCP server has connected

Expected: You should see logs about google-cloud-mcp initialization.

VS Code output panel showing MCP connection


f. Test MCP Server in VS Code

Open a new file or chat with Gemini in VS Code:

Try this query:

What are my top 5 GCP services by cost over the past 30 days?

Expected: Gemini queries your BigQuery billing export and returns cost data.

VS Code Gemini querying GCP billing data


Step 4: Configure with Google Gemini (Web/Desktop)

What is Google Gemini? Google Gemini is Google's conversational AI platform, available via web interface and desktop app.

Important: Gemini supports MCP through the Gemini CLI or Vertex AI. For consumer Gemini (gemini.google.com), MCP support is limited and primarily available through the API.

This section covers configuration through the Gemini CLI (terminal-based agent).


a. Install Gemini CLI (if not already installed)

What is Gemini CLI? The Gemini CLI is an open-source agent that runs in your terminal and supports MCP natively.

Install Gemini CLI:

npm install -g @google/gemini-cli

Verify installation:

gemini --version

Gemini CLI installation


b. Create Gemini MCP Configuration File

Create Gemini config directory:

Windows PowerShell:

New-Item -Path "$env:USERPROFILE\.gemini" -ItemType Directory -Force

Linux/Mac:

mkdir -p ~/.gemini

Create or edit settings.json:

Windows PowerShell:

notepad $env:USERPROFILE\.gemini\settings.json

Linux/Mac:

nano ~/.gemini/settings.json

Creating Gemini settings directory


c. Add MCP Server Configuration

Add the following configuration:

Replace <your-user> with your actual username.

Linux/Mac:

{
  "mcpServers": {
    "google-cloud-mcp": {
      "command": "node",
      "args": [
        "/Users/<your-user>/code/google-cloud-mcp/dist/index.js"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/Users/<your-user>/.config/gcloud/application_default_credentials.json"
      }
    }
  }
}

Windows:

{
  "mcpServers": {
    "google-cloud-mcp": {
      "command": "node",
      "args": [
        "C:\\Users\\<your-user>\\code\\google-cloud-mcp\\dist\\index.js"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "C:\\Users\\<your-user>\\AppData\\Roaming\\gcloud\\application_default_credentials.json"
      }
    }
  }
}

Save the file.

Gemini settings.json configuration


d. Start Gemini CLI

Run Gemini:

gemini

Expected: Gemini CLI starts and loads the MCP server.

Verify MCP server is active:

/mcp list

You should see google-cloud-mcp in the list of available MCP servers.

Gemini CLI startup with MCP server


e. Test MCP Server with Gemini

Try these queries in Gemini CLI:

Query 1: Top services by cost

What are my top 5 GCP services by cost in the last 30 days?

Query 2: Cost trends

Show me a cost trend for Compute Engine over the past 90 days

Query 3: Regional breakdown

Break down my GCP costs by region for the current month

Expected: Gemini queries your BigQuery billing export and returns cost analysis.

Screenshot placeholder: Gemini CLI querying GCP billing data


Step 5: Troubleshooting Common Issues

Issue 1: Package Not Found

Error:

npm error 404 Not Found - GET https://registry.npmjs.org/@google%2fmcp-server-compute

Solution: This tutorial uses the community server krzko/google-cloud-mcp, not the official Google servers. Ensure you cloned the correct repository from https://github.com/krzko/google-cloud-mcp.


Issue 2: Permission Denied on GCP APIs

Error:

ERROR: (gcloud.services.enable) PERMISSION_DENIED: Permission denied to enable service [bigquery.googleapis.com]

Solution:

  1. Verify you're using a project where you have Owner or Editor permissions:

    gcloud projects get-iam-policy YOUR_PROJECT_ID \
      --flatten="bindings[].members" \
      --filter="bindings.members:user:YOUR_EMAIL"
    
  2. Try using your "Default Gemini Project":

    gcloud projects list
    # Look for project with name like "gen-lang-client-*"
    gcloud config set project gen-lang-client-XXXXXXXX
    
  3. If needed, create a new project for MCP operations with sufficient permissions.


Issue 3: Authentication Expired

Error:

ERROR: (gcloud.auth.application-default.print-access-token) There was a problem refreshing your credentials

Solution: Re-authenticate:

gcloud auth application-default login

Issue 4: MCP Server Not Connecting in VS Code

Solution:

  1. Check VS Code Output panel for errors:

    • Open Output (Ctrl+Shift+U)
    • Select "Gemini Code Assist" from dropdown
    • Look for connection errors
  2. Verify paths in settings.json are correct (use absolute paths)

  3. Ensure dist/index.js exists:

    ls google-cloud-mcp/dist/index.js
    
  4. Reload VS Code window:

    • Press Ctrl+Shift+P
    • Type "Reload Window"

Issue 5: No Billing Data Returned

Solution:

  1. Verify Billing Export is enabled and has data:

    • Go to BigQuery Console
    • Check your billing export dataset
    • Run a test query:
      SELECT * FROM `your-project.billing_dataset.gcp_billing_export_v1_*`
      LIMIT 10
      
  2. Ensure you're querying the correct project and dataset

  3. Check IAM permissions:

    • You need roles/bigquery.dataViewer on the billing dataset
    • You need roles/billing.viewer on the billing account

Step 6: Understanding the Architecture

Here's what you've just set up โ€” an MCP server connecting your AI client (VS Code or Gemini) to your GCP billing data in BigQuery:

flowchart TB
    subgraph Local["Your Computer"]
        Client["AI Client<br/>(VS Code / Gemini CLI)"]
        Config["MCP Config<br/>(settings.json)"]
        MCPServer["GCP Billing MCP Server<br/>(krzko/google-cloud-mcp)"]
        ADC["Application Default Credentials<br/>(gcloud auth)"]
    end

    subgraph GCP["Google Cloud Platform โ˜๏ธ"]
        IAM["IAM User/Service Account"]
        BQ["BigQuery<br/>Billing Export Dataset"]
        BillingAPI["Cloud Billing API"]
    end

    Client -- reads config --> Config
    Client -- invokes --> MCPServer
    MCPServer -- uses auth --> ADC
    ADC -- authenticates --> IAM
    MCPServer -- queries --> BQ
    MCPServer -- fetches metadata --> BillingAPI
    BQ -- returns cost data --> MCPServer
    MCPServer -- sends response --> Client

    %% style definitions
    classDef gcp fill:#4285F4,stroke:#000,color:#fff
    class IAM,BQ,BillingAPI gcp

Next Steps

Now that your GCP Billing MCP server is set up, you can:

  1. Build Custom FinOps Reports

    • Monthly cost summaries by service
    • Cost anomaly detection
    • Budget vs actual analysis
  2. Integrate with Other MCP Servers

    • Combine GCP billing data with AWS Cost Explorer
    • Cross-cloud cost comparison
    • Multi-cloud FinOps dashboards
  3. Automate Cost Optimization

    • Identify underutilized resources
    • Generate rightsizing recommendations
    • Track savings from optimizations
  4. Explore Other Google MCP Servers

    • Official Google MCP Servers (BigQuery, GKE, GCE, Google Maps)
    • Combine billing data with Compute Engine metrics
    • Analyze Kubernetes cluster costs


Congratulations! ๐ŸŽ‰

You've successfully set up the GCP Billing Export MCP server with both VS Code and Google Gemini. You can now leverage AI to analyze your GCP costs, generate reports, and identify optimization opportunities using natural language queries.


Having issues? Check the Troubleshooting section above or open an issue on the finops-mcp-resources repository.