Skip to main content
Glama

get_spend_limits

Retrieve spend limit details from Brex financial platform to monitor budget constraints and track active or archived spending policies.

Instructions

List spend limits (read-only). Example: {"limit":10,"status":"ACTIVE"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorNo
limitNo
member_user_idNo
parent_budget_idNo
statusNo

Implementation Reference

  • Core handler function for the get_spend_limits tool. Validates input parameters, calls BrexClient.getSpendLimits API, formats the response as JSON with spend_limits array and pagination meta, handles errors.
    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; } });
  • TypeScript interface and validation function defining the expected input parameters for the get_spend_limits tool, including limit, cursor, filters.
    interface GetSpendLimitsParams { limit?: number; cursor?: string; parent_budget_id?: string; status?: SpendLimitStatus; member_user_id?: string; } 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; }
  • Exported registration function that registers the get_spend_limits tool handler with the MCP server 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; } }); }
  • JSON schema definition for get_spend_limits tool input, provided in the MCP list_tools response for client validation.
    { 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" } } } },
  • Invocation of registerGetSpendLimits during overall tools registration in registerTools function.
    registerGetSpendLimits(server);
  • BrexClient method that makes the actual API call to /v2/spend_limits endpoint, used by the tool handler.
    async getSpendLimits(params?: SpendLimitListParams): Promise<SpendLimitsResponse> { try { logDebug('Fetching spend limits from Brex API', { params }); return await this.get<SpendLimitsResponse>('/v2/spend_limits', params as unknown as Record<string, any>); } catch (error) { logError(`Error fetching spend limits: ${error instanceof Error ? error.message : String(error)}`); throw error; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/crazyrabbitLTC/mcp-brex-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server