list_regions
Retrieve available Oracle Cloud Infrastructure regions with keys and names for resource management and deployment planning.
Instructions
List all available OCI regions.
Returns:
List of regions with their keys and names
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Core handler function that executes the logic to list all available OCI regions using the OCI IdentityClient, processes the response, and returns a list of dictionaries containing region key and name.def list_regions(identity_client: oci.identity.IdentityClient) -> List[Dict[str, Any]]: """ List all available regions. Args: identity_client: OCI Identity client Returns: List of regions with their details """ try: regions_response = identity_client.list_regions() regions = [] for region in regions_response.data: regions.append({ "key": region.key, "name": region.name, }) logger.info(f"Found {len(regions)} regions") return regions except Exception as e: logger.exception(f"Error listing regions: {e}") raise
- mcp_server_oci/mcp_server.py:1379-1392 (registration)Registration of the 'list_regions' tool in the MCP server using the @mcp.tool decorator. This wrapper function handles MCP context, applies common error handling via mcp_tool_wrapper, and delegates to the core handler.@mcp.tool(name="list_regions") @mcp_tool_wrapper( start_msg="Listing all available OCI regions...", error_prefix="Error listing regions" ) async def mcp_list_regions(ctx: Context) -> List[Dict[str, Any]]: """ List all available OCI regions. Returns: List of regions with their keys and names """ return list_regions(oci_clients["identity"])