AgentStack
MCP verified MIT Self-run

Gcp Cost Mcp Server

mcp-nozomi-koborinai-gcp-cost-mcp-server Β· by nozomi-koborinai

πŸ’° An MCP server that enables AI assistants to estimate Google Cloud costs, powered by Cloud Billing Catalog API and built with Genkit for Go

β€” No reviews yet
0 installs
18 views
0.0% view→install

Install

$ agentstack add mcp-nozomi-koborinai-gcp-cost-mcp-server

βœ“ scanned Β· βœ“ verified β€” works with Claude Code, Cursor, and more.

Security review

βœ“ Passed

No issues found. Passed automated security review. Β· v0.1.0 How review works β†’

  • βœ“ Prompt-injection patterns
  • βœ“ Secret / credential exfiltration
  • βœ“ Dangerous shell & filesystem operations
  • βœ“ Untrusted network calls
  • βœ“ Known-malicious package signatures

What it can access

  • βœ“ Network access No
  • βœ“ Filesystem access No
  • βœ“ Shell / process execution No
  • βœ“ Environment & secrets No
  • βœ“ Dynamic code execution No

From automated source analysis of v0.1.0. β€œUsed” means the capability is present in the source β€” more access means more to trust, not that it’s unsafe.

Are you the author of Gcp Cost Mcp Server? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

GCP Cost MCP Server

> Note: This is an unofficial project and is not affiliated with, endorsed by, or supported by Google or the Genkit team.

An MCP (Model Context Protocol) server for estimating Google Cloud running costs.

Instead of manually using the Google Cloud Pricing Calculator, you can get GCP cost estimates directly from AI assistants like Claude Desktop, Gemini CLI, or Cursor.

Features

Available Tools

| Tool | Description | |------|-------------| | get_estimation_guide | Start here! Dynamically generates estimation guides from SKU analysis for any GCP service | | list_services | Lists all available Google Cloud services with their IDs | | list_skus | Lists SKUs (billable items) for a specific service | | get_sku_price | Gets pricing details for a specific SKU | | estimate_cost | Calculates cost based on SKU and usage amount, with automatic free tier deduction |

Tool Relationships

Each tool is independent and stateless. AI assistants autonomously decide which tools to call and in what order based on context:

graph TB
    guide["get_estimation_guide─────────────────IN: service_nameOUT: required params, pricingfactors, free tier info, tips─────────────────Internally resolvesservice & SKU lookup"]

    services["list_services─────────────────IN: name filter (opt)OUT: service_id, display_name"]

    skus["list_skus─────────────────IN: service_id, region, keywordOUT: sku_id, display_name,categories, regions"]

    price["get_sku_price─────────────────IN: sku_id, currencyOUT: price/unit, pricing tiers"]

    cost["estimate_cost─────────────────IN: sku_id, usage_amountOUT: estimated cost withautomatic free tier deduction─────────────────Internally resolves pricing"]

    services -- "service_id" --> skus
    skus -- "sku_id" --> price
    skus -- "sku_id" --> cost

> Solid arrows show data flow β€” one tool's output feeds another's input. get_estimation_guide and estimate_cost are self-contained: they internally resolve their own dependencies, reducing round-trips.

| Use Case | How AI Uses the Tools | |----------|----------------------| | Quick estimate | get_estimation_guide β†’ gather user requirements β†’ estimate_cost | | Multi-service | Multiple get_estimation_guide + estimate_cost calls in parallel | | Explore pricing | list_services β†’ list_skus β†’ get_sku_price | | Direct calculation | estimate_cost with a known SKU ID |

Supported Services

get_estimation_guide works with any Google Cloud service:

  • Dynamic Guide Generation: Guides are generated dynamically by analyzing SKUs from the Cloud Billing Catalog API
  • Free Tier Information: Automatically fetched from GCP documentation and included in the guide
  • Universal Coverage: Works with all GCP services - no hardcoded service list

The tool analyzes available SKUs to determine:

  • Required parameters (region, instance type, storage, etc.)
  • Pricing factors and billing dimensions
  • Free tier quotas (when available)
  • Cost optimization tips

Quick Start

Prerequisites

  • Google Cloud SDK (gcloud) installed
  • Application Default Credentials configured

> Note: No Google Cloud project setup or API enablement is required. This server accesses public pricing data using OAuth authentication.

1. Set up Authentication

gcloud auth application-default login

2. Install

Choose the installation method that best fits your environment:

Option A: Homebrew (macOS/Linux) β€” Recommended

