get_budget_programs
Retrieve and list budget programs from Brex financial platform, including active and inactive programs with pagination support for comprehensive financial oversight.
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 |
|---|---|---|---|
| budget_program_status | No | ||
| cursor | No | ||
| limit | No |
Implementation Reference
- src/tools/getBudgetPrograms.ts:44-76 (handler)Registers the 'get_budget_programs' tool handler. Validates input parameters, calls the Brex client to fetch budget programs, processes the response, and returns formatted JSON output.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/getBudgetPrograms.ts:15-19 (schema)TypeScript interface defining the input parameters for the get_budget_programs tool.interface GetBudgetProgramsParams { limit?: number; cursor?: string; budget_program_status?: BudgetProgramStatus; }
- src/tools/getBudgetPrograms.ts:21-42 (helper)Validates and parses the input parameters for the get_budget_programs tool, enforcing constraints like limit range.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; }
- src/tools/index.ts:67-67 (registration)Registers the get_budget_programs tool by calling registerGetBudgetPrograms during server tool setup.registerGetBudgetPrograms(server);
- src/tools/index.ts:134-145 (schema)MCP input schema for the get_budget_programs tool, used 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"] } } } },