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
| Name | Required | Description | Default |
|---|---|---|---|
| budget_id | No | The ID of the budget. If not provided, the default budget will be used. | |
| entity_id | Yes | The ID of the entity to look up. | |
| entity_type | Yes | The type of entity to look up. |
Implementation Reference
- src/ynab_mcp_server/server.py:533-559 (handler)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.")
- src/ynab_mcp_server/server.py:115-119 (registration)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(), ),