get_budget_programs
Retrieve budget program details from Brex to view active or inactive spending limits and financial allocations.
Instructions
List budget programs (read-only). Returns complete budget program objects. Example: {"limit":10,"budget_program_status":"ACTIVE"}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| cursor | No | ||
| budget_program_status | No |
Implementation Reference
- src/tools/getBudgetPrograms.ts:45-75 (handler)Main handler function for the 'get_budget_programs' tool: validates input parameters, calls the Brex API via client, processes response, and returns formatted JSON.registerToolHandler("get_budget_programs", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const apiParams: BudgetProgramListParams = { limit: params.limit, cursor: params.cursor, budget_program_status: params.budget_program_status }; const resp = await client.getBudgetPrograms(apiParams); const items = Array.isArray(resp.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ budget_programs: items, meta: { count: items.length, next_cursor: resp.next_cursor || null } }, null, 2) }] }; } catch (error) { logError(`Error in get_budget_programs: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
- src/tools/getBudgetPrograms.ts:15-19 (schema)TypeScript interface defining input parameters for the get_budget_programs tool.interface GetBudgetProgramsParams { limit?: number; cursor?: string; budget_program_status?: BudgetProgramStatus; }
- src/tools/getBudgetPrograms.ts:44-76 (registration)Registration function that sets up the 'get_budget_programs' tool handler using registerToolHandler.export function registerGetBudgetPrograms(_server: Server): void { registerToolHandler("get_budget_programs", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const apiParams: BudgetProgramListParams = { limit: params.limit, cursor: params.cursor, budget_program_status: params.budget_program_status }; const resp = await client.getBudgetPrograms(apiParams); const items = Array.isArray(resp.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ budget_programs: items, meta: { count: items.length, next_cursor: resp.next_cursor || null } }, null, 2) }] }; } catch (error) { logError(`Error in get_budget_programs: ${error instanceof Error ? error.message : String(error)}`); throw error; } }); }
- src/tools/index.ts:67-67 (registration)Invocation of the registerGetBudgetPrograms function within the overall registerTools function.registerGetBudgetPrograms(server);
- src/tools/index.ts:135-144 (schema)JSON input schema definition for the 'get_budget_programs' tool in the listTools response.name: "get_budget_programs", description: "List budget programs (read-only). Returns complete budget program objects. Example: {\"limit\":10,\"budget_program_status\":\"ACTIVE\"}", inputSchema: { type: "object", properties: { limit: { type: "number" }, cursor: { type: "string" }, budget_program_status: { type: "string", enum: ["ACTIVE","INACTIVE"] } } }
- src/tools/getBudgetPrograms.ts:21-42 (helper)Helper function to validate and parse input parameters for the tool.function validateParams(input: unknown): GetBudgetProgramsParams { const raw = (input || {}) as Record<string, unknown>; const out: GetBudgetProgramsParams = {}; 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.budget_program_status !== undefined) { out.budget_program_status = String(raw.budget_program_status) as BudgetProgramStatus; } return out; }