Skip to main content
Glama
JosueM1109

personal-finance-mcp

List Accounts

list_accounts
Read-only

Retrieve a list of all linked financial accounts with current balances, including warnings for accounts needing attention like re-authentication or API errors.

Instructions

List every account across all linked Items, with balances.

Returns: {"accounts": [...], "warnings": [...]}. Warnings describe Items that are unhealthy (re-auth required, etc.) or hit API errors on this call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • server.py:40-63 (handler)
    Core implementation function _list_accounts_impl that iterates all linked Plaid Items, fetches accounts via Plaid API, shapes them, and returns a dict with accounts and warnings.
    def _list_accounts_impl() -> dict:
        """List every account across all linked Items, with balances.
    
        Returns:
            {"accounts": [...], "warnings": [...]}. Warnings describe Items that
            are unhealthy (re-auth required, etc.) or hit API errors on this call.
        """
        api = build_api()
        accounts: list[dict] = []
        warnings: list[dict] = []
        for env_key, token, health in all_items(api):
            if health.status != "healthy":
                warnings.append(_warning_from_health(health))
                continue
            try:
                resp = api.accounts_get(
                    AccountsGetRequest(access_token=token.reveal())
                ).to_dict()
                for raw in resp.get("accounts", []):
                    accounts.append(shape_account(raw, health.institution_name))
            except ApiException as e:
                mapped = map_plaid_error(e, health.institution_name)["error"]
                warnings.append({"institution": health.institution_name, **mapped})
        return {"accounts": accounts, "warnings": warnings}
  • server.py:66-69 (registration)
    Registration of list_accounts as a FastMCP tool with read-only hint and title annotation, wrapping _list_accounts_impl.
    list_accounts = mcp.tool(
        name="list_accounts",
        annotations={"readOnlyHint": True, "title": "List Accounts"},
    )(_list_accounts_impl)
  • Helper _warning_from_health used by _list_accounts_impl to convert ItemHealth to a warning dict.
    def _warning_from_health(h: ItemHealth) -> dict:
        return {
            "institution": h.institution_name or h.env_key,
            "status": h.status,
            "reason": h.reason,
        }
  • Test verifying list_accounts aggregates accounts from healthy items and warns on unhealthy items.
    def test_list_accounts_aggregates_across_items(fake_env_tokens):
        fake_api = MagicMock()
        fake_api.accounts_get.return_value.to_dict.return_value = {
            "accounts": [
                {
                    "account_id": "a1",
                    "name": "Checking",
                    "mask": "0001",
                    "type": "depository",
                    "subtype": "checking",
                    "balances": {"current": 100, "available": 100, "iso_currency_code": "USD"},
                },
            ],
        }
        items = [
            ("CHASE", SecretStr("t"), ItemHealth("CHASE", "healthy", "ins_3", "Chase")),
            ("FIDELITY", SecretStr("t2"), ItemHealth("FIDELITY", "re_auth_required", "ins_9", "Fidelity", reason="ITEM_LOGIN_REQUIRED")),
        ]
        with patch.object(srv, "build_api", return_value=fake_api), \
             patch.object(srv, "all_items", return_value=items):
            out = srv._list_accounts_impl()
        assert len(out["accounts"]) == 1
        assert out["accounts"][0]["institution"] == "Chase"
        assert out["accounts"][0]["handle"] == "chase_checking_0001"
        assert len(out["warnings"]) == 1
        assert out["warnings"][0]["institution"] == "Fidelity"
        assert out["warnings"][0]["status"] == "re_auth_required"
    
    
    def test_list_accounts_surfaces_api_exception_as_warning(fake_env_tokens):
        from plaid.exceptions import ApiException
        fake_api = MagicMock()
        exc = ApiException(status=500, reason="boom")
        exc.body = '{"error_code":"INTERNAL_SERVER_ERROR","error_message":"plaid down"}'
        fake_api.accounts_get.side_effect = exc
        items = [("CHASE", SecretStr("t"), ItemHealth("CHASE", "healthy", "ins_3", "Chase"))]
        with patch.object(srv, "build_api", return_value=fake_api), \
             patch.object(srv, "all_items", return_value=items):
  • Test verifying list_accounts surfaces Plaid API exceptions as warnings.
    def test_list_accounts_surfaces_api_exception_as_warning(fake_env_tokens):
        from plaid.exceptions import ApiException
        fake_api = MagicMock()
        exc = ApiException(status=500, reason="boom")
        exc.body = '{"error_code":"INTERNAL_SERVER_ERROR","error_message":"plaid down"}'
        fake_api.accounts_get.side_effect = exc
        items = [("CHASE", SecretStr("t"), ItemHealth("CHASE", "healthy", "ins_3", "Chase"))]
        with patch.object(srv, "build_api", return_value=fake_api), \
             patch.object(srv, "all_items", return_value=items):
            out = srv._list_accounts_impl()
        assert out["accounts"] == []
        assert len(out["warnings"]) == 1
        w = out["warnings"][0]
        assert w["institution"] == "Chase"
        assert w["code"] == "INTERNAL_SERVER_ERROR"
        assert w["trace_id"]
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate readOnlyHint=true. The description adds value by detailing the return format including warnings for unhealthy Items and API errors, which goes beyond the annotation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no fluff. The return format is included concisely.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters and presence of output schema (implied), the description is fully complete. It explains the output structure and warning semantics.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With zero parameters and 100% schema coverage, the description need not explain parameters. It appropriately focuses on the tool's behavior and output.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb 'List' and resource 'accounts' with scope 'across all linked Items'. It clearly distinguishes from siblings like 'get_balances' which are more specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving all accounts, but does not explicitly state when to use this tool versus alternatives or provide exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JosueM1109/personal-finance-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server