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';

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