Skip to main content
Glama

gcp_billing_info

Read-onlyIdempotent

Retrieve Google Cloud Platform project billing details and costs to monitor expenses and analyze spending patterns.

Instructions

과금 정보|비용 확인|요금|billing|cost|얼마 나왔어 - GCP 프로젝트 결제 정보와 비용을 조회합니다

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoGCP 프로젝트 ID (기본: 현재 설정된 프로젝트)
formatNo출력 형식 (기본: text)text

Implementation Reference

  • The main async handler function for the 'gcp_billing_info' tool. It queries GCP billing information using gcloud commands, handles permissions, fetches budget info, and formats output as text or JSON.
    export async function gcpBillingInfo(args: GcpBillingInfoArgs) {
      try {
        const projectId = await getProjectId(args.project_id);
    
        // Get billing account linked to project
        const billingCommand = `billing projects describe ${projectId} --format=json`;
        let billingInfo: any = {};
    
        try {
          const result = await executeGcloud(billingCommand, 15000);
          billingInfo = JSON.parse(result.stdout || '{}');
        } catch (error: any) {
          // Billing API might not be enabled or no permission
          if (error.type === 'PERMISSION_DENIED') {
            return {
              content: [
                {
                  type: 'text',
                  text: `❌ 결제 정보 조회 권한이 없습니다.\n\n필요한 역할: roles/billing.viewer\n\n💡 프로젝트 소유자에게 권한을 요청하거나,\nGCP Console에서 직접 확인해주세요:\nhttps://console.cloud.google.com/billing`,
                },
              ],
              isError: true,
            };
          }
          throw error;
        }
    
        const billingEnabled = billingInfo.billingEnabled === true;
        const billingAccountName = billingInfo.billingAccountName || 'N/A';
    
        // Try to get budget info if available
        let budgetInfo: any = null;
        try {
          const budgetCommand = `billing budgets list --billing-account=${billingAccountName.split('/').pop()} --format=json`;
          const budgetResult = await executeGcloud(budgetCommand, 15000);
          const budgets = JSON.parse(budgetResult.stdout || '[]');
          if (budgets.length > 0) {
            budgetInfo = budgets[0]; // Get first budget
          }
        } catch {
          // Budget API might not be enabled
        }
    
        const result = {
          project: projectId,
          billingEnabled,
          billingAccount: billingAccountName,
          budget: budgetInfo ? {
            displayName: budgetInfo.displayName,
            amount: budgetInfo.amount?.specifiedAmount?.currencyCode
              ? `${budgetInfo.amount.specifiedAmount.units} ${budgetInfo.amount.specifiedAmount.currencyCode}`
              : 'N/A',
          } : null,
        };
    
        if (args.format === 'json') {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        }
    
        const lines = [
          '💰 GCP 결제 정보',
          '',
          `📁 프로젝트: ${projectId}`,
          `${billingEnabled ? '✅' : '❌'} 결제 활성화: ${billingEnabled ? '예' : '아니오'}`,
          `💳 결제 계정: ${billingAccountName}`,
        ];
    
        if (budgetInfo) {
          lines.push('', '📊 예산 정보:');
          lines.push(`  이름: ${budgetInfo.displayName || 'N/A'}`);
          if (budgetInfo.amount?.specifiedAmount) {
            lines.push(`  금액: ${budgetInfo.amount.specifiedAmount.units} ${budgetInfo.amount.specifiedAmount.currencyCode}`);
          }
        }
    
        lines.push(
          '',
          '💡 상세 비용 확인:',
          `  https://console.cloud.google.com/billing/linkedaccount?project=${projectId}`,
          '',
          '📈 비용 분석:',
          '  https://console.cloud.google.com/billing/reports'
        );
    
        // Add tip for cost optimization
        lines.push(
          '',
          '💡 비용 절감 팁:',
          '  - Cloud Run: 최소 인스턴스 0으로 설정',
          '  - Cloud SQL: 사용하지 않을 때 중지',
          '  - Storage: 수명 주기 정책 설정',
          '  - Committed Use 할인 검토'
        );
    
        // hi-ai 연동 힌트 추가
        lines.push(getHiAiIntegrationHint('cost_alert'));
    
        return {
          content: [
            {
              type: 'text',
              text: lines.join('\n'),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: formatError(error),
            },
          ],
          isError: true,
        };
      }
    }
  • Tool schema definition for 'gcp_billing_info' including name, description, annotations, and inputSchema for MCP protocol compliance.
    export const gcpBillingInfoDefinition = {
      name: 'gcp_billing_info',
      description: '과금 정보|비용 확인|요금|billing|cost|얼마 나왔어 - GCP 프로젝트 결제 정보와 비용을 조회합니다',
      annotations: {
        title: 'GCP 결제 정보 조회',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
      inputSchema: {
        type: 'object' as const,
        properties: {
          project_id: {
            type: 'string',
            description: 'GCP 프로젝트 ID (기본: 현재 설정된 프로젝트)',
          },
          format: {
            type: 'string',
            enum: ['text', 'json'],
            description: '출력 형식 (기본: text)',
            default: 'text',
          },
        },
        required: [],
      },
    };
  • src/index.ts:77-89 (registration)
    Registration of all tools including gcpBillingInfoDefinition in the tools array used by MCP ListToolsRequestHandler.
    const tools = [
      gcpSetupDefinition,
      gcpLogsReadDefinition,
      gcpRunStatusDefinition,
      gcpRunLogsDefinition,
      gcpSqlQueryDefinition,
      gcpSqlProxyDefinition,
      gcpStorageListDefinition,
      gcpSecretListDefinition,
      gcpAuthStatusDefinition,
      gcpServicesListDefinition,
      gcpBillingInfoDefinition,
    ];
  • src/index.ts:231-232 (registration)
    Dispatch/execution routing for 'gcp_billing_info' tool in the MCP CallToolRequestHandler switch statement.
    case 'gcp_billing_info':
      return await gcpBillingInfo(args as any) as CallToolResult;
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=true, covering safety and idempotency. The description adds no behavioral traits beyond this, such as rate limits, authentication requirements, or data freshness. However, it doesn't contradict annotations, so it meets the lower bar with annotations present but adds minimal context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with a clear purpose statement, but the initial keyword list ('과금 정보|비용 확인|요금|billing|cost|얼마 나왔어') is verbose and unnecessary, reducing efficiency. The core sentence is concise, but overall structure could be improved by removing redundant elements.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (2 optional parameters, no output schema) and rich annotations (covering safety and idempotency), the description is minimally adequate. It states the purpose but lacks details on output format, error handling, or integration with sibling tools. Completeness is borderline, as it relies heavily on structured fields without supplementing them sufficiently.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters (project_id, format) well-documented in the schema. The description adds no parameter-specific information beyond what the schema provides, such as explaining the implications of the format choice or project_id defaults. Baseline 3 is appropriate as the schema carries the full burden.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'GCP 프로젝트 결제 정보와 비용을 조회합니다' (retrieves GCP project payment information and costs), which is a specific verb+resource combination. It distinguishes from siblings like gcp_logs_read or gcp_storage_list by focusing on billing data. However, the initial keyword list ('과금 정보|비용 확인|요금|billing|cost|얼마 나왔어') is redundant and doesn't enhance clarity, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication status), compare with other billing-related tools (none listed in siblings), or specify scenarios like checking recent charges versus historical data. Usage is implied through the purpose statement but lacks explicit context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/su-record/hi-gcloud'

If you have feedback or need assistance with the MCP directory API, please join our Discord server