Skip to main content
Glama

list_budgets

Retrieve budget details for Oracle Cloud Infrastructure compartments to monitor spending, track actual versus forecasted amounts, and manage reset periods.

Instructions

List all budgets in a compartment.

Args:
    compartment_id: OCID of the compartment to list budgets from

Returns:
    List of budgets with amount, reset period, actual spend, and forecasted spend

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes

Implementation Reference

  • Handler function implementing the list_budgets tool logic using OCI Budget SDK to fetch and format budgets in a compartment.
    def list_budgets(budget_client: oci.budget.BudgetClient, compartment_id: str) -> List[Dict[str, Any]]:
        """
        List all budgets in a compartment.
    
        Args:
            budget_client: OCI Budget client
            compartment_id: OCID of the compartment
    
        Returns:
            List of budgets with their details
        """
        try:
            budgets_response = oci.pagination.list_call_get_all_results(
                budget_client.list_budgets,
                compartment_id
            )
    
            budgets = []
            for budget in budgets_response.data:
                budgets.append({
                    "id": budget.id,
                    "display_name": budget.display_name,
                    "compartment_id": budget.compartment_id,
                    "target_compartment_id": budget.target_compartment_id,
                    "amount": budget.amount,
                    "reset_period": budget.reset_period,
                    "lifecycle_state": budget.lifecycle_state,
                    "alert_rule_count": budget.alert_rule_count,
                    "time_created": str(budget.time_created),
                    "actual_spend": budget.actual_spend,
                    "forecasted_spend": budget.forecasted_spend,
                    "time_spend_computed": str(budget.time_spend_computed) if budget.time_spend_computed else None,
                })
    
            logger.info(f"Found {len(budgets)} budgets in compartment {compartment_id}")
            return budgets
    
        except Exception as e:
            logger.exception(f"Error listing budgets: {e}")
            raise
  • MCP tool registration decorator and wrapper function that registers 'list_budgets' tool and delegates to the core handler with the initialized budget client.
    @mcp.tool(name="list_budgets")
    @mcp_tool_wrapper(
        start_msg="Listing budgets in compartment {compartment_id}...",
        error_prefix="Error listing budgets"
    )
    async def mcp_list_budgets(ctx: Context, compartment_id: str) -> List[Dict[str, Any]]:
        """
        List all budgets in a compartment.
    
        Args:
            compartment_id: OCID of the compartment to list budgets from
    
        Returns:
            List of budgets with amount, reset period, actual spend, and forecasted spend
        """
        return list_budgets(oci_clients["budget"], compartment_id)
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the return format but does not disclose behavioral traits such as pagination, rate limits, authentication requirements, or error handling. For a read operation with no annotations, this leaves significant gaps in understanding how the tool behaves.

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

Conciseness5/5

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

The description is front-loaded with the core purpose, followed by structured sections for Args and Returns. Every sentence adds value without redundancy, making it efficient and well-organized for quick comprehension.

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 the tool's low complexity (single parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the basic operation and return format but lacks details on behavioral aspects like pagination or error handling, which are important for a list operation in a cloud service 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?

With 0% schema description coverage, the description compensates by explaining the 'compartment_id' parameter as 'OCID of the compartment to list budgets from', adding semantic meaning beyond the schema's basic type. However, it does not cover other potential parameters or constraints, though only one parameter exists.

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

Purpose5/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 ('budgets in a compartment'), specifying the scope ('all budgets') and distinguishing it from sibling tools like 'get_budget' which likely retrieves a single budget. It provides specific, actionable purpose.

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

Usage Guidelines3/5

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

The description implies usage for listing budgets within a compartment but does not explicitly state when to use this tool versus alternatives like 'get_budget' or other list_* tools. It provides basic context but lacks explicit guidance on exclusions or comparisons.

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