create_trip_budget
Set up a budget tracker for a trip by providing a trip ID, total budget, and optional currency code.
Instructions
Create a budget tracker for a trip.
Args: trip_id: Unique identifier for the trip (e.g. "tokyo-oct-2024") total_budget: Total budget amount currency: Currency code (default: "USD")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trip_id | Yes | ||
| total_budget | Yes | ||
| currency | No | USD |
Implementation Reference
- src/travel_mcp/server.py:119-134 (handler)The @mcp.tool()-decorated handler for 'create_trip_budget'. Accepts trip_id (str), total_budget (float), and optional currency (str, default 'USD'), delegating to budget.create().
@mcp.tool() def create_trip_budget( trip_id: str, total_budget: float, currency: str = "USD", ) -> dict: """ Create a budget tracker for a trip. Args: trip_id: Unique identifier for the trip (e.g. "tokyo-oct-2024") total_budget: Total budget amount currency: Currency code (default: "USD") """ return budget.create(trip_id, total_budget, currency) - src/travel_mcp/tools/budget.py:24-33 (helper)The budget.create() function that implements the core logic: creates a BudgetRecord in the in-memory _budgets dict and returns a dict with trip_id, total_budget, currency, categories (initialized to zero), and a confirmation message.
def create(trip_id: str, total_budget: float, currency: str = "USD") -> dict: record = BudgetRecord(trip_id=trip_id, total_budget=total_budget, currency=currency) _budgets[trip_id] = record return { "trip_id": trip_id, "total_budget": total_budget, "currency": currency, "categories": {cat: 0.0 for cat in CATEGORIES}, "message": f"Budget of {currency} {total_budget:.2f} created for trip '{trip_id}'.", } - src/travel_mcp/tools/budget.py:14-19 (schema)BudgetRecord Pydantic model — schema for in-memory storage of a trip budget including trip_id, total_budget, currency, and a list of Expense items.
class BudgetRecord(BaseModel): trip_id: str total_budget: float currency: str expenses: list[Expense] = [] - src/travel_mcp/server.py:215-219 (registration)HTTP API route registration for the tool at /api/tools/create_trip_budget (POST), mapping to budget.create().
@mcp.custom_route("/api/tools/create_trip_budget", methods=["POST"]) async def api_create_trip_budget(request: Request) -> JSONResponse: body = await request.json() result = budget.create(body["trip_id"], body["total_budget"], body.get("currency", "USD")) return JSONResponse(result) - src/travel_mcp/tools/budget.py:8-11 (schema)Expense Pydantic model — schema for individual expense entries with category, amount, and description fields.
class Expense(BaseModel): category: str amount: float description: str