Skip to main content
Glama
Jtewen
by Jtewen

lookup-entity-by-id

Retrieve detailed information about an account, category, or payee in YNAB by specifying its ID. Use this tool to identify entities when only their ID is known.

Instructions

Look up the name and details of a specific account, category, or payee by its ID. A utility for when you have an ID but need the full context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idNoThe ID of the budget. If not provided, the default budget will be used.
entity_idYesThe ID of the entity to look up.
entity_typeYesThe type of entity to look up.

Implementation Reference

  • The handler function within the @server.call_tool() decorator that implements the core logic for the "lookup-entity-by-id" tool. It validates the input using LookupEntityByIdInput, retrieves the budget ID, calls appropriate ynab_client methods based on entity_type, and formats the response.
    elif name == "lookup-entity-by-id": args = LookupEntityByIdInput.model_validate(arguments or {}) budget_id = await _get_budget_id(args.model_dump()) entity = None if args.entity_type == "account": entity = await ynab_client.get_account_by_id(budget_id, args.entity_id) elif args.entity_type == "category": entity = await ynab_client.get_category_by_id(budget_id, args.entity_id) elif args.entity_type == "payee": entity = await ynab_client.get_payee_by_id(budget_id, args.entity_id) if not entity: return [ types.TextContent( type="text", text=f"No {args.entity_type} found with ID {args.entity_id}.", ) ] entity_dict = entity.to_dict() return [ types.TextContent( type="text", text=f"Found {args.entity_type}:\n{json.dumps(entity_dict, indent=2, default=str)}", ) ]
  • Pydantic input schema model for the tool, including EntityType enum and fields for entity_type and entity_id, inheriting from BudgetIdInput.
    class EntityType(str, Enum): ACCOUNT = "account" CATEGORY = "category" PAYEE = "payee" class LookupEntityByIdInput(BudgetIdInput): entity_type: EntityType = Field(..., description="The type of entity to look up.") entity_id: str = Field(..., description="The ID of the entity to look up.")
  • Tool registration in the @server.list_tools() handler, specifying name, description, and inputSchema derived from the Pydantic model.
    types.Tool( name="lookup-entity-by-id", description="Look up the name and details of a specific account, category, or payee by its ID. A utility for when you have an ID but need the full context.", inputSchema=LookupEntityByIdInput.model_json_schema(), ),

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