Skip to main content
Glama

get_account_details

Retrieve comprehensive financial account information from Brex, including balances, transactions, and account status by providing the account ID.

Instructions

Get detailed information about a Brex account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesID of the Brex account

Implementation Reference

  • Core execution logic of the get_account_details tool handler: validates input, fetches account details and recent transactions via BrexClient, enriches response, handles errors.
    registerToolHandler("get_account_details", async (request: ToolCallRequest) => { try { // Validate parameters const params = validateParams(request.params.arguments as unknown as Record<string, unknown>); logDebug(`Getting account details for account ${params.accountId}`); // Get Brex client const brexClient = getBrexClient(); try { // Call Brex API to get account details const account = await brexClient.getAccount(params.accountId); // Validate account data if (!isBrexAccount(account)) { throw new Error("Invalid account data received from Brex API"); } // Get additional account information if available try { const transactions = await brexClient.getTransactions(params.accountId, undefined, 5); const recentActivity = transactions.items.slice(0, 5); // Combine account details with recent activity const enrichedAccount = { ...account, recent_activity: recentActivity }; return { content: [{ type: "text", text: JSON.stringify(enrichedAccount, null, 2) }] }; } catch (transactionError) { // If we can't get transactions, just return the account details logError(`Error fetching recent transactions: ${transactionError instanceof Error ? transactionError.message : String(transactionError)}`); return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] }; } } catch (apiError) { logError(`Error calling Brex API: ${apiError instanceof Error ? apiError.message : String(apiError)}`); throw new Error(`Failed to get account details: ${apiError instanceof Error ? apiError.message : String(apiError)}`); } } catch (error) { logError(`Error in get_account_details tool: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
  • TypeScript interface defining the expected input parameters (accountId: string). Used internally for validation.
    interface GetAccountDetailsParams { accountId: string; }
  • JSON schema for get_account_details input parameters, exposed in the listTools MCP response.
    name: "get_account_details", description: "Get detailed information about a Brex account", inputSchema: { type: "object", properties: { accountId: { type: "string", description: "ID of the Brex account" } }, required: ["accountId"] }
  • Registration function that sets up the tool handler using registerToolHandler from index.ts.
    export function registerGetAccountDetails(_server: Server): void { registerToolHandler("get_account_details", async (request: ToolCallRequest) => { try { // Validate parameters const params = validateParams(request.params.arguments as unknown as Record<string, unknown>); logDebug(`Getting account details for account ${params.accountId}`); // Get Brex client const brexClient = getBrexClient(); try { // Call Brex API to get account details const account = await brexClient.getAccount(params.accountId); // Validate account data if (!isBrexAccount(account)) { throw new Error("Invalid account data received from Brex API"); } // Get additional account information if available try { const transactions = await brexClient.getTransactions(params.accountId, undefined, 5); const recentActivity = transactions.items.slice(0, 5); // Combine account details with recent activity const enrichedAccount = { ...account, recent_activity: recentActivity }; return { content: [{ type: "text", text: JSON.stringify(enrichedAccount, null, 2) }] }; } catch (transactionError) { // If we can't get transactions, just return the account details logError(`Error fetching recent transactions: ${transactionError instanceof Error ? transactionError.message : String(transactionError)}`); return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] }; } } catch (apiError) { logError(`Error calling Brex API: ${apiError instanceof Error ? apiError.message : String(apiError)}`); throw new Error(`Failed to get account details: ${apiError instanceof Error ? apiError.message : String(apiError)}`); } } catch (error) { logError(`Error in get_account_details tool: ${error instanceof Error ? error.message : String(error)}`); throw error; } }); }
  • Invocation of the tool's registration during overall tools setup in registerTools.
    registerGetAccountDetails(server);
  • Utility function to validate and cast raw input parameters to typed GetAccountDetailsParams.
    function validateParams(input: any): GetAccountDetailsParams { if (!input) { throw new Error("Missing parameters"); } if (!input.accountId) { throw new Error("Missing required parameter: accountId"); } return { accountId: input.accountId }; }

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