list_accounts
Retrieve a list of your bank and depository accounts from Akahu. Data is cached for 24 hours; use force=True to fetch fresh data.
Instructions
List the user's bank/depository accounts (excludes Sharesight, which has its own tool). Cached for 24h; pass force=True to refresh from Akahu.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- akahu_mcp/server.py:62-67 (registration)Tool registration via @mcp.tool() decorator — the 'list_accounts' tool is registered as a FastMCP tool on the 'akahu' server.
@mcp.tool() async def list_accounts(force: bool = False) -> list[dict[str, Any]]: """List the user's bank/depository accounts (excludes Sharesight, which has its own tool). Cached for 24h; pass force=True to refresh from Akahu.""" accounts = await sync.ensure_accounts_fresh(force=force) return [_trim_account(a) for a in accounts if not _is_sharesight(a)] - akahu_mcp/server.py:62-67 (handler)Handler function — 'list_accounts' async function that calls ensure_accounts_fresh, filters out Sharesight accounts via _is_sharesight, and trims each result via _trim_account.
@mcp.tool() async def list_accounts(force: bool = False) -> list[dict[str, Any]]: """List the user's bank/depository accounts (excludes Sharesight, which has its own tool). Cached for 24h; pass force=True to refresh from Akahu.""" accounts = await sync.ensure_accounts_fresh(force=force) return [_trim_account(a) for a in accounts if not _is_sharesight(a)] - akahu_mcp/server.py:35-49 (helper)Helper function — _trim_account reduces the raw account dict to a slimmed-down version with id, name, type, formatted_account, balance (current/available/currency), and connection name.
def _trim_account(acc: dict[str, Any]) -> dict[str, Any]: """Return a slimmed-down account dict suitable for an LLM.""" bal = acc.get("balance") or {} return { "id": acc["_id"], "name": acc.get("name"), "type": acc.get("type"), "formatted_account": acc.get("formatted_account"), "balance": { "current": bal.get("current"), "available": bal.get("available"), "currency": bal.get("currency"), }, "connection": (acc.get("connection") or {}).get("name"), } - akahu_mcp/server.py:24-32 (helper)Helper function — _is_sharesight filters out Sharesight/investment accounts by checking name, connection name, and type for 'sharesight', 'investment', or 'wealth'.
def _is_sharesight(acc: dict[str, Any]) -> bool: name = (acc.get("name") or "").lower() conn_name = ((acc.get("connection") or {}).get("name") or "").lower() acc_type = (acc.get("type") or "").lower() return ( "sharesight" in name or "sharesight" in conn_name or acc_type in {"investment", "wealth"} ) - akahu_mcp/sync.py:33-44 (helper)Helper function — ensure_accounts_fresh checks the SQLite cache first (24h TTL), and if stale or force=True, fetches accounts from the Akahu API via AkahuClient.get_accounts() and stores them in cache.
async def ensure_accounts_fresh(force: bool = False) -> list[dict[str, Any]]: """Return the account list, refreshing from Akahu if cache is stale or `force`.""" cache.init_db() if not force: cached = cache.get_accounts_cached(DEFAULT_TTL_SECONDS) if cached is not None: return cached logger.info("Refreshing accounts from Akahu (force=%s)", force) client = AkahuClient() accounts = await client.get_accounts() cache.put_accounts(accounts) return accounts