Skip to main content
Glama
Jtewen
by Jtewen

list-accounts

Retrieve all accounts linked to a specified budget, enabling users to obtain account IDs for integration with other tools or processes.

Instructions

List all accounts for a given budget. Useful for getting account IDs for other tools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idNoThe ID of the budget. If not provided, the default budget will be used.

Implementation Reference

  • The main handler for executing the 'list-accounts' tool. Validates input using ListAccountsInput, determines budget_id, fetches accounts via ynab_client, formats and returns the list.
    elif name == "list-accounts": args = ListAccountsInput.model_validate(arguments or {}) budget_id = await _get_budget_id(args.model_dump()) accounts = await ynab_client.get_accounts(budget_id=budget_id) if not accounts: return [types.TextContent(type="text", text="No accounts found for this budget.")] account_list = "\n".join( f"- {acc.name} (ID: {acc.id}): {acc.balance / 1000:.2f} (Type: {acc.type})" for acc in accounts ) return [ types.TextContent( type="text", text=f"Here are the accounts for budget {budget_id}:\n{account_list}", ) ]
  • Pydantic model for the input schema of 'list-accounts' tool. Inherits from BudgetIdInput, allowing optional budget_id.
    class ListAccountsInput(BudgetIdInput): pass
  • Base Pydantic model providing the optional budget_id field used by ListAccountsInput schema.
    class BudgetIdInput(BaseModel): budget_id: Optional[str] = Field( None, description="The ID of the budget. If not provided, the default budget will be used.", )
  • Registration of the 'list-accounts' tool in the list_tools handler, including name, description, and schema reference.
    types.Tool( name="list-accounts", description="List all accounts for a given budget. Useful for getting account IDs for other tools.", inputSchema=ListAccountsInput.model_json_schema(), ),
  • Helper function used by list-accounts handler to resolve the budget_id from input arguments, settings, or default budget.
    async def _get_budget_id(arguments: dict | None) -> str: """Gets the budget_id from arguments, settings, or falls back to the default budget.""" if settings.ynab_default_budget_id: return settings.ynab_default_budget_id if arguments and "budget_id" in arguments and arguments["budget_id"]: return arguments["budget_id"] budget = await ynab_client.get_default_budget() return budget.id

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/Jtewen/ynab-mcp'

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