Skip to main content
Glama

create_snapshot

Generate a snapshot of a Compute Engine disk in Google Cloud Platform. Provide project ID, zone, disk name, and snapshot name to save disk data for backup or replication.

Instructions

    Create a snapshot of a Compute Engine disk.
    
    Args:
        project_id: The ID of the GCP project
        zone: The zone where the disk is located (e.g., "us-central1-a")
        disk_name: The name of the disk to snapshot
        snapshot_name: The name for the new snapshot
        description: Optional description for the snapshot
    
    Returns:
        Status message indicating whether the snapshot was created successfully
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNo
disk_nameYes
project_idYes
snapshot_nameYes
zoneYes

Implementation Reference

  • The core handler function for the 'create_snapshot' MCP tool. It uses the Google Cloud Compute API to create a snapshot from a specified disk, waits for completion, and returns success or error message.
    @mcp.tool()
    def create_snapshot(project_id: str, zone: str, disk_name: str, snapshot_name: str, description: str = "") -> str:
        """
        Create a snapshot of a Compute Engine disk.
        
        Args:
            project_id: The ID of the GCP project
            zone: The zone where the disk is located (e.g., "us-central1-a")
            disk_name: The name of the disk to snapshot
            snapshot_name: The name for the new snapshot
            description: Optional description for the snapshot
        
        Returns:
            Status message indicating whether the snapshot was created successfully
        """
        try:
            from google.cloud import compute_v1
            
            # Initialize the Disks client
            disks_client = compute_v1.DisksClient()
            
            # Create the snapshot request
            snapshot = compute_v1.Snapshot()
            snapshot.name = snapshot_name
            if description:
                snapshot.description = description
            
            # Create the snapshot
            operation = disks_client.create_snapshot(
                project=project_id,
                zone=zone,
                disk=disk_name,
                snapshot_resource=snapshot
            )
            
            # 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 creating snapshot {snapshot_name}: {operation.error.errors[0].message}"
            
            return f"Snapshot {snapshot_name} of disk {disk_name} in zone {zone} created successfully."
        except Exception as e:
            return f"Error creating snapshot: {str(e)}"
  • Registers the compute tools module, which includes the create_snapshot tool, by calling its register_tools function with the MCP server instance.
    compute_tools.register_tools(mcp)
  • The function that defines and registers all compute tools, including create_snapshot via decorators.
    def register_tools(mcp):
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 insight. It mentions the tool creates a snapshot and returns a status message, but lacks details on permissions required, whether the disk must be stopped, potential costs, rate limits, or error conditions.

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 well-structured with clear sections (purpose, args, returns) and uses bullet-like formatting. It's appropriately sized, though the 'Returns' section could be more specific about the status message format. Every sentence adds value without redundancy.

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?

For a mutation tool with 5 parameters, no annotations, and no output schema, the description is adequate but incomplete. It covers parameters well and states the basic action, but lacks critical context like behavioral constraints, error handling, or detailed output expectations, leaving gaps for safe agent operation.

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?

The description adds significant value beyond the schema's 0% coverage. It explains each parameter's purpose (e.g., 'zone: The zone where the disk is located'), clarifies optionality ('description: Optional description'), and provides an example ('e.g., "us-central1-a"'), fully compensating for the schema's lack of descriptions.

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 ('Create a snapshot') and resource ('Compute Engine disk'), distinguishing it from sibling tools like 'list_snapshots' or 'create_backup'. It precisely defines the tool's function without being tautological.

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. While it's clear this creates snapshots, there's no mention of prerequisites (e.g., disk must be stopped), limitations, or comparison to similar tools like 'create_backup' for other resources.

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