Token导航 LogoToken导航TokenDH.com
Gcp Cost MCP Server logo
运维云端stdio官方级别未说明来源级核验

Gcp Cost MCP Server

MCP Server

@modelcontextprotocol/inspector

一个用于估算Google Cloud运行成本的MCP服务器,可直接从AI助手获取GCP成本估算,支持动态生成估算指南和自动免费层级扣除。

工具数

5

提示词数

0

GitHub Stars

16

资源数

0
云计算GoClaudeClaude DesktopClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

nozomi-koborinai

提供方

nozomi-koborinai

最后核验

2026/5/17 20:20

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

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

详细介绍

GCP成本MCP服务器

备注:这是一个非官方项目,不隶属于谷歌或Genkit团队,也不得到谷歌或Genkit团队的认可或支持。

AI Workflow Pipeline with Genkit

用于估算Google Cloud运行成本的MCP(模型上下文协议)服务器。

而不是手动使用 谷歌云定价计算器,您可以直接从Claude Desktop、Gemini CLI或Cursor等AI助手获得GCP成本估算。

特性

可用工具

工具说明
get_estimation_guide从这里开始! 根据SKU分析为任何GCP服务动态生成估算指南
list_services列出所有可用的Google Cloud服务及其ID
list_skus列出特定服务的SKU(可计费项目)
get_sku_price获取特定SKU的定价详细信息
estimate_cost根据SKU和使用量计算成本, 自动扣除免费等级

工具关系

每个工具都是 独立和无国籍AI助手根据上下文自主决定调用哪些工具以及调用顺序:

