Skip to main content
Glama

get-billing-budget

Retrieve billing budgets for Google Cloud Platform projects to monitor and control cloud spending. Use this tool to access budget information and manage cost allocation across GCP services.

Instructions

Get billing budgets for the current project

Input Schema

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

Implementation Reference

  • index.ts:157-170 (registration)
    Registration of the 'get-billing-budget' tool in the ListTools response, including its name, description, and input schema.
    {
      name: "get-billing-budget",
      description: "Get billing budgets for the current project",
      inputSchema: {
        type: "object",
        properties: {
          projectId: {
            type: "string",
            description: "Project ID to get budgets for (defaults to selected project)",
          },
        },
        required: [],
      },
    },
  • Zod schema for validating input arguments to the 'get-billing-budget' tool.
    const GetBillingBudgetSchema = z.object({
      projectId: z.string().optional(),
    });
  • Handler function that executes the 'get-billing-budget' tool logic, fetching project billing info and listing budgets using CloudBillingClient and BudgetServiceClient.
    } else if (name === "get-billing-budget") {
      const { projectId } = GetBillingBudgetSchema.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.");
        }
    
        // Use the BudgetServiceClient to list budgets
        const budgetClient = new BudgetServiceClient();
        const [budgets] = await budgetClient.listBudgets({
          parent: billingAccount
        });
    
        interface Budget {
          name: string | null;
          displayName: string | null;
          amount: {
            units: string | null;
            currencyCode: string | null;
          };
          thresholdRules: Array<{
            thresholdPercent: number | null;
            spendBasis: string | null;
          }>;
        }
    
        const formattedBudgets = budgets.map((budget: any) => ({
          name: budget.name ?? null,
          displayName: budget.displayName ?? null,
          amount: budget.amount ? {
            units: budget.amount.units ?? null,
            currencyCode: budget.amount.currencyCode ?? null
          } : null,
          thresholdRules: budget.thresholdRules?.map((rule: any) => ({
            thresholdPercent: rule.thresholdPercent ?? null,
            spendBasis: rule.spendBasis ?? null
          })) ?? []
        }));
    
        return createTextResponse(JSON.stringify({
          projectId: targetProject,
          billingAccount: billingAccount,
          budgets: formattedBudgets
        }, null, 2));
      } catch (error: any) {
        console.error('Error getting billing budgets:', error);
        if (error.code === 7) {
          return createTextResponse("Error: Cloud Billing API or Cloud Billing Budgets API is not enabled. Please enable it in the Google Cloud Console.");
        }
        return createTextResponse(`Error getting billing budgets: ${error.message}`);
      }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what the tool does without behavioral details. It doesn't disclose if this is a read-only operation, requires specific permissions, has rate limits, or what the return format looks like. This is inadequate for a tool with zero annotation coverage.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste. It's appropriately sized for a simple tool and front-loaded with the core purpose.

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?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what 'billing budgets' entails, the return format, or behavioral aspects like error handling. For a tool in a billing context with siblings offering related functions, more context is needed.

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?

The schema has 100% description coverage, with the single parameter 'projectId' well-documented in the schema. The description adds no additional parameter semantics beyond implying it defaults to the current project, which is already covered in the schema. Baseline 3 is appropriate when the schema does the heavy lifting.

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') and resource ('billing budgets'), specifying it's for the current project. However, it doesn't distinguish this tool from sibling tools like 'get-billing-info' or 'get-cost-forecast', which likely provide related billing information but for different resources.

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 minimal guidance by mentioning 'for the current project', but offers no explicit when-to-use advice, no exclusions, and no alternatives. It doesn't help an agent decide between this tool and siblings like 'get-billing-info' or 'get-cost-forecast'.

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/RadiumGu/gcp-ops-mcp'

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