Skip to main content
Glama
krzko

Google Cloud MCP Server

by krzko

List Billing Account Projects

gcp-billing-list-projects

Retrieve all Google Cloud projects linked to a specific billing account to manage costs and track resource usage across your organization.

Instructions

List all projects associated with a specific Google Cloud billing account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
billingAccountNameYesBilling account name (e.g., 'billingAccounts/123456-789ABC-DEF012')
pageSizeNoMaximum number of projects to return (1-200)
pageTokenNoToken for pagination to get next page of results

Implementation Reference

  • The handler function for the 'gcp-billing-list-projects' tool. It uses the Cloud Billing API to list projects associated with a billing account, formats results as a Markdown table with project ID, billing status, and name, supports pagination, and handles errors.
    async ({ billingAccountName, pageSize, pageToken }) => {
      try {
        const billingClient = getBillingClient();
    
        logger.debug(
          `Listing projects for billing account: ${billingAccountName}`,
        );
    
        const request: any = {
          name: billingAccountName,
          pageSize,
        };
    
        if (pageToken) {
          request.pageToken = pageToken;
        }
    
        const [projects, nextPageToken] =
          await billingClient.listProjectBillingInfo(request);
    
        if (!projects || projects.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `No projects found for billing account: ${billingAccountName}`,
              },
            ],
          };
        }
    
        let response = `# Projects for Billing Account\n\n`;
        response += `**Billing Account:** ${billingAccountName}\n`;
        response += `**Projects Found:** ${projects.length}\n\n`;
    
        response += "| Project ID | Billing Enabled | Project Name |\n";
        response += "|------------|-----------------|-------------|\n";
    
        for (const project of projects) {
          const projectId = project.name?.replace("projects/", "") || "Unknown";
          const billingEnabled = project.billingEnabled ? "✅ Yes" : "❌ No";
          const projectName = project.name || "Unknown";
    
          response += `| ${projectId} | ${billingEnabled} | ${projectName} |\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 projects for billing account: ${error.message}`,
        );
        throw new GcpMcpError(
          `Failed to list projects for billing account: ${error.message}`,
          error.code || "UNKNOWN",
          error.status || 500,
        );
      }
    },
  • Input schema definition for the tool, using Zod for validation of billingAccountName (required), pageSize (1-200, default 50), and optional pageToken.
    {
      title: "List Billing Account Projects",
      description:
        "List all projects associated with a specific Google Cloud billing account",
      inputSchema: {
        billingAccountName: z
          .string()
          .describe(
            "Billing account name (e.g., 'billingAccounts/123456-789ABC-DEF012')",
          ),
        pageSize: z
          .number()
          .min(1)
          .max(200)
          .default(50)
          .describe("Maximum number of projects to return (1-200)"),
        pageToken: z
          .string()
          .optional()
          .describe("Token for pagination to get next page of results"),
      },
  • Registration of the tool with the MCP server using server.registerTool.
    server.registerTool(
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool lists projects but doesn't mention whether this is a read-only operation, requires specific permissions, has rate limits, or describes the return format (e.g., paginated results). The mention of 'all projects' implies completeness, but without behavioral details, this is insufficient for a mutation-free tool.

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 that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with zero waste, making it easy for an agent to parse quickly.

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 (list operation with 3 parameters) and high schema coverage (100%), the description is minimally adequate. However, with no annotations and no output schema, it lacks details on behavioral traits (e.g., read-only nature, permissions) and return values, which are important for a tool interacting with billing data.

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 all three parameters (billingAccountName, pageSize, pageToken). The description doesn't add any parameter semantics beyond what's in the schema, such as explaining the billing account name format or pagination behavior. This meets the baseline of 3 when schema coverage is high.

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 action ('List all projects') and resource ('associated with a specific Google Cloud billing account'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'gcp-billing-list-accounts' or 'gcp-billing-get-project-info', which reduces the score from a perfect 5.

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-accounts' (for listing billing accounts) or 'gcp-billing-get-project-info' (for detailed project information), leaving the agent with no context for tool selection.

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