Skip to main content
Glama

get-cost-forecast

Forecast your Google Cloud Platform project costs by specifying a project ID and the number of months for prediction. Helps in planning and managing cloud expenses effectively.

Instructions

Get cost forecast for the current project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
monthsNoNumber of months to forecast (default: 3)
projectIdNoProject ID to get forecast for (defaults to selected project)

Implementation Reference

  • Handler function that implements the get-cost-forecast tool by retrieving and returning project billing account information.
    } else if (name === "get-cost-forecast") { const { projectId, months = 3 } = GetCostForecastSchema.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 cost forecast using Cloud Billing API const [costInfo] = await billingClient.getProjectBillingInfo({ name: `projects/${targetProject}` }); return createTextResponse(JSON.stringify({ projectId: targetProject, billingAccount: billingAccount, billingEnabled: costInfo.billingEnabled, currency: 'USD' }, null, 2)); } catch (error: any) { console.error('Error getting cost forecast:', 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 cost forecast: ${error.message}`); } } else if (name === "get-billing-budget") {
  • Zod schema used for input validation in the get-cost-forecast handler.
    const GetCostForecastSchema = z.object({ projectId: z.string().optional(), months: z.number().optional(), });
  • index.ts:139-156 (registration)
    Tool registration in the listTools response, including name, description, and input schema.
    { name: "get-cost-forecast", description: "Get cost forecast for the current project", inputSchema: { type: "object", properties: { projectId: { type: "string", description: "Project ID to get forecast for (defaults to selected project)", }, months: { type: "number", description: "Number of months to forecast (default: 3)", }, }, required: [], }, },

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