get_tenancy_info
Retrieve tenancy details including name, home region, and description by providing the tenancy OCID.
Instructions
Get detailed information about a tenancy.
Args:
tenancy_id: OCID of the tenancy
Returns:
Tenancy details including name, home region, and description
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tenancy_id | Yes |
Implementation Reference
- Core implementation of the get_tenancy_info tool handler. Fetches tenancy details using OCI IdentityClient.get_tenancy() and formats the response.def get_tenancy_info(identity_client: oci.identity.IdentityClient, tenancy_id: str) -> Dict[str, Any]: """ Get tenancy information. Args: identity_client: OCI Identity client tenancy_id: OCID of the tenancy Returns: Tenancy details """ try: tenancy = identity_client.get_tenancy(tenancy_id).data tenancy_details = { "id": tenancy.id, "name": tenancy.name, "description": tenancy.description, "home_region_key": tenancy.home_region_key, "upi_idcs_compatibility_layer_endpoint": tenancy.upi_idcs_compatibility_layer_endpoint, } logger.info(f"Retrieved tenancy details for {tenancy_id}") return tenancy_details except Exception as e: logger.exception(f"Error getting tenancy details: {e}") raise
- mcp_server_oci/mcp_server.py:1394-1411 (registration)MCP tool registration using @mcp.tool(name='get_tenancy_info') decorator. Wraps the core handler with standardized error handling, logging, and profile management via mcp_tool_wrapper.@mcp.tool(name="get_tenancy_info") @mcp_tool_wrapper( start_msg="Getting tenancy information for {tenancy_id}...", success_msg="Retrieved tenancy information successfully", error_prefix="Error getting tenancy information" ) async def mcp_get_tenancy_info(ctx: Context, tenancy_id: str) -> Dict[str, Any]: """ Get detailed information about a tenancy. Args: tenancy_id: OCID of the tenancy Returns: Tenancy details including name, home region, and description """ return get_tenancy_info(oci_clients["identity"], tenancy_id)