get_budgets
Retrieve and list budget information from the Brex financial platform, including active, archived, or draft budgets with pagination support.
Instructions
List budgets (read-only). Example: {"limit":10}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | ||
| limit | No | ||
| parent_budget_id | No | ||
| spend_budget_status | No |
Implementation Reference
- src/tools/getBudgets.ts:35-60 (handler)Core handler function for the 'get_budgets' tool. Validates input parameters, calls the Brex API via client.getBudgets, processes the response, and returns formatted JSON output.registerToolHandler("get_budgets", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const apiParams: BudgetListParams = { limit: params.limit, cursor: params.cursor, parent_budget_id: params.parent_budget_id, spend_budget_status: params.spend_budget_status }; const resp = await client.getBudgets(apiParams); const items = Array.isArray(resp.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ budgets: items, meta: { count: items.length, next_cursor: resp.next_cursor || null } }, null, 2) }] }; } catch (error) { logError(`Error in get_budgets: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
- src/tools/getBudgets.ts:13-32 (schema)Type definition (GetBudgetsParams interface) and validation logic for tool input parameters.interface GetBudgetsParams { limit?: number; cursor?: string; parent_budget_id?: string; spend_budget_status?: SpendBudgetStatus; } function validateParams(input: unknown): GetBudgetsParams { const raw = (input || {}) as Record<string, unknown>; const out: GetBudgetsParams = {}; if (raw.limit !== undefined) { const n = parseInt(String(raw.limit), 10); if (isNaN(n) || n <= 0 || n > 100) throw new Error("Invalid limit (1..100)"); out.limit = n; } if (raw.cursor !== undefined) out.cursor = String(raw.cursor); if (raw.parent_budget_id !== undefined) out.parent_budget_id = String(raw.parent_budget_id); if (raw.spend_budget_status !== undefined) out.spend_budget_status = String(raw.spend_budget_status) as SpendBudgetStatus; return out; }
- src/tools/index.ts:63-63 (registration)Registers the get_budgets tool by calling registerGetBudgets(server).registerGetBudgets(server);
- src/tools/index.ts:86-97 (schema)Official MCP input schema definition for the 'get_budgets' tool, exposed in the listTools response.name: "get_budgets", description: "List budgets (read-only). Example: {\"limit\":10}", inputSchema: { type: "object", properties: { limit: { type: "number" }, cursor: { type: "string" }, parent_budget_id: { type: "string" }, spend_budget_status: { type: "string", enum: ["ACTIVE","ARCHIVED","DRAFT"] } } } },
- src/tools/index.ts:24-24 (registration)Imports the registerGetBudgets function used to register the tool.import { registerGetBudgets } from "./getBudgets.js";