Skip to main content
Glama
crazyrabbitLTC

Brex MCP Server

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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states a read operation ('Get'), which implies it's non-destructive, but doesn't mention permissions, rate limits, pagination, or response format. For a tool with two parameters and no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for a simple tool, making it easy to parse without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (2 parameters, no annotations, no output schema) and multiple sibling tools, the description is incomplete. It doesn't explain return values, error handling, or how it differs from similar tools, leaving the agent with insufficient context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear documentation for both parameters ('accountId' and 'limit'). The description adds no additional meaning beyond what the schema provides, such as context for how 'limit' interacts with default behavior. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get transactions for a Brex account' clearly states the verb ('Get') and resource ('transactions'), but it's vague about scope (e.g., time range, transaction types) and doesn't distinguish from siblings like 'get_card_transactions' or 'get_cash_transactions'. It provides a basic purpose but lacks specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as 'get_card_transactions' or 'get_cash_transactions'. The description implies usage for any Brex account transactions but offers no context, exclusions, or prerequisites, leaving the agent to guess based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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