Skip to main content
Glama
code-alchemist01

MCP Cloud Services Server

gcp_list_compute_instances

List all Compute Engine instances in a specified GCP project and region to manage cloud resources.

Instructions

List all Compute Engine instances in GCP

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoGCP project ID
regionNoGCP regionus-central1

Implementation Reference

  • Core handler implementation that lists GCP Compute Engine instances by fetching zones, listing VMs per zone, and extracting detailed instance information including IPs, status, machine type, etc.
    async listComputeInstances(): Promise<GCPComputeInstance[]> {
      await this.initializeClients();
      if (!this.compute) throw new Error('Compute client not initialized');
    
      try {
        const instances: GCPComputeInstance[] = [];
        const [zones] = await this.compute.getZones();
    
        for (const zone of zones) {
          const zoneName = zone.name || '';
          const vm = this.compute.zone(zoneName);
          const [vms] = await vm.getVMs();
    
          for (const instance of vms) {
            const networkInterfaces = instance.networkInterfaces || [];
            const privateIp = networkInterfaces[0]?.networkIP;
            const publicIp = networkInterfaces[0]?.accessConfigs?.[0]?.natIP;
    
            instances.push({
              id: instance.id?.toString() || instance.name || '',
              type: 'instance',
              name: instance.name || '',
              projectId: this.projectId,
              zone: zoneName,
              region: this.extractRegion(zoneName),
              status: this.mapInstanceStatus(instance.status),
              machineType: this.extractMachineType(instance.machineType || ''),
              image: this.extractImage(instance.disks?.[0]?.initializeParams?.sourceImage || ''),
              privateIp,
              publicIp,
              creationTimestamp: instance.creationTimestamp ? new Date(instance.creationTimestamp) : undefined,
              labels: instance.labels,
            });
          }
        }
    
        return instances;
      } catch (error) {
        throw new Error(`Failed to list compute instances: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Tool handler case within handleGCPTool function that invokes the GCPAdapter's listComputeInstances and formats the output for the MCP response.
    case 'gcp_list_compute_instances': {
      const instances = await adapter.listComputeInstances();
      return {
        total: instances.length,
        instances: instances.map((inst) => ({
          id: inst.id,
          name: inst.name,
          machineType: inst.machineType,
          zone: inst.zone,
          region: inst.region,
          status: inst.status,
          privateIp: inst.privateIp,
          publicIp: inst.publicIp,
        })),
      };
    }
  • Input schema and metadata definition for the gcp_list_compute_instances tool, specifying parameters for projectId and optional region.
    {
      name: 'gcp_list_compute_instances',
      description: 'List all Compute Engine instances in GCP',
      inputSchema: {
        type: 'object',
        properties: {
          projectId: {
            type: 'string',
            description: 'GCP project ID',
          },
          region: {
            type: 'string',
            description: 'GCP region',
            default: 'us-central1',
          },
        },
      },
    },
  • src/server.ts:19-27 (registration)
    Registration of all tools including gcpTools (which contains gcp_list_compute_instances) into the MCP server's tool list.
    const allTools = [
      ...awsTools,
      ...azureTools,
      ...gcpTools,
      ...resourceManagementTools,
      ...costAnalysisTools,
      ...monitoringTools,
      ...securityTools,
    ];
  • src/server.ts:68-69 (registration)
    Dispatch registration in the MCP server's CallToolRequest handler that routes calls to gcp_list_compute_instances to the specific GCP handler.
    } else if (gcpTools.some((t) => t.name === name)) {
      result = await handleGCPTool(name, args || {});
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states it lists instances but does not disclose behavioral traits such as pagination, rate limits, authentication needs, or what happens if no instances exist. This is a significant gap for a tool with no annotation coverage.

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 waste. It is front-loaded and appropriately sized for a simple listing tool, making it easy to parse quickly.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete. It lacks details on behavior, return values, error handling, or how it fits with siblings. For a tool with 2 parameters and no structured support, more context is needed to be fully helpful.

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 already documents both parameters (projectId and region). The description does not add any meaning beyond the schema, such as explaining parameter interactions or constraints, but it implies listing is scoped to GCP, which aligns with the schema.

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 ('Compute Engine instances in GCP'), making the purpose unambiguous. However, it does not differentiate from sibling tools like 'list_resources' or 'gcp_list_cloud_functions', which could also list GCP resources, so it misses full sibling distinction.

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?

No guidance is provided on when to use this tool versus alternatives. It does not mention sibling tools like 'list_resources' for broader listing or 'gcp_list_cloud_functions' for other GCP resources, nor does it specify prerequisites or exclusions, leaving usage context unclear.

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/code-alchemist01/Cloud-mcp_server'

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