Skip to main content
Glama

get_budget_summary

Retrieve a complete budget summary for a trip, including total spent, remaining balance, and breakdown by category. Input the trip ID to get actionable insights.

Instructions

Get a full budget summary: total spent, remaining balance, and per-category breakdown.

Args: trip_id: The trip identifier used when creating the budget

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
trip_idYes

Implementation Reference

  • MCP tool handler for 'get_budget_summary'. Decorated with @mcp.tool(), takes a trip_id string and delegates to budget.get_summary(trip_id).
    @mcp.tool()
    def get_budget_summary(trip_id: str) -> dict:
        """
        Get a full budget summary: total spent, remaining balance, and per-category breakdown.
    
        Args:
            trip_id: The trip identifier used when creating the budget
        """
        return budget.get_summary(trip_id)
  • HTTP API registration for 'get_budget_summary' via @mcp.custom_route at POST /api/tools/get_budget_summary. Extracts trip_id from JSON body and calls budget.get_summary().
    @mcp.custom_route("/api/tools/get_budget_summary", methods=["POST"])
    async def api_get_budget_summary(request: Request) -> JSONResponse:
        body = await request.json()
        result = budget.get_summary(body["trip_id"])
        return JSONResponse(result)
  • Core helper function 'get_summary' that computes the full budget summary: total spent, remaining balance, budget used percentage, and per-category breakdown with spending and percentage.
    def get_summary(trip_id: str) -> dict:
        if trip_id not in _budgets:
            return {"error": f"No budget found for trip_id '{trip_id}'."}
    
        record = _budgets[trip_id]
        category_totals: dict[str, float] = {cat: 0.0 for cat in CATEGORIES}
        for expense in record.expenses:
            cat = expense.category if expense.category in CATEGORIES else "misc"
            category_totals[cat] += expense.amount
    
        total_spent = sum(category_totals.values())
        remaining = record.total_budget - total_spent
    
        breakdown = {}
        for cat, spent in category_totals.items():
            pct = (spent / record.total_budget * 100) if record.total_budget > 0 else 0.0
            breakdown[cat] = {
                "spent": round(spent, 2),
                "percentage_of_budget": round(pct, 1),
            }
    
        return {
            "trip_id": trip_id,
            "currency": record.currency,
            "total_budget": record.total_budget,
            "total_spent": round(total_spent, 2),
            "remaining_balance": round(remaining, 2),
            "budget_used_pct": round(total_spent / record.total_budget * 100, 1) if record.total_budget > 0 else 0.0,
            "category_breakdown": breakdown,
            "expenses": [
                {"category": e.category, "amount": e.amount, "description": e.description}
                for e in record.expenses
            ],
        }
  • Schema definitions: Expense and BudgetRecord Pydantic models, CATEGORIES constant, and the _budgets in-memory store used by get_summary.
    from __future__ import annotations
    
    from pydantic import BaseModel
    
    CATEGORIES = ["flights", "hotels", "food", "activities", "transport", "shopping", "misc"]
    
    
    class Expense(BaseModel):
        category: str
        amount: float
        description: str
    
    
    class BudgetRecord(BaseModel):
        trip_id: str
        total_budget: float
        currency: str
        expenses: list[Expense] = []
    
    
    _budgets: dict[str, BudgetRecord] = {}
  • Reference to get_budget_summary in a note generated by the itinerary planner, directing users to use the trip_id with add_expense and get_budget_summary.
    result["budget"] = {
        "trip_id": trip_id,
        "total_budget": total_budget,
        "currency": "USD",
        "suggested_allocation": allocation,
        "note": f"Use trip_id '{trip_id}' with add_expense and get_budget_summary to track spending.",
    }
Behavior2/5

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

No annotations provided, so the description must fully disclose behavior. It does not explicitly state that the operation is read-only or non-destructive, nor does it mention any side effects, authorization requirements, or error handling.

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 extremely concise with two sentences plus an Args section. Every sentence is necessary and there is no repetition or fluff.

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?

The description gives a high-level summary of return values but does not mention what happens if the trip_id is invalid or not found. Given no output schema, more context on error handling would improve completeness.

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 meaning to the trip_id parameter by noting it is 'The trip identifier used when creating the budget', which goes beyond the schema's title-only field. The schema coverage is 0%, so this additional context is valuable.

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 it retrieves a full budget summary with total spent, remaining balance, and per-category breakdown. It distinguishes from sibling tools like add_expense and create_trip_budget by being a read operation.

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 on when to use this tool versus alternatives like get_weather or search_hotels. There is no mention of context where this tool is appropriate or inappropriate.

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/ismailrz/travel-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server