Skip to main content
Glama

get-billing-info

Retrieve billing details for Google Cloud Platform projects to monitor costs and manage cloud spending.

Instructions

Get billing information for the current project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoProject ID to get billing info for (defaults to selected project)

Implementation Reference

  • Handler function that executes the 'get-billing-info' tool: parses input, checks selected project, uses CloudBillingClient to fetch project billing info and account details, handles errors, returns JSON response.
    } else if (name === "get-billing-info") {
      const { projectId } = GetBillingInfoSchema.parse(args);
      const targetProject = projectId || selectedProject;
      
      if (!targetProject) {
        return createTextResponse("No project selected. Please select a project first.");
      }
    
      try {
        const billingClient = new CloudBillingClient();
        const [billingInfo] = await billingClient.getProjectBillingInfo({
          name: `projects/${targetProject}`
        });
    
        if (!billingInfo.billingEnabled) {
          return createTextResponse("Billing is not enabled for this project.");
        }
    
        const billingAccount = billingInfo.billingAccountName;
        if (!billingAccount) {
          return createTextResponse("No billing account associated with this project.");
        }
    
        // Get billing account details
        const [account] = await billingClient.getBillingAccount({
          name: billingAccount
        });
    
        return createTextResponse(JSON.stringify({
          projectId: targetProject,
          billingEnabled: billingInfo.billingEnabled,
          billingAccountName: billingAccount,
          displayName: account.displayName,
          open: account.open
        }, null, 2));
      } catch (error: any) {
        console.error('Error getting billing info:', error);
        if (error.code === 7) {
          return createTextResponse("Error: Cloud Billing API is not enabled. Please enable it in the Google Cloud Console.");
        }
        return createTextResponse(`Error getting billing info: ${error.message}`);
      }
  • index.ts:125-138 (registration)
    Registration of the 'get-billing-info' tool in the list-tools handler, defining its name, description, and input schema.
    {
      name: "get-billing-info",
      description: "Get billing information for the current project",
      inputSchema: {
        type: "object",
        properties: {
          projectId: {
            type: "string",
            description: "Project ID to get billing info for (defaults to selected project)",
          },
        },
        required: [],
      },
    },
  • Zod validation schema for the input arguments of the 'get-billing-info' tool.
    const GetBillingInfoSchema = z.object({
      projectId: z.string().optional(),
    });
  • Import of CloudBillingClient used in the get-billing-info handler.
    import { CloudBillingClient } from '@google-cloud/billing';

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool retrieves billing info but does not disclose whether it is read-only, what data is included, required permissions, or potential costs. Minimal behavioral context.

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?

Single sentence, no wasted words. However, it is so minimal that it omits potentially useful details; conciseness is good but not excellent given the lack of additional context.

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

Completeness2/5

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

No output schema, yet the description does not explain what billing information is returned (e.g., fields, format). With sibling billing tools, more context would help differentiate. Incomplete for typical agent needs.

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% (the only parameter 'projectId' is described clearly). The description adds no extra meaning beyond the schema, so baseline score of 3 applies.

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 action ('Get billing information') and the target resource ('current project'). It distinguishes from siblings like get-billing-budget and get-cost-forecast by not mentioning budgets or forecasts, but does not explicitly differentiate.

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 like get-billing-budget or get-cost-forecast. The description implies it is for general billing info, but fails to specify scenarios or exclusions.

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