Skip to main content
Glama
krzko

Google Cloud MCP Server

by krzko

gcp-billing-list-services

Retrieve a paginated list of Google Cloud services to facilitate billing insights and cost analysis, allowing users to manage and optimize cloud expenses effectively.

Instructions

List all available Google Cloud services for billing and cost analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageSizeNoMaximum number of services to return (1-200)
pageTokenNoToken for pagination to get next page of results

Implementation Reference

  • The main handler function for the 'gcp-billing-list-services' tool. It uses the Cloud Billing Catalog client to list services, formats them into a markdown table, handles pagination, and returns the response.
    async ({ pageSize, pageToken }) => { try { const catalogClient = getCatalogClient(); logger.debug( `Listing Google Cloud services with pageSize: ${pageSize}`, ); const request: any = { pageSize, }; if (pageToken) { request.pageToken = pageToken; } const [services, nextPageToken] = await catalogClient.listServices(request); if (!services || services.length === 0) { return { content: [ { type: "text", text: "No Google Cloud services found.", }, ], }; } let response = `# Google Cloud Services\n\n`; response += `Found ${services.length} service(s):\n\n`; response += "| Service ID | Display Name | Business Entity |\n"; response += "|------------|--------------|----------------|\n"; for (const service of services) { const cloudService: CloudService = { name: service.name || "", serviceId: service.serviceId || "Unknown", displayName: service.displayName || "Unknown", businessEntityName: service.businessEntityName || "Unknown", }; response += `| ${cloudService.serviceId} | ${cloudService.displayName} | ${cloudService.businessEntityName} |\n`; } if (nextPageToken) { response += `\n**Next Page Token:** ${nextPageToken}\n`; response += `Use this token with the same tool to get the next page of results.\n`; } return { content: [ { type: "text", text: response, }, ], }; } catch (error: any) { logger.error(`Error listing services: ${error.message}`); throw new GcpMcpError( `Failed to list services: ${error.message}`, error.code || "UNKNOWN", error.status || 500, ); }
  • The server.registerTool call that registers the 'gcp-billing-list-services' tool with the MCP server, including title, description, input schema, and handler reference.
    server.registerTool( "gcp-billing-list-services", { title: "List Google Cloud Services", description: "List all available Google Cloud services for billing and cost analysis", inputSchema: { pageSize: z .number() .min(1) .max(200) .default(50) .describe("Maximum number of services to return (1-200)"), pageToken: z .string() .optional() .describe("Token for pagination to get next page of results"), }, }, async ({ pageSize, pageToken }) => { try { const catalogClient = getCatalogClient(); logger.debug( `Listing Google Cloud services with pageSize: ${pageSize}`, ); const request: any = { pageSize, }; if (pageToken) { request.pageToken = pageToken; } const [services, nextPageToken] = await catalogClient.listServices(request); if (!services || services.length === 0) { return { content: [ { type: "text", text: "No Google Cloud services found.", }, ], }; } let response = `# Google Cloud Services\n\n`; response += `Found ${services.length} service(s):\n\n`; response += "| Service ID | Display Name | Business Entity |\n"; response += "|------------|--------------|----------------|\n"; for (const service of services) { const cloudService: CloudService = { name: service.name || "", serviceId: service.serviceId || "Unknown", displayName: service.displayName || "Unknown", businessEntityName: service.businessEntityName || "Unknown", }; response += `| ${cloudService.serviceId} | ${cloudService.displayName} | ${cloudService.businessEntityName} |\n`; } if (nextPageToken) { response += `\n**Next Page Token:** ${nextPageToken}\n`; response += `Use this token with the same tool to get the next page of results.\n`; } return { content: [ { type: "text", text: response, }, ], }; } catch (error: any) { logger.error(`Error listing services: ${error.message}`); throw new GcpMcpError( `Failed to list services: ${error.message}`, error.code || "UNKNOWN", error.status || 500, ); } }, );
  • Zod input schema defining parameters for pagination: pageSize (1-200, default 50) and optional pageToken.
    inputSchema: { pageSize: z .number() .min(1) .max(200) .default(50) .describe("Maximum number of services to return (1-200)"), pageToken: z .string() .optional() .describe("Token for pagination to get next page of results"), },

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