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."""

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.2/5.0
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It mentions a return status but omits that deletion is a destructive, likely irreversible action that may require specific IAM permissions and could affect attached resources like persistent disks. No warnings or side-effect information is provided.

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 docstring is well-structured with separate sections for Description, Args, and Returns. It is concise, with no redundant content, and each section directly contributes to understanding the tool's usage.

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?

The description covers the basic action and parameters but lacks critical context for a destructive operation. It does not mention that deletion is permanent, necessary permissions, behavior for running instances, or impact on associated disks. The return message is mentioned, but this alone is insufficient for a delete operation with no annotations or output schema.

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?

The schema has zero descriptions, so the description compensates by listing each parameter with a brief explanation and including an example for zone ('us-central1-a'). However, the explanations are largely restatements of the parameter names and add minimal depth beyond what a user would infer.

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 'Delete a Compute Engine instance' with a specific verb and resource. It distinguishes from sibling operations like start_instance, stop_instance, get_instance_details, and create_instance by specifying the delete action.

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 does not provide any guidance on when to use this tool over alternatives, such as prerequisites (e.g., stopping the instance first) or conditions where deletion might not be appropriate. No explicit exclusions or alternative tool references are given.

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