Skip to main content
Glama
crazyrabbitLTC

Brex MCP Server

get_cash_transactions

Retrieve cash transaction data from Brex accounts to monitor financial activity, filter by date, and manage pagination for detailed reporting.

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
limitNoItems per page (1-100)
posted_at_startNoISO timestamp to start from
expandNoFields to expand

Implementation Reference

  • Primary handler registration and execution logic for the 'get_cash_transactions' tool. Validates input parameters, calls the Brex API via client.getCashTransactions, processes the response, and returns formatted JSON with transactions and pagination metadata.
    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;
        }
      });
    }
  • MCP tool specification including name, description, and inputSchema (JSON Schema) for validating 'get_cash_transactions' tool calls.
    {
      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 during server initialization by calling its dedicated registration function.
    registerGetCashTransactions(server);
  • BrexClient helper method that performs the actual API call to retrieve cash transactions for a specific account ID, handling parameters and pagination.
    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;
      }
    }
  • Parameter validation and normalization function for get_cash_transactions tool inputs, enforcing required fields and type conversions.
    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;
    }

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