chase_balance
Retrieve the current balance for a Chase account by entering the account ID. Returns the account's available balance.
Instructions
Get the current balance for a specific account.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | The account ID to check balance for |
Implementation Reference
- src/browser.ts:281-304 (handler)The actual getBalance handler function that fetches the account balance by finding the account from getAccounts() result.
export async function getBalance(accountId: string): Promise<{ success: boolean; balance?: number; availableBalance?: number; error?: string }> { try { const accountsResult = await getAccounts(); if (!accountsResult.success || !accountsResult.accounts) { return { success: false, error: "Failed to get accounts" }; } const account = accountsResult.accounts.find(a => a.id === accountId); if (!account) { return { success: false, error: `Account not found: ${accountId}` }; } return { success: true, balance: account.balance, availableBalance: account.availableBalance || account.balance, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : "Failed to get balance", }; } } - src/index.ts:77-91 (schema)Tool registration definition including input schema for chase_balance, requiring an 'accountId' string parameter.
{ name: "chase_balance", description: "Get the current balance for a specific account.", inputSchema: { type: "object", properties: { accountId: { type: "string", description: "The account ID to check balance for", }, }, required: ["accountId"], }, }, - src/index.ts:294-306 (registration)The tool execution handler that dispatches the 'chase_balance' tool call to the getBalance function from browser.ts.
case "chase_balance": { const { accountId } = args as { accountId: string }; const result = await getBalance(accountId); return { content: [ { type: "text", text: JSON.stringify(result), }, ], isError: !result.success, }; } - src/browser.ts:172-217 (helper)The getAccounts() helper function that getBalance depends on to find the account and its balance.
export async function getAccounts(): Promise<{ success: boolean; accounts?: Account[]; error?: string }> { try { const p = await getPage(); await p.goto(`${CHASE_BASE_URL}/web/auth/dashboard`, { waitUntil: "networkidle" }); await p.waitForTimeout(2000); const accounts = await p.$$eval( '.account-tile, .account-card, [data-testid="account-tile"]', (elements) => elements.map((el, index) => { const nameEl = el.querySelector('.account-name, .tile-header, h3'); const balanceEl = el.querySelector('.account-balance, .balance, [data-testid="balance"]'); const lastFourEl = el.querySelector('.account-last-four, .masked-number'); const typeEl = el.querySelector('.account-type'); const name = nameEl?.textContent?.trim() || `Account ${index + 1}`; const balanceText = balanceEl?.textContent?.trim() || '0'; const balance = parseFloat(balanceText.replace(/[$,]/g, '')) || 0; const lastFour = lastFourEl?.textContent?.trim().replace(/[^0-9]/g, '').slice(-4) || undefined; let type: 'checking' | 'savings' | 'credit' | 'investment' | 'loan' = 'checking'; const typeText = (typeEl?.textContent || name).toLowerCase(); if (typeText.includes('saving')) type = 'savings'; else if (typeText.includes('credit') || typeText.includes('card')) type = 'credit'; else if (typeText.includes('invest') || typeText.includes('brokerage')) type = 'investment'; else if (typeText.includes('loan') || typeText.includes('mortgage') || typeText.includes('auto')) type = 'loan'; return { id: el.getAttribute('data-account-id') || `account-${index}`, name, type, balance, lastFour, }; }), ); return { success: true, accounts }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : "Failed to get accounts", }; } } - src/index.ts:17-30 (helper)Import of the getBalance function from browser.ts module.
import { checkAuth, getAccounts, getTransactions, getBalance, getBills, getTransfers, getStatements, getRewards, initiateTransfer, payBill, getLoginUrl, cleanup, } from "./browser.js";