Skip to main content
Glama

list_metrics

Retrieve available metrics in an Oracle Cloud Infrastructure compartment to monitor and analyze resource performance, with optional namespace filtering for targeted insights.

Instructions

List available metrics in a compartment.

Args:
    compartment_id: OCID of the compartment
    namespace: Optional namespace to filter metrics (e.g., oci_computeagent, oci_blockstore)

Returns:
    List of available metrics with their namespaces and dimensions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes
namespaceNo

Implementation Reference

  • MCP tool handler for 'list_metrics': wraps the core helper function, provides input validation via signature/docstring, logging, error handling, and calls OCI monitoring client via helper.
    @mcp.tool(name="list_metrics")
    @mcp_tool_wrapper(
        start_msg="Listing metrics in compartment {compartment_id}...",
        error_prefix="Error listing metrics"
    )
    async def mcp_list_metrics(ctx: Context, compartment_id: str,
                               namespace: Optional[str] = None) -> List[Dict[str, Any]]:
        """
        List available metrics in a compartment.
    
        Args:
            compartment_id: OCID of the compartment
            namespace: Optional namespace to filter metrics (e.g., oci_computeagent, oci_blockstore)
    
        Returns:
            List of available metrics with their namespaces and dimensions
        """
        return list_metrics(oci_clients["monitoring"], compartment_id, namespace)
  • Explicit registration of the tool with name 'list_metrics' using FastMCP decorator.
    @mcp.tool(name="list_metrics")
  • Core helper function implementing the OCI API call to list_metrics, with pagination, response formatting, and error handling.
    def list_metrics(monitoring_client: oci.monitoring.MonitoringClient,
                     compartment_id: str,
                     namespace: Optional[str] = None) -> List[Dict[str, Any]]:
        """
        List available metrics in a compartment.
    
        Args:
            monitoring_client: OCI Monitoring client
            compartment_id: OCID of the compartment
            namespace: Optional namespace to filter metrics
    
        Returns:
            List of available metrics
        """
        try:
            list_metrics_details = oci.monitoring.models.ListMetricsDetails(
                compartment_id=compartment_id,
                namespace=namespace
            )
    
            metrics_response = oci.pagination.list_call_get_all_results(
                monitoring_client.list_metrics,
                compartment_id,
                list_metrics_details
            )
    
            metrics = []
            for metric in metrics_response.data:
                metrics.append({
                    "name": metric.name,
                    "namespace": metric.namespace,
                    "resource_group": metric.resource_group,
                    "compartment_id": metric.compartment_id,
                    "dimensions": metric.dimensions,
                })
    
            logger.info(f"Found {len(metrics)} metrics in compartment {compartment_id}")
            return metrics
    
        except Exception as e:
            logger.exception(f"Error listing metrics: {e}")
            raise
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states it's a list operation, implying read-only behavior, but doesn't disclose critical details like authentication requirements, rate limits, pagination, or what happens if the compartment_id is invalid. For a tool with no annotations, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose. The Args and Returns sections are structured clearly, though the return description could be more specific (e.g., what fields are included). No wasted sentences, but minor room for improvement in brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description covers basic purpose and parameters adequately but lacks details on behavioral traits, error handling, and return format specifics. For a simple list tool, it's minimally viable but incomplete for robust agent usage without additional context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context beyond the schema, which has 0% coverage. It explains that 'compartment_id' is an OCID and 'namespace' is optional for filtering, with examples like 'oci_computeagent'. This compensates well for the lack of schema descriptions, though it doesn't detail format constraints for OCIDs.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('available metrics in a compartment'), making the purpose specific and understandable. It distinguishes from siblings like 'query_metric_data' by focusing on listing available metrics rather than querying metric data, though it doesn't explicitly mention this distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'query_metric_data' or other list tools. The description mentions optional namespace filtering but doesn't explain when this filtering is appropriate or what the tool's scope is relative to siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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