get_volume
Retrieve detailed information about a specific Oracle Cloud Infrastructure Block Storage volume, including size, performance tier, and backup policy, by providing its OCID.
Instructions
Get detailed information about a specific Block Storage volume.
Args:
volume_id: OCID of the volume to retrieve
Returns:
Detailed volume information including size, performance tier, and backup policy
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| volume_id | Yes |
Implementation Reference
- mcp_server_oci/tools/storage.py:135-175 (handler)The core handler function that retrieves detailed information about a specific OCI block volume using the BlockstorageClient. It extracts and formats volume properties into a dictionary.def get_volume(block_storage_client: oci.core.BlockstorageClient, volume_id: str) -> Dict[str, Any]: """ Get details of a specific volume. Args: block_storage_client: OCI BlockStorage client volume_id: OCID of the volume Returns: Details of the volume """ try: volume = block_storage_client.get_volume(volume_id).data volume_details = { "id": volume.id, "display_name": volume.display_name, "compartment_id": volume.compartment_id, "availability_domain": volume.availability_domain, "size_in_mbs": volume.size_in_mbs, "size_in_gbs": volume.size_in_gbs, "lifecycle_state": volume.lifecycle_state, "time_created": str(volume.time_created), "volume_group_id": volume.volume_group_id, "is_hydrated": volume.is_hydrated, "vpus_per_gb": volume.vpus_per_gb, "is_auto_tune_enabled": volume.is_auto_tune_enabled, "auto_tuned_vpus_per_gb": volume.auto_tuned_vpus_per_gb, "kms_key_id": volume.kms_key_id, "source_details": { "type": volume.source_details.type if volume.source_details else None, "id": volume.source_details.id if volume.source_details else None, } if volume.source_details else None, } logger.info(f"Retrieved details for volume {volume_id}") return volume_details except Exception as e: logger.exception(f"Error getting volume details: {e}") raise
- mcp_server_oci/mcp_server.py:882-899 (registration)MCP tool registration for 'get_volume'. This async wrapper function registers the tool with the FastMCP server, provides input validation via type hints, adds logging and error handling via mcp_tool_wrapper, and delegates to the core handler.@mcp.tool(name="get_volume") @mcp_tool_wrapper( start_msg="Getting volume details for {volume_id}...", success_msg="Retrieved volume details successfully", error_prefix="Error getting volume details" ) async def mcp_get_volume(ctx: Context, volume_id: str) -> Dict[str, Any]: """ Get detailed information about a specific Block Storage volume. Args: volume_id: OCID of the volume to retrieve Returns: Detailed volume information including size, performance tier, and backup policy """ return get_volume(oci_clients["block_storage"], volume_id)