get_cash_account_statements
Retrieve detailed cash account statements using account ID to access transaction history and financial records for monitoring and analysis.
Instructions
Get cash account statements by account ID. Returns complete statement objects. Example: {"account_id":"cash_acc_123","limit":5}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes | Cash account ID | |
| cursor | No | Pagination cursor | |
| limit | No | Items per page (default 50, max 100) |
Implementation Reference
- Core execution logic for the get_cash_account_statements tool: parameter validation, API call to BrexClient, response formatting as JSON with statements and pagination meta.registerToolHandler("get_cash_account_statements", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const resp = await client.getCashAccountStatements(params.account_id, params.cursor, params.limit); // Return complete objects without any summarization const items = Array.isArray(resp?.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ statements: items, meta: { count: items.length, next_cursor: resp?.next_cursor || undefined } }, null, 2) }] }; } catch (error) { logError(`Error in get_cash_account_statements: ${error instanceof Error ? error.message : String(error)}`); throw error; } });
- src/tools/index.ts:222-232 (schema)MCP inputSchema definition for the tool, exposed in listTools response defining parameters account_id (required), cursor, limit.name: "get_cash_account_statements", description: "Get cash account statements by account ID. Returns complete statement objects. Example: {\"account_id\":\"cash_acc_123\",\"limit\":5}", 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 (default 50, max 100)" } }, required: ["account_id"] }
- src/tools/getCashAccountStatements.ts:33-60 (registration)Registers the tool handler function into the global toolHandlers Map using registerToolHandler.export function registerGetCashAccountStatements(_server: Server): void { registerToolHandler("get_cash_account_statements", async (request: ToolCallRequest) => { try { const params = validateParams(request.params.arguments); const client = getBrexClient(); const resp = await client.getCashAccountStatements(params.account_id, params.cursor, params.limit); // Return complete objects without any summarization const items = Array.isArray(resp?.items) ? resp.items : []; return { content: [{ type: "text", text: JSON.stringify({ statements: items, meta: { count: items.length, next_cursor: resp?.next_cursor || undefined } }, null, 2) }] }; } catch (error) { logError(`Error in get_cash_account_statements: ${error instanceof Error ? error.message : String(error)}`); throw error; } }); }
- src/tools/index.ts:57-57 (registration)Invokes the tool-specific registration during overall tools registration in registerTools(server).registerGetCashAccountStatements(server);
- Parameter validation and normalization function for tool inputs.function validateParams(input: unknown): GetCashAccountStatementsParams { const raw = (input || {}) as Record<string, unknown>; if (!raw.account_id) throw new Error("Missing required parameter: account_id"); const out: GetCashAccountStatementsParams = { 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; } return out; }
- src/services/brex/client.ts:309-323 (helper)Brex API client method that fetches cash account statements from /v2/accounts/cash/{id}/statements endpoint.async getCashAccountStatements(id: string, cursor?: string, limit?: number): Promise<PageStatement> { try { const params: Record<string, unknown> = {}; if (cursor) params.cursor = cursor; if (limit) params.limit = limit; logDebug(`Fetching statements for cash account ${id} from Brex API`); const response = await this.client.get(`/v2/accounts/cash/${id}/statements`, { params }); logDebug(`Successfully fetched ${response.data.items.length} statements for cash account ${id}`); return response.data; } catch (error) { this.handleApiError(error, 'GET', `/v2/accounts/cash/${id}/statements`); throw error; } }