Skip to main content
Glama

list_shapes

Retrieve available compute shapes with CPU, memory, network, and GPU specifications for an Oracle Cloud Infrastructure compartment to support resource selection.

Instructions

List all compute shapes available in a compartment.

Args:
    compartment_id: OCID of the compartment

Returns:
    List of shapes with CPU, memory, network, and GPU specifications

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes

Implementation Reference

  • MCP tool handler for 'list_shapes'. This async function is decorated with @mcp.tool(name='list_shapes') and calls the underlying list_shapes helper with the compute client and compartment_id.
    @mcp.tool(name="list_shapes")
    @mcp_tool_wrapper(
        start_msg="Listing compute shapes in compartment {compartment_id}...",
        error_prefix="Error listing shapes"
    )
    async def mcp_list_shapes(ctx: Context, compartment_id: str) -> List[Dict[str, Any]]:
        """
        List all compute shapes available in a compartment.
    
        Args:
            compartment_id: OCID of the compartment
    
        Returns:
            List of shapes with CPU, memory, network, and GPU specifications
        """
        return list_shapes(oci_clients["compute"], compartment_id)
  • Core helper function that implements the OCI API call to list shapes, formats the response into a list of dictionaries with detailed shape specifications, and handles errors.
    def list_shapes(compute_client: oci.core.ComputeClient, compartment_id: str) -> List[Dict[str, Any]]:
        """
        List all shapes available in a compartment.
        
        Args:
            compute_client: OCI Compute client
            compartment_id: OCID of the compartment
            
        Returns:
            List of shapes with their details
        """
        try:
            shapes_response = oci.pagination.list_call_get_all_results(
                compute_client.list_shapes,
                compartment_id
            )
            
            shapes = []
            for shape in shapes_response.data:
                shapes.append({
                    "shape": shape.shape,
                    "processor_description": shape.processor_description,
                    "ocpus": shape.ocpus,
                    "memory_in_gbs": shape.memory_in_gbs,
                    "networking_bandwidth_in_gbps": shape.networking_bandwidth_in_gbps,
                    "max_vnic_attachments": shape.max_vnic_attachments,
                    "gpus": shape.gpus,
                    "gpu_description": shape.gpu_description,
                    "local_disks": shape.local_disks,
                    "local_disks_total_size_in_gbs": shape.local_disks_total_size_in_gbs,
                    "local_disk_description": shape.local_disk_description,
                    "rdma_ports": shape.rdma_ports,
                    "rdma_bandwidth_in_gbps": shape.rdma_bandwidth_in_gbps,
                    "is_live_migration_supported": shape.is_live_migration_supported,
                    "ocpu_options": {
                        "min": shape.ocpu_options.min if shape.ocpu_options else None,
                        "max": shape.ocpu_options.max if shape.ocpu_options else None,
                    } if shape.ocpu_options else None,
                    "memory_options": {
                        "min_in_g_bs": shape.memory_options.min_in_g_bs if shape.memory_options else None,
                        "max_in_g_bs": shape.memory_options.max_in_g_bs if shape.memory_options else None,
                        "default_per_ocpu_in_g_bs": shape.memory_options.default_per_ocpu_in_g_bs if shape.memory_options else None,
                        "min_per_ocpu_in_g_bs": shape.memory_options.min_per_ocpu_in_g_bs if shape.memory_options else None,
                        "max_per_ocpu_in_g_bs": shape.memory_options.max_per_ocpu_in_g_bs if shape.memory_options else None,
                    } if shape.memory_options else None,
                    "networking_bandwidth_options": {
                        "min_in_gbps": shape.networking_bandwidth_options.min_in_gbps if shape.networking_bandwidth_options else None,
                        "max_in_gbps": shape.networking_bandwidth_options.max_in_gbps if shape.networking_bandwidth_options else None,
                        "default_per_ocpu_in_gbps": shape.networking_bandwidth_options.default_per_ocpu_in_gbps if shape.networking_bandwidth_options else None,
                    } if shape.networking_bandwidth_options else None,
                })
            
            logger.info(f"Found {len(shapes)} shapes in compartment {compartment_id}")
            return shapes
            
        except Exception as e:
            logger.exception(f"Error listing shapes: {e}")
            raise
  • MCP tool registration decorator specifying the tool name as 'list_shapes'.
    @mcp.tool(name="list_shapes")

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/jopsis/mcp-server-oci'

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