get_share_holdings
Retrieve your Sharesight investment portfolio details including total value, returns breakdown, and per-holding information like symbol, shares, and value.
Instructions
Return the user's Sharesight investment portfolio: total value, breakdown (returns / capital / currency / dividends) and the per-holding list (symbol, shares, value, returns).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- akahu_mcp/server.py:70-88 (handler)The get_share_holdings tool handler: fetches fresh accounts from Akahu, finds the Sharesight account (by name/connection/type), and returns the investment portfolio data (total value, breakdown, per-holding list) from the account's balance and meta fields.
@mcp.tool() async def get_share_holdings(force: bool = False) -> dict[str, Any]: """Return the user's Sharesight investment portfolio: total value, breakdown (returns / capital / currency / dividends) and the per-holding list (symbol, shares, value, returns).""" accounts = await sync.ensure_accounts_fresh(force=force) sharesight = next((a for a in accounts if _is_sharesight(a)), None) if sharesight is None: return {"error": "No Sharesight account found in your Akahu connections"} meta = sharesight.get("meta") or {} bal = sharesight.get("balance") or {} return { "account_id": sharesight["_id"], "account_name": sharesight.get("name"), "total_value": bal.get("current"), "currency": bal.get("currency"), "breakdown": meta.get("breakdown") or {}, "portfolio": meta.get("portfolio") or [], } - akahu_mcp/server.py:70-70 (registration)The @mcp.tool() decorator registers get_share_holdings as a tool with the FastMCP server, making it available via stdio transport.
@mcp.tool() - akahu_mcp/server.py:24-32 (helper)Helper function used by get_share_holdings to identify the Sharesight account among the user's accounts by checking if the name, connection name, or type matches Sharesight-related values.
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)Called by get_share_holdings to get the account list (from cache or fresh from Akahu API), which is then filtered to find the Sharesight account.
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