Skip to main content
Glama

get_budget

Retrieve detailed budget information from Oracle Cloud Infrastructure, including targets, alert rules, and spend tracking data for cost management.

Instructions

Get detailed information about a specific budget.

Args:
    budget_id: OCID of the budget to retrieve

Returns:
    Detailed budget information including targets, alert rules, and spend tracking

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes

Implementation Reference

  • The main MCP tool handler function 'mcp_get_budget' registered with name 'get_budget'. It uses the pre-initialized OCI budget client and calls the helper function to retrieve and return budget details.
    @mcp.tool(name="get_budget")
    @mcp_tool_wrapper(
        start_msg="Getting budget details for {budget_id}...",
        success_msg="Retrieved budget details successfully",
        error_prefix="Error getting budget details"
    )
    async def mcp_get_budget(ctx: Context, budget_id: str) -> Dict[str, Any]:
        """
        Get detailed information about a specific budget.
    
        Args:
            budget_id: OCID of the budget to retrieve
    
        Returns:
            Detailed budget information including targets, alert rules, and spend tracking
        """
        return get_budget(oci_clients["budget"], budget_id)
  • Supporting helper function that executes the core OCI API call to retrieve budget details and formats the response dictionary.
    def get_budget(budget_client: oci.budget.BudgetClient, budget_id: str) -> Dict[str, Any]:
        """
        Get details of a specific budget.
    
        Args:
            budget_client: OCI Budget client
            budget_id: OCID of the budget
    
        Returns:
            Details of the budget
        """
        try:
            budget = budget_client.get_budget(budget_id).data
    
            budget_details = {
                "id": budget.id,
                "display_name": budget.display_name,
                "description": budget.description,
                "compartment_id": budget.compartment_id,
                "target_compartment_id": budget.target_compartment_id,
                "target_type": budget.target_type,
                "targets": budget.targets,
                "amount": budget.amount,
                "reset_period": budget.reset_period,
                "budget_processing_period_start_offset": budget.budget_processing_period_start_offset,
                "processing_period_type": budget.processing_period_type,
                "lifecycle_state": budget.lifecycle_state,
                "alert_rule_count": budget.alert_rule_count,
                "version": budget.version,
                "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,
                "time_created": str(budget.time_created),
                "time_updated": str(budget.time_updated),
            }
    
            logger.info(f"Retrieved details for budget {budget_id}")
            return budget_details
    
        except Exception as e:
            logger.exception(f"Error getting budget details: {e}")
            raise
  • The @mcp.tool decorator registers the handler function with the name 'get_budget'.
    @mcp.tool(name="get_budget")

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