The easiest way to install on macOS or Linux:

brew tap nozomi-koborinai/tap
brew install gcp-cost-mcp-server

The binary will be installed to /opt/homebrew/bin/gcp-cost-mcp-server (Apple Silicon) or /usr/local/bin/gcp-cost-mcp-server (Intel/Linux).

Upgrading to the latest version:

# Update tap to fetch the latest Formula
brew update

# Check the available version
brew info gcp-cost-mcp-server

# Upgrade to the latest version
brew upgrade gcp-cost-mcp-server

> Note: Always run brew update first to ensure you get the latest version. Without it, Homebrew uses cached Formula information.

Option B: Download pre-built binary

Download from GitHub Releases for your platform:

| Binary | Platform | Architecture | |--------|----------|--------------| | gcp-cost-mcp-server-darwin-arm64 | macOS | Apple Silicon (M1/M2/M3/M4) | | gcp-cost-mcp-server-darwin-amd64 | macOS | Intel | | gcp-cost-mcp-server-linux-amd64 | Linux | x8664 | | gcp-cost-mcp-server-windows-amd64.exe | Windows | x8664 |

> macOS users: After downloading, remove the quarantine attribute: > ``bash > chmod +x gcp-cost-mcp-server-darwin-* > xattr -d com.apple.quarantine gcp-cost-mcp-server-darwin-* > ``

Option C: Build from source

Requires Go 1.21+:

git clone https://github.com/nozomi-koborinai/gcp-cost-mcp-server.git
cd gcp-cost-mcp-server
go build -o gcp-cost-mcp-server .

3. Configure Your MCP Client

Find your binary path first:

# If installed via Homebrew
which gcp-cost-mcp-server
# Output: /opt/homebrew/bin/gcp-cost-mcp-server (Apple Silicon)
#         /usr/local/bin/gcp-cost-mcp-server (Intel/Linux)
Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "gcp-cost": {
      "command": "/opt/homebrew/bin/gcp-cost-mcp-server"
    }
  }
}
Cursor

Add to .cursor/mcp.json in your project or global config:

{
  "mcpServers": {
    "gcp-cost": {
      "command": "/opt/homebrew/bin/gcp-cost-mcp-server"
    }
  }
}
Gemini CLI

Add to ~/.gemini/settings.json:

{
  "mcpServers": {
    "gcp-cost": {
      "command": "/opt/homebrew/bin/gcp-cost-mcp-server"
    }
  }
}

> Note: Replace /opt/homebrew/bin/gcp-cost-mcp-server with your actual binary path if different.

Usage Examples

Basic Cost Estimation (Conversational)

Start with a simple question - the AI will guide you through the details:

You: "How much would Cloud Run cost for 2 instances?"

AI: "To estimate Cloud Run costs accurately, I need a few more details:
    - Region: Where will this be deployed? (e.g., asia-northeast1, us-central1)
    - vCPU: How many vCPUs per instance? (e.g., 1, 2, 4)
    - Memory: How much memory per instance? (e.g., 1 GiB, 2 GiB)
    - Billing type: Instance-based or request-based?
    - Monthly usage: Will it run 24/7 (730 hours) or less?"

You: "Tokyo region, 1 vCPU, 2GB memory, instance-based, 24/7"

AI: "Based on your requirements for 2 Cloud Run instances in Tokyo (asia-northeast1):

    πŸ“Š Cost Breakdown:
    - vCPU: 2 vCPU Γ— 2,628,000 sec = 5,256,000 vCPU-seconds
      Free tier applied: -180,000 vCPU-seconds
      Billable: 5,076,000 vCPU-seconds Γ— $0.000024 = $121.82/month
    
    - Memory: 4 GiB Γ— 2,628,000 sec = 10,512,000 GiB-seconds
      Free tier applied: -360,000 GiB-seconds
      Billable: 10,152,000 GiB-seconds Γ— $0.0000025 = $25.38/month
    
    πŸ’° Total estimated: ~$147.20/month (free tier already applied)
    
    πŸ’‘ Tip: Cloud Run's free tier (180,000 vCPU-sec + 360,000 GiB-sec/month) 
       has been automatically deducted from your estimate."

Explore Services and SKUs

You: "What's the service ID for Compute Engine?"
You: "List the available SKUs for Compute Engine in Tokyo region"
You: "How much would an n2-standard-4 instance cost for 730 hours?"

Any GCP Service

All services work with dynamic guide generation:

You: "How much would Vertex AI cost for my ML training?"

