Skip to main content
Glama

list_log_groups

Retrieve all log groups within a specified Oracle Cloud Infrastructure compartment to monitor and manage logging resources.

Instructions

List all log groups in a compartment. Args: compartment_id: OCID of the compartment to list log groups from Returns: List of log groups with their display names and lifecycle states

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes

Implementation Reference

  • Core handler function that executes the OCI API call to list log groups in a compartment using pagination and formats the response.
    def list_log_groups(logging_client: oci.logging.LoggingManagementClient, compartment_id: str) -> List[Dict[str, Any]]: """ List all log groups in a compartment. Args: logging_client: OCI Logging Management client compartment_id: OCID of the compartment Returns: List of log groups with their details """ try: log_groups_response = oci.pagination.list_call_get_all_results( logging_client.list_log_groups, compartment_id ) log_groups = [] for log_group in log_groups_response.data: log_groups.append({ "id": log_group.id, "display_name": log_group.display_name, "description": log_group.description, "compartment_id": log_group.compartment_id, "time_created": str(log_group.time_created), "time_last_modified": str(log_group.time_last_modified), "lifecycle_state": log_group.lifecycle_state, }) logger.info(f"Found {len(log_groups)} log groups in compartment {compartment_id}") return log_groups except Exception as e: logger.exception(f"Error listing log groups: {e}") raise
  • MCP tool registration with @mcp.tool decorator, including wrapper for error handling, logging, and OCI client injection.
    @mcp.tool(name="list_log_groups") @mcp_tool_wrapper( start_msg="Listing log groups in compartment {compartment_id}...", error_prefix="Error listing log groups" ) async def mcp_list_log_groups(ctx: Context, compartment_id: str) -> List[Dict[str, Any]]: """ List all log groups in a compartment. Args: compartment_id: OCID of the compartment to list log groups from Returns: List of log groups with their display names and lifecycle states """ return list_log_groups(oci_clients["logging"], compartment_id)

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