Skip to main content
Glama
krzko

Google Cloud MCP Server

by krzko

List Google Cloud Services

gcp-billing-list-services

Retrieve Google Cloud services for billing analysis to monitor costs. Use pagination to manage large datasets and identify service usage patterns.

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 CloudCatalogClient to list Google Cloud services, formats them into a markdown table, handles pagination, and returns the response in MCP format.
    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 tool schema defining title, description, and Zod input schema for pagination parameters (pageSize and pageToken).
    {
      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"),
      },
  • Registers the 'gcp-billing-list-services' tool on the MCP server within the registerBillingTools function.
      "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,
          );
        }
      },
    );
  • Helper function to initialize and return the Google Cloud Catalog client used by the tool handler to list services.
    export function getCatalogClient(): CloudCatalogClient {
      return new CloudCatalogClient({
        projectId: process.env.GOOGLE_CLOUD_PROJECT,
      });
    }
  • TypeScript interface defining the structure of a Google Cloud service object, used in the handler to type the formatted service data.
    export interface CloudService {
      name: string;
      serviceId: string;
      displayName: string;
      businessEntityName: string;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral disclosure. It implies a read-only operation (listing) but doesn't address authentication needs, rate limits, pagination behavior beyond what's in the schema, error conditions, or what format/services are returned. For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a simple listing tool, making it easy to parse quickly without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (simple list operation), 100% schema coverage, but no annotations and no output schema, the description is minimally complete. It states what the tool does but lacks behavioral context, usage guidance, and output details that would be helpful for an agent. It meets basic requirements but has clear gaps in a broader context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (pageSize with range/default, pageToken for pagination). The description adds no parameter-specific information beyond what's already in the structured schema, maintaining the baseline score of 3 for adequate but not enhanced parameter semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('all available Google Cloud services'), specifying the domain ('for billing and cost analysis'). It distinguishes from general service listing by focusing on billing context, but doesn't explicitly differentiate from sibling tools like 'gcp-billing-list-accounts' or 'gcp-billing-list-projects' beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'gcp-billing-list-skus' or 'gcp-billing-service-breakdown' that might overlap in billing analysis contexts, nor does it specify prerequisites, dependencies, or typical use cases beyond the generic 'billing and cost analysis' context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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