AI: "I'll generate an estimation guide for Vertex AI by analyzing available SKUs...
    
    Based on my analysis, to estimate Vertex AI costs, I need:
    1. Region: Where will training run?
    2. Machine type: What accelerator type? (e.g., NVIDIA T4, A100)
    3. Training hours: How long will training take?
    4. Storage: How much training data?
    
    Free tier note: Vertex AI offers $300 in free credits for new users.
    
    Would you like me to list the specific SKUs available for Vertex AI?"

Architecture Diagram Estimation (Multi-Service)

Upload an architecture diagram and get a complete cost breakdown:

You: [Upload architecture diagram image]
     "Please estimate the monthly cost for this architecture"

AI: "I've analyzed your architecture diagram. Here are the GCP services identified:
     - Cloud Run (Application layer)
     - Cloud SQL (Database)
     - Cloud Storage (Static files)
     - Cloud Load Balancing (Traffic distribution)
     
     To provide an accurate estimate, I need some details:
     
     🌏 Common Settings:
     - Region: Is asia-northeast1 (Tokyo) okay?
     
     πŸ“¦ Cloud Run:
     - vCPUs: 1? 2? 4?
     - Memory: 1GB? 2GB? 4GB?
     - Instance count: How many instances?
     - Uptime: 24/7 or specific hours only?
     
     πŸ—„οΈ Cloud SQL:
     - Database type: MySQL? PostgreSQL?
     - Machine type: Dev (db-f1-micro)? Production (db-custom-2-4096)?
     - Storage: How many GB needed?
     - High Availability (HA): Required?"

You: "Tokyo region, Cloud Run with 1vCPU/2GB Γ— 2 instances running 24/7,
      Cloud SQL PostgreSQL db-custom-2-4096, 100GB SSD with HA,
      Cloud Storage 50GB Standard"

AI: "Thank you! Here's your estimate (free tiers automatically applied):

     | Service            | Configuration                  | Monthly Cost |
     |--------------------|--------------------------------|--------------|
     | Cloud Run          | 2 Γ— 1vCPU Γ— 2GB (24/7)         | $147.20 ✨   |
     | Cloud SQL          | PostgreSQL, 2vCPU/4GB, 100GB HA| $178.50      |
     | Cloud Storage      | 50GB Standard                  | $0.00 ✨     |
     | Cloud Load Balancing| Base + traffic                | $18.00       |
     | **Total**          |                                | **$343.70**  |
     
     ✨ = Free tier applied
     
     πŸ’‘ Cost Optimization Tips:
     - Cloud Run: Set min instances to 0 to reduce idle costs
     - Cloud SQL: Disable HA for ~50% savings (dev environments)
     - Consider 1yr/3yr Committed Use Discounts (CUDs) for up to 57% off"

This workflow:

  1. AI analyzes the architecture diagram to identify GCP services
  2. AI asks about shared parameters (region) first, then service-specific details
  3. AI calculates costs for each service using the MCP tools
  4. AI presents a consolidated breakdown with total and optimization tips

Authentication Options

Using Application Default Credentials (Recommended)

This is the simplest option for personal use:

gcloud auth application-default login

Using a Service Account

For production or automated environments, use a service account:

{
  "mcpServers": {
    "gcp-cost": {
      "command": "/path/to/gcp-cost-mcp-server",
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json"
      }
    }
  }
}

Required IAM Role (only for custom/contract pricing):

  • roles/billing.viewer (Billing Account Viewer)

> For public pricing data, no IAM roles are required.


Architecture

Project Structure

gcp-cost-mcp-server/
β”œβ”€β”€ main.go                      # Entry point, tool registration
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ freetier/                # Free tier information retrieval
β”‚   β”‚   β”œβ”€β”€ service.go           # FreeTierService with 24h cache
β”‚   β”‚   β”œβ”€β”€ search.go            # DuckDuckGo search client
β”‚   β”‚   β”œβ”€β”€ scraper.go           # GCP documentation scraper
β”‚   β”‚   └── patterns.go          # Regex patterns for extraction
β”‚   β”œβ”€β”€ pricing/
β”‚   β”‚   └── client.go            # Cloud Billing Catalog API client
β”‚   β”œβ”€β”€ tools/
β”‚   β”‚   β”œβ”€β”€ get_estimation_guide.go  # Dynamic guide generator
β”‚   β”‚   β”œβ”€β”€ estimate_cost.go         # Cost calc + free tier
β”‚   β”‚   β”œβ”€β”€ list_services.go
β”‚   β”‚   β”œβ”€β”€ list_skus.go
β”‚   β”‚   └── get_sku_price.go
β”‚   └── mcp/
β”‚       └── server.go            # MCP server wrapper

