get_spend_limits
Retrieve and view current spend limit configurations for Brex accounts to monitor budget allocations and status.
Instructions
List spend limits (read-only). Example: {"limit":10,"status":"ACTIVE"}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| cursor | No | ||
| parent_budget_id | No | ||
| status | No | ||
| member_user_id | No |
Implementation Reference
- src/tools/getSpendLimits.ts:33-51 (handler)Executes the get_spend_limits tool: validates params, calls Brex API, returns formatted JSON response.registerToolHandler("get_spend_limits", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const apiParams: SpendLimitListParams = { limit: params.limit, cursor: params.cursor, parent_budget_id: params.parent_budget_id, status: params.status, member_user_id: params.member_user_id }; const resp = await client.getSpendLimits(apiParams); const items = Array.isArray(resp.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ spend_limits: items, meta: { count: items.length, next_cursor: resp.next_cursor } }, null, 2) }] }; } catch (error) { logError(`Error in get_spend_limits: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
- src/tools/index.ts:109-122 (schema)JSON schema for get_spend_limits tool inputs in the listTools handler response.{ name: "get_spend_limits", description: "List spend limits (read-only). Example: {\"limit\":10,\"status\":\"ACTIVE\"}", inputSchema: { type: "object", properties: { limit: { type: "number" }, cursor: { type: "string" }, parent_budget_id: { type: "string" }, status: { type: "string", enum: ["ACTIVE","ARCHIVED"] }, member_user_id: { type: "string" } } } },
- src/tools/getSpendLimits.ts:32-52 (registration)Registers the get_spend_limits tool handler using registerToolHandler.export function registerGetSpendLimits(_server: Server): void { registerToolHandler("get_spend_limits", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const apiParams: SpendLimitListParams = { limit: params.limit, cursor: params.cursor, parent_budget_id: params.parent_budget_id, status: params.status, member_user_id: params.member_user_id }; const resp = await client.getSpendLimits(apiParams); const items = Array.isArray(resp.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ spend_limits: items, meta: { count: items.length, next_cursor: resp.next_cursor } }, null, 2) }] }; } catch (error) { logError(`Error in get_spend_limits: ${error instanceof Error ? error.message : String(error)}`); throw error; } }); }
- src/tools/getSpendLimits.ts:21-30 (helper)Validates and parses input parameters for the get_spend_limits tool.function validateParams(input: unknown): GetSpendLimitsParams { const raw = (input || {}) as Record<string, unknown>; const out: GetSpendLimitsParams = {}; 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.status !== undefined) out.status = String(raw.status) as SpendLimitStatus; if (raw.member_user_id !== undefined) out.member_user_id = String(raw.member_user_id); return out; }
- src/tools/getSpendLimits.ts:13-19 (schema)TypeScript interface defining typed parameters for get_spend_limits.interface GetSpendLimitsParams { limit?: number; cursor?: string; parent_budget_id?: string; status?: SpendLimitStatus; member_user_id?: string; }