Skip to main content
Glama

get_cash_transactions

Retrieve cash transaction data from Brex accounts to monitor financial activity, track spending patterns, and analyze cash flow using pagination and filtering options.

Instructions

LIST: Cash transactions (requires cash scopes). Example: {"account_id":"cash_acc_123","limit":10}. Returns complete transaction objects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYesCash account ID
cursorNoPagination cursor
expandNoFields to expand
limitNoItems per page (1-100)
posted_at_startNoISO timestamp to start from

Implementation Reference

  • Main tool handler: validates input parameters, calls BrexClient.getCashTransactions, formats and returns paginated transaction data as JSON.
    registerToolHandler("get_cash_transactions", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); // Call API with all supported parameters const resp = await client.getCashTransactions(params.account_id, { cursor: params.cursor, limit: params.limit, posted_at_start: params.posted_at_start, expand: params.expand }); // Return complete transaction objects without any filtering or summarization const items = Array.isArray(resp.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ transactions: items, meta: { count: items.length, next_cursor: (resp as any).next_cursor } }, null, 2) }] }; } catch (error) { logError(`Error in get_cash_transactions: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
  • MCP protocol tool schema: defines inputSchema, description, and parameters for the get_cash_transactions tool.
    { name: "get_cash_transactions", description: "LIST: Cash transactions (requires cash scopes). Example: {\"account_id\":\"cash_acc_123\",\"limit\":10}. Returns complete transaction objects.", inputSchema: { type: "object", properties: { account_id: { type: "string", description: "Cash account ID" }, cursor: { type: "string", description: "Pagination cursor" }, limit: { type: "number", description: "Items per page (1-100)" }, posted_at_start: { type: "string", description: "ISO timestamp to start from" }, expand: { type: "array", items: { type: "string" }, description: "Fields to expand" } }, required: ["account_id"] } },
  • Registers the get_cash_transactions tool handler using registerToolHandler.
    export function registerGetCashTransactions(_server: Server): void { registerToolHandler("get_cash_transactions", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); // Call API with all supported parameters const resp = await client.getCashTransactions(params.account_id, { cursor: params.cursor, limit: params.limit, posted_at_start: params.posted_at_start, expand: params.expand }); // Return complete transaction objects without any filtering or summarization const items = Array.isArray(resp.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ transactions: items, meta: { count: items.length, next_cursor: (resp as any).next_cursor } }, null, 2) }] }; } catch (error) { logError(`Error in get_cash_transactions: ${error instanceof Error ? error.message : String(error)}`); throw error; } }); }
  • Calls registerGetCashTransactions as part of registerTools(server) to enable the tool.
    registerGetCashTransactions(server);
  • TypeScript interface defining parameters and validation function for input sanitization and type checking.
    interface GetCashTransactionsParams { account_id: string; cursor?: string; limit?: number; posted_at_start?: string; expand?: string[]; } function validateParams(input: unknown): GetCashTransactionsParams { const raw = (input || {}) as Record<string, unknown>; if (!raw.account_id) throw new Error("Missing required parameter: account_id"); const out: GetCashTransactionsParams = { account_id: String(raw.account_id) }; if (raw.cursor !== undefined) out.cursor = String(raw.cursor); 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.posted_at_start !== undefined) { out.posted_at_start = new Date(String(raw.posted_at_start)).toISOString(); } if (raw.expand !== undefined) { out.expand = Array.isArray(raw.expand) ? raw.expand.map(String) : [String(raw.expand)]; } // Ignore deprecated parameters silently // summary_only and fields are no longer supported but we don't error out return out; }
  • BrexClient method that makes the actual API call to fetch cash transactions from Brex /v2/transactions/cash/{id} endpoint.
    async getCashTransactions(id: string, options?: { cursor?: string; limit?: number; posted_at_start?: string; expand?: string[]; }): Promise<PageCashTransaction> { try { const params: Record<string, unknown> = {}; if (options) { if (options.cursor) params.cursor = options.cursor; if (options.limit) params.limit = options.limit; if (options.posted_at_start) params.posted_at_start = options.posted_at_start; if (options.expand) params.expand = options.expand; } logDebug(`Fetching cash transactions for account ${id} from Brex API`); const response = await this.client.get(`/v2/transactions/cash/${id}`, { params }); logDebug(`Successfully fetched ${response.data.items.length} cash transactions for account ${id}`); return response.data; } catch (error) { this.handleApiError(error, 'GET', `/v2/transactions/cash/${id}`); 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