Skip to main content
Glama

get_transactions

Retrieve transaction data from a Brex account by specifying the account ID, with options to limit the number of results returned.

Instructions

Get transactions for a Brex account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesID of the Brex account
limitNoMaximum number of transactions to return (default: 50)

Implementation Reference

  • Core execution logic of the get_transactions tool: parameter validation, Brex API call, transaction filtering, error handling, and JSON response formatting.
    registerToolHandler("get_transactions", async (request: ToolCallRequest) => { try { // Validate parameters const params = validateParams(request.params.arguments); logDebug(`Getting transactions for account ${params.accountId}`); // Get Brex client const brexClient = getBrexClient(); // Set default limit if not provided const limit = params.limit || 50; try { // Call Brex API to get transactions (fallback via statements). Prefer get_cash_transactions. const transactions = await brexClient.getTransactions(params.accountId, undefined, limit); // Validate transactions data if (!transactions || !Array.isArray(transactions.items)) { throw new Error("Invalid response format from Brex API"); } // Filter valid transactions const validTransactions = transactions.items.filter(isBrexTransaction); logDebug(`Found ${validTransactions.length} valid transactions out of ${transactions.items.length} total`); const result = { transactions: validTransactions, meta: { account_id: params.accountId, total_count: validTransactions.length, requested_parameters: params } }; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (apiError) { logError(`Error calling Brex API: ${apiError instanceof Error ? apiError.message : String(apiError)}`); throw new Error(`Failed to get transactions: ${apiError instanceof Error ? apiError.message : String(apiError)}`); } } catch (error) { logError(`Error in get_transactions tool: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
  • Input schema definition for the get_transactions tool, exposed in the listTools MCP response.
    name: "get_transactions", description: "Get transactions for a Brex account", inputSchema: { type: "object", properties: { accountId: { type: "string", description: "ID of the Brex account" }, limit: { type: "number", description: "Maximum number of transactions to return (default: 50)" } }, required: ["accountId"] } },
  • Registration function for the get_transactions tool that sets up the tool handler using registerToolHandler.
    export function registerGetTransactions(_server: Server): void { registerToolHandler("get_transactions", async (request: ToolCallRequest) => { try { // Validate parameters const params = validateParams(request.params.arguments); logDebug(`Getting transactions for account ${params.accountId}`); // Get Brex client const brexClient = getBrexClient(); // Set default limit if not provided const limit = params.limit || 50; try { // Call Brex API to get transactions (fallback via statements). Prefer get_cash_transactions. const transactions = await brexClient.getTransactions(params.accountId, undefined, limit); // Validate transactions data if (!transactions || !Array.isArray(transactions.items)) { throw new Error("Invalid response format from Brex API"); } // Filter valid transactions const validTransactions = transactions.items.filter(isBrexTransaction); logDebug(`Found ${validTransactions.length} valid transactions out of ${transactions.items.length} total`); const result = { transactions: validTransactions, meta: { account_id: params.accountId, total_count: validTransactions.length, requested_parameters: params } }; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (apiError) { logError(`Error calling Brex API: ${apiError instanceof Error ? apiError.message : String(apiError)}`); throw new Error(`Failed to get transactions: ${apiError instanceof Error ? apiError.message : String(apiError)}`); } } catch (error) { logError(`Error in get_transactions tool: ${error instanceof Error ? error.message : String(error)}`); throw error; } }); }
  • Invocation of registerGetTransactions during overall tool registration in registerTools.
    registerGetTransactions(server);
  • Helper function to validate and parse input parameters for the get_transactions tool.
    function validateParams(input: unknown): GetTransactionsParams { if (!input) { throw new Error("Missing parameters"); } const raw = input as Record<string, unknown>; if (!raw.accountId) { throw new Error("Missing required parameter: accountId"); } const params: GetTransactionsParams = { accountId: String(raw.accountId) }; // Add optional parameters if provided if (raw.limit !== undefined) { const limit = parseInt(String(raw.limit), 10); if (isNaN(limit) || limit <= 0) { throw new Error("Invalid limit: must be a positive number"); } params.limit = limit; } return params; }

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