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
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | ID of the Brex account |
Implementation Reference
- src/tools/getAccountDetails.ts:50-103 (handler)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; } });
- src/tools/getAccountDetails.ts:22-24 (schema)TypeScript interface defining the expected input parameters (accountId: string). Used internally for validation.interface GetAccountDetailsParams { accountId: string; }
- src/tools/index.ts:286-297 (schema)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"] }
- src/tools/getAccountDetails.ts:49-104 (registration)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; } }); }
- src/tools/index.ts:47-47 (registration)Invocation of the tool's registration during overall tools setup in registerTools.registerGetAccountDetails(server);
- src/tools/getAccountDetails.ts:31-43 (helper)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 }; }