Skip to main content
Glama

get-billing-info

Retrieve billing details for a specific Google Cloud Platform project by providing the project ID, defaulting to the currently selected project if none is specified.

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

  • The handler function that executes the get-billing-info tool. It parses input, checks project, uses CloudBillingClient to fetch project billing info and account details, 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}`); }
  • Zod schema used for input validation in the get-billing-info handler.
    const GetBillingInfoSchema = z.object({ projectId: z.string().optional(), });
  • index.ts:125-138 (registration)
    Tool registration in the list-tools response, including 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: [], }, },
  • Input schema defined in the tool registration for get-billing-info.
    inputSchema: { type: "object", properties: { projectId: { type: "string", description: "Project ID to get billing info for (defaults to selected project)", }, }, required: [], },
  • Import of CloudBillingClient used by 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