Skip to main content
Glama
sniper35
by sniper35

attach_volume

Attach a storage volume to a Verda Cloud GPU instance to expand capacity. Ensure the instance is shut down before attaching the volume.

Instructions

Attach a volume to an instance.

Note: The instance must be shut down first.

Args: volume_id: The ID of the volume to attach. instance_id: The ID of the instance to attach to.

Returns: Confirmation of attachment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
volume_idYes
instance_idYes

Implementation Reference

  • Main handler for the attach_volume MCP tool. Decorated with @mcp.tool(), this async function takes volume_id and instance_id as parameters, calls the client's attach_volume method, and returns a confirmation message.
    @mcp.tool()
    async def attach_volume(volume_id: str, instance_id: str) -> str:
        """Attach a volume to an instance.
    
        Note: The instance must be shut down first.
    
        Args:
            volume_id: The ID of the volume to attach.
            instance_id: The ID of the instance to attach to.
    
        Returns:
            Confirmation of attachment.
        """
        client = _get_client()
        await client.attach_volume(volume_id, instance_id)
        return f"Volume `{volume_id}` attached to instance `{instance_id}`."
  • Client method that performs the actual volume attachment by calling the underlying SDK's _volumes.attach method through the async sync wrapper.
    async def attach_volume(self, volume_id: str, instance_id: str) -> None:
        """Attach a volume to an instance.
    
        Note: Instance must be shut down.
        """
        self._ensure_client()
        await self._run_sync(self._volumes.attach, volume_id, instance_id)
  • Helper function _get_client() that provides access to the global VerdaSDKClient instance used by the handler.
    def _get_client() -> VerdaSDKClient:
        """Get the global Verda client instance."""
        global _client
        if _client is None:
            _client = get_client()
        return _client
  • Volume dataclass defining the schema for volume representation with fields: id, name, size_gb, status, and attached_to.
    @dataclass
    class Volume:
        """Simplified volume representation."""
    
        id: str
        name: str
        size_gb: int
        status: str
        attached_to: str | None
    
        @classmethod
        def from_sdk(cls, vol: Any) -> "Volume":
            """Create from SDK Volume object."""
            return cls(
                id=vol.id,
                name=getattr(vol, "name", ""),
                size_gb=getattr(vol, "size", 0),
                status=getattr(vol, "status", "unknown"),
                attached_to=getattr(vol, "instance_id", None),
            )

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/sniper35/verda-cloud-mcp'

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