Skip to main content
Glama

delete_instance

Remove a Compute Engine instance on GCP by specifying the project ID, zone, and instance name. Returns a status message confirming deletion.

Instructions

    Delete a Compute Engine instance.
    
    Args:
        project_id: The ID of the GCP project
        zone: The zone where the instance is located (e.g., "us-central1-a")
        instance_name: The name of the instance to delete
    
    Returns:
        Status message indicating whether the instance was deleted successfully
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_nameYes
project_idYes
zoneYes

Implementation Reference

  • The delete_instance tool handler, registered via @mcp.tool() decorator, implements deletion of a GCP Compute Engine instance by calling the delete method on InstancesClient and polling the operation status.
    @mcp.tool()
    def delete_instance(project_id: str, zone: str, instance_name: str) -> str:
        """
        Delete a Compute Engine instance.
        
        Args:
            project_id: The ID of the GCP project
            zone: The zone where the instance is located (e.g., "us-central1-a")
            instance_name: The name of the instance to delete
        
        Returns:
            Status message indicating whether the instance was deleted successfully
        """
        try:
            from google.cloud import compute_v1
            
            # Initialize the Compute Engine client
            client = compute_v1.InstancesClient()
            
            # Delete the instance
            operation = client.delete(project=project_id, zone=zone, instance=instance_name)
            
            # Wait for the operation to complete
            operation_client = compute_v1.ZoneOperationsClient()
            
            # This is a synchronous call that will wait until the operation is complete
            while operation.status != compute_v1.Operation.Status.DONE:
                operation = operation_client.get(project=project_id, zone=zone, operation=operation.name.split('/')[-1])
                import time
                time.sleep(1)
            
            if operation.error:
                return f"Error deleting instance {instance_name}: {operation.error.errors[0].message}"
            
            return f"Instance {instance_name} in zone {zone} deleted successfully."
        except Exception as e:
            return f"Error deleting instance: {str(e)}"
  • The register_tools function where all compute tools, including delete_instance, are registered using @mcp.tool() decorators.
    def register_tools(mcp):
        """Register all compute tools with the MCP server."""
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a deletion operation (implying destructive mutation) but doesn't mention critical behaviors: whether deletion is permanent/irreversible, if it requires specific IAM permissions, what happens to attached resources (disks, IPs), or typical execution time. The return value description is vague ('status message').

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

Conciseness4/5

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

The description is appropriately sized and well-structured with clear sections (purpose, args, returns). Every sentence adds value, though the return statement could be more specific. The formatting with bullet-like sections enhances readability without unnecessary verbosity.

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?

For a destructive mutation tool with no annotations and no output schema, the description is incomplete. It lacks critical context: irreversible nature, permission requirements, side effects on attached resources, error conditions, and detailed return format. The sibling tool list shows many instance-related tools, but no comparison is provided.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must fully compensate. It provides clear semantic explanations for all three parameters: 'project_id' identifies the GCP project, 'zone' specifies location with an example, and 'instance_name' identifies the target instance. This adds essential meaning beyond the bare schema.

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

Purpose5/5

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

The description clearly states the specific action ('Delete') and resource ('a Compute Engine instance'), making the purpose unambiguous. It distinguishes this destructive operation from sibling tools like 'create_instance', 'start_instance', and 'stop_instance' that manipulate instances differently.

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 prerequisites (e.g., instance must be stopped), irreversible consequences, or compare with similar tools like 'delete_object' for storage or 'create_snapshot' for backup before deletion.

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

Related 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/henihaddad/gcp-mcp'

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