graph TB
    guide["get_estimation_guide
─────────────────
IN: service_name
OUT: required params, pricing
factors, free tier info, tips
─────────────────
Internally resolves
service & SKU lookup"]

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

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

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

    cost["estimate_cost
─────────────────
IN: sku_id, usage_amount
OUT: estimated cost with
automatic free tier deduction
─────────────────
Internally resolves pricing"]

    services -- "service_id" --> skus
    skus -- "sku_id" --> price
    skus -- "sku_id" --> cost
实心箭头 显示数据流——一个工具的输出为另一个工具提供输入。 get_estimation_guideestimate_cost独立的:它们在内部解决了自己的依赖关系,减少了往返。
用例人工智能如何使用工具
快速估算get_estimation_guide → 收集用户需求→ estimate_cost
多业务多个 get_estimation_guide + estimate_cost 电话 并行
探索定价list_serviceslist_skusget_sku_price
直接计算estimate_cost 具有已知的SKU ID

支持服务列表

get_estimation_guide 与...合作 任何谷歌云服务:

  • 动态指南生成:通过分析云计费目录API中的SKU动态生成指南
  • 免费等级信息:自动从GCP文档中提取并包含在指南中
  • 普遍覆盖:适用于所有GCP服务-没有硬编码的服务列表

该工具分析可用SKU以确定:

  • 所需参数(区域、实例类型、存储等)
  • 定价因素和计费维度
  • 免费等级配额(如果可用)
  • 成本优化提示

快速开始

先决条件

  • 谷歌云SDK(gcloud)已安装
  • 已配置应用程序默认凭据
备注:无需设置Google Cloud项目或启用API。此服务器使用OAuth身份验证访问公共定价数据。

1.设置身份验证

gcloud auth application-default login

2.安装

选择最适合您环境的安装方法:

选项A:自制(macOS/Linux)——推荐

在macOS或Linux上安装的最简单方法:

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

二进制文件将安装到 /opt/homebrew/bin/gcp-cost-mcp-server (苹果硅)或 /usr/local/bin/gcp-cost-mcp-server (英特尔/Linux)。

升级到最新版本:

# 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
备注:始终运行 brew update 首先,确保您获得最新版本。如果没有它,Homebrew将使用缓存的配方信息。

选项B:下载预构建的二进制文件

下载自 对于您的平台:

二进制平台架构
gcp-cost-mcp-server-darwin-arm64macOS苹果硅(M1/M2/M3/M4)
gcp-cost-mcp-server-darwin-amd64macOS英特尔
gcp-cost-mcp-server-linux-amd64Linuxx86_64
gcp-cost-mcp-server-windows-amd64.exeWindowsx86_64
macOS用户:下载后,删除隔离属性: ``bash chmod +x gcp-cost-mcp-server-darwin-* xattr -d com.apple.quarantine gcp-cost-mcp-server-darwin-* ``

选项C:从源代码构建

需要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.配置您的MCP客户端

先找到你的二进制路径:

# 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)

克劳德桌面

增添 ~/Library/Application Support/Claude/claude_desktop_config.json:

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

光标

增添 .cursor/mcp.json 在您的项目或全局配置中:

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

Gemini CLI

增添 ~/.gemini/settings.json:

{
  "mcpServers": {
    "gcp-cost": {
      "command": "/opt/homebrew/bin/gcp-cost-mcp-server"
    }
  }
}
备注:替换 /opt/homebrew/bin/gcp-cost-mcp-server 如果不同,请使用实际的二进制路径。

使用示例

基本成本估算(对话式)

从一个简单的问题开始——人工智能将指导你完成细节:

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."

探索服务和SKU

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?"

任何GCP服务

所有服务均支持动态指南生成:

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?"

架构图估算(多服务)

上传架构图并获得完整的成本明细:

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"

此工作流程:

  1. AI分析架构图以识别GCP服务
  2. AI首先询问共享参数(地区),然后询问服务特定的详细信息
  3. AI使用MCP工具计算每项服务的成本
  4. AI提供了一个包含总体和优化提示的综合细分

身份验证选项

使用应用程序默认凭据(推荐)

这是个人使用的最简单的选择:

gcloud auth application-default login

使用服务帐户

对于生产或自动化环境,请使用服务帐户:

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

所需IAM角色 (仅适用于定制/合同定价):

  • roles/billing.viewer (账单账户查看器)
对于公开定价数据,不需要IAM角色。

______________________________________________________________________

建筑

项目结构

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

工具设计

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 v2beta
cloudbilling.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

数据流

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)"

关键组件

组件描述
get_estimation_guide通过分析云计费API的SKU动态生成指南。包括从GCP文档中获取的免费等级信息。
list_services查询云计费API中的所有可用服务。返回查询SKU所需的服务ID。
list_skus列出特定服务的SKU。可按地区和类别筛选。
get_sku_price获取特定SKU的详细定价。支持多种货币(美元、日元、欧元等)。
估算成本通过自动扣除免费等级来计算最终成本。处理分层定价计算。
FreeTier服务通过DuckDuckGo搜索+GCP文档抓取获取免费等级信息。将结果缓存24小时。

______________________________________________________________________

发展

构建

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

测试

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

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

使用MCP检查员进行测试

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

交叉编译

# 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 .

发布过程

通过以下方式自动发布 GoRelease GitHub Actions。

要创建新版本,请执行以下操作:

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

这将自动:

  1. 为所有平台构建二进制文件(darwin/linux/windows、amd64/arm64)
  2. 使用changelog创建GitHub版本
  3. 更新 自制水龙头 公式

自制水龙头自动化的先决条件:

  • GitHub个人访问令牌(PAT) repo 范围
  • 将其存储为 HOMEBREW_TAP_TOKEN 存储库中的机密

本地开发

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

# Run locally
./gcp-cost-mcp-server

# Test GoReleaser config (dry run)
goreleaser release --snapshot --clean

为什么选择Genkit for Go?

类型安全工具定义

Genkit自动从Go结构标签生成JSON模式,消除了手动模式定义:

// Genkit: Type-safe with auto-generated schema
genkit.DefineTool(g, "list_skus", "Lists SKUs for a service",
    func(ctx *ai.ToolContext, input struct {
        ServiceID string `json:"service_id" jsonschema_description:"The service ID"`
        PageSize  int    `json:"page_size,omitempty"`
    }) (*Output, error) {
        // Implementation
    })

自动MCP电桥

Genkit的MCP插件会自动从注册表中发现工具并将其转换为MCP格式,无需手动注册。

统一的生态系统

特点优点
Genkit用户界面在开发过程中直观地调试和测试工具
追踪自动执行跟踪和可观察性
AI模型集成与Gemini、Bedrock、OpenAI无缝连接
MCP主机使用同一代码库中的其他MCP服务器

刀具中断支持

Genkit的 ToolContext 为长时间运行的操作提供中断/恢复功能,这对用户确认流很有用。

面向未来

工具定义与以下工具定义相同:

  • MCP服务器工具(适用于Claude Desktop、Cursor、Gemini CLI)
  • Genkit Flow组件(用于AI代理工作流)
  • HTTP API端点(通过 genkit.Handler)

有关更多详细信息,请参阅 Genkit MCP插件文档.

许可证

MIT许可证

目录标签

目录标签

云计算GoClaude本地部署成本估算GoogleCloudAI集成自动化工具

支持客户端

Claude DesktopClaudeCursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

oauth

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

@modelcontextprotocol/inspector

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiooauth部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP