Skip to main content
Glama
krzko

Google Cloud MCP Server

by krzko

gcp-billing-get-account-details

Retrieve detailed information about a specific Google Cloud billing account by providing the billing account name. Use this tool to access billing data for management and analysis purposes.

Instructions

Retrieve detailed information about a specific Google Cloud billing account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
billingAccountNameYesBilling account name (e.g., 'billingAccounts/123456-789ABC-DEF012')

Implementation Reference

  • The handler function that executes the tool logic: fetches billing account details using Google Cloud Billing API client, formats the response using formatBillingAccount, and returns markdown-formatted text.
    async ({ billingAccountName }) => { try { const billingClient = getBillingClient(); logger.debug( `Getting billing account details for: ${billingAccountName}`, ); const [account] = await billingClient.getBillingAccount({ name: billingAccountName, }); if (!account) { return { content: [ { type: "text", text: `Billing account not found: ${billingAccountName}`, }, ], }; } const billingAccount: BillingAccount = { name: account.name || "", displayName: account.displayName || "Unknown", open: account.open || false, masterBillingAccount: account.masterBillingAccount, parent: account.parent, }; const response = formatBillingAccount(billingAccount); return { content: [ { type: "text", text: response, }, ], }; } catch (error: any) { logger.error(`Error getting billing account details: ${error.message}`); throw new GcpMcpError( `Failed to get billing account details: ${error.message}`, error.code || "UNKNOWN", error.status || 500, ); } },
  • The MCP tool registration call that defines the tool name, title, description, input schema, and associates the handler function.
    server.registerTool( "gcp-billing-get-account-details", { title: "Get Billing Account Details", description: "Retrieve detailed information about a specific Google Cloud billing account", inputSchema: { billingAccountName: z .string() .describe( "Billing account name (e.g., 'billingAccounts/123456-789ABC-DEF012')", ), }, }, async ({ billingAccountName }) => { try { const billingClient = getBillingClient(); logger.debug( `Getting billing account details for: ${billingAccountName}`, ); const [account] = await billingClient.getBillingAccount({ name: billingAccountName, }); if (!account) { return { content: [ { type: "text", text: `Billing account not found: ${billingAccountName}`, }, ], }; } const billingAccount: BillingAccount = { name: account.name || "", displayName: account.displayName || "Unknown", open: account.open || false, masterBillingAccount: account.masterBillingAccount, parent: account.parent, }; const response = formatBillingAccount(billingAccount); return { content: [ { type: "text", text: response, }, ], }; } catch (error: any) { logger.error(`Error getting billing account details: ${error.message}`); throw new GcpMcpError( `Failed to get billing account details: ${error.message}`, error.code || "UNKNOWN", error.status || 500, ); } }, );
  • Zod input schema defining the required 'billingAccountName' parameter.
    billingAccountName: z .string() .describe( "Billing account name (e.g., 'billingAccounts/123456-789ABC-DEF012')", ), },
  • Helper function to format BillingAccount object into a readable markdown string, used in the tool response.
    export function formatBillingAccount(account: BillingAccount): string { let result = `## ${account.displayName}\n\n`; result += `**Account Name:** ${account.name}\n`; result += `**Status:** ${account.open ? "✅ Active" : "❌ Closed"}\n`; if (account.masterBillingAccount) { result += `**Master Account:** ${account.masterBillingAccount}\n`; } if (account.parent) { result += `**Parent:** ${account.parent}\n`; } return result; }
  • Helper function to initialize and return the Google Cloud Billing client instance, used in the handler.
    export function getBillingClient(): CloudBillingClient { return new CloudBillingClient({ projectId: process.env.GOOGLE_CLOUD_PROJECT, }); }

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/krzko/google-cloud-mcp'

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