Tool Design

flowchart TB
    subgraph MCP["MCP Server Tools"]
        direction TB

        Guide["get_estimation_guide─────────────────‒ Dynamic SKU analysisβ€’ Free tier info includedβ€’ Self-contained"]

        Services["list_services─────────────────Returns: service IDs"]
        SKUs["list_skus─────────────────Returns: SKU IDs, regions"]
        Price["get_sku_price─────────────────Returns: price/unit, tiers"]
        Cost["estimate_cost─────────────────‒ Auto free tier deductionβ€’ Tiered pricing supportβ€’ Self-contained"]

        Services --> SKUs
        SKUs --> Price
        SKUs --> Cost
    end

    subgraph External["External Services"]
        Billing["Google Cloud Billing API v2betacloudbilling.googleapis.com"]
        Docs["GCP Documentation(for free tier info)"]
        DDG["DuckDuckGo Search(fallback for doc discovery)"]
    end

    MCP --> Billing
    Guide -.-> Docs
    Guide -.-> DDG
    Cost -.-> Docs
    Cost -.-> DDG

Data Flow

sequenceDiagram
    participant User
    participant AI as AI Assistant
    participant MCP as MCP Server
    participant API as Cloud Billing API
    participant Docs as GCP Docs
    
    User->>AI: "How much would Cloud Run cost?"
    AI->>MCP: get_estimation_guide("Cloud Run")
    MCP->>API: ListSKUs(Cloud Run)
    API-->>MCP: SKU list
    MCP->>Docs: Fetch free tier info
    Docs-->>MCP: Free tier data
    MCP-->>AI: Dynamic guide + free tier
    AI->>User: "I need: region, vCPU, memory..."
    
    User->>AI: "Tokyo, 1vCPU, 2GB, 24/7"
    AI->>MCP: list_services()
    MCP->>API: ListServices
    API-->>MCP: Service IDs
    AI->>MCP: list_skus(service_id)
    MCP->>API: ListSKUs
    API-->>MCP: SKU details
    AI->>MCP: estimate_cost(sku_id, usage)
    MCP->>MCP: Apply free tier deduction
    MCP-->>AI: Cost with free tier applied
    AI->>User: "Estimated: $147.20/month (free tier applied)"

Key Components

| Component | Description | |-----------|-------------| | getestimationguide | Dynamically generates guides by analyzing SKUs from Cloud Billing API. Includes free tier information fetched from GCP documentation. | | listservices | Queries the Cloud Billing API for all available services. Returns service IDs needed to query SKUs. | | listskus | Lists SKUs for a specific service. Filterable by region and category. | | getskuprice | Gets detailed pricing for a specific SKU. Supports multiple currencies (USD, JPY, EUR, etc.). | | estimate_cost | Calculates final cost with automatic free tier deduction. Handles tiered pricing calculations. | | FreeTierService | Fetches free tier information via DuckDuckGo search + GCP doc scraping. Caches results for 24 hours. |


Development

Build

go build -o gcp-cost-mcp-server .

Test

# Run all tests
go test -v ./...

# With coverage
go test -cover ./...

Test with MCP Inspector

npx @modelcontextprotocol/inspector ./gcp-cost-mcp-server

Cross-compile

# macOS (Apple Silicon)
GOOS=darwin GOARCH=arm64 go build -o dist/gcp-cost-mcp-server-darwin-arm64 .

# macOS (Intel)
GOOS=darwin GOARCH=amd64 go build -o dist/gcp-cost-mcp-server-darwin-amd64 .

# Linux (x86_64)
GOOS=linux GOARCH=amd64 go build -o dist/gcp-cost-mcp-server-linux-amd64 .

# Windows (x86_64)
GOOS=windows GOARCH=amd64 go build -o dist/gcp-cost-mcp-server-windows-amd64.exe .

Release Process

Releases are automated via GoReleaser and GitHub Actions.

To create a new release:

# 1. Create and push a tag
git tag v0.6.0
git push origin v0.6.0

This will automatically:

  1. Build binaries for all platforms (darwin/linux/windows, amd64/arm64)
  2. Create a GitHub Release with changelog
  3. Update the homebrew-tap Formula

**Prerequisites for homebrew-tap automat

…

Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source β€” we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet β€” be the first.

Versions

  • v0.1.0 Imported from the upstream source.