Skip to main content
Glama

gcp_billing_info

Read-onlyIdempotent

Retrieve billing information and cost details for your GCP projects. Check current charges and expenses.

Instructions

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

Input Schema

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

Implementation Reference

  • The main handler function for gcp_billing_info tool. It queries GCP billing info using gcloud CLI (billing projects describe), retrieves budget information, and returns formatted text or JSON output.
    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 definition including name ('gcp_billing_info'), description, annotations, and JSON Schema input schema with optional project_id and format fields.
    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:88-89 (registration)
    Tool registration: gcpBillingInfoDefinition is added to the tools array sent via ListToolsRequestSchema.
      gcpBillingInfoDefinition,
    ];
  • src/index.ts:231-232 (registration)
    Tool dispatch in CallToolRequestSchema handler: routes 'gcp_billing_info' to call gcpBillingInfo(args).
    case 'gcp_billing_info':
      return await gcpBillingInfo(args as any) as CallToolResult;
  • src/index.ts:27-28 (registration)
    Import of gcpBillingInfoDefinition and gcpBillingInfo from ./gcp/billing.js module.
    import { gcpBillingInfoDefinition, gcpBillingInfo } from './gcp/billing.js';
    import { gcpSqlProxyDefinition, gcpSqlProxy } from './gcp/sqlProxy.js';
Behavior2/5

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

Annotations already mark the tool as readOnly, idempotent, and non-destructive. The description adds no additional behavioral context such as data freshness, authentication requirements, or rate limits. It merely restates the purpose.

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

Conciseness4/5

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

The description is concise (single line with keywords and sentence) and front-loaded with searchable terms. However, the pipe-separated keyword list could be cleaner, but overall it is brief and to the point.

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?

The description provides the core purpose but lacks details about the output format or the scope of billing data (e.g., time range, cost breakdown). With no output schema, agents may need more context to interpret results.

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% for both parameters (project_id and format). The tool description does not add any meaning beyond the schema, so baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states the tool retrieves GCP billing and cost information, using both Korean and English keywords. The title from annotations reinforces this. It is distinct from sibling tools which handle auth, logs, secrets, etc.

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?

No guidance on when to use this tool versus alternatives. The description does not provide any context on prerequisites, expected input, or comparison to other billing-related tools (though none exist among siblings).

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