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
| Name | Required | Description | Default |
|---|---|---|---|
| volume_id | Yes | ||
| instance_id | Yes |
Implementation Reference
- src/verda_mcp/server.py:540-555 (handler)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}`." - src/verda_mcp/client.py:461-467 (helper)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) - src/verda_mcp/server.py:30-35 (helper)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 - src/verda_mcp/client.py:103-122 (schema)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), )