whooing_latest_items
Retrieve unique transaction items from the past 60 days to populate autocomplete suggestions when adding new entries.
Instructions
Get recent unique transaction items from the past 60 days. Useful for autocomplete suggestions when adding new entries.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| section_id | No | Section ID. Defaults to WHOOING_SECTION_ID env var. |
Implementation Reference
- src/server.ts:1540-1553 (handler)The handler function for whooing_latest_items. Calls loadAccounts, then fetches entries/latest_items.json, formats results via formatLatestItems.
async (args) => { const sectionId = args.section_id ?? client.defaultSectionId; await client.loadAccounts(sectionId); const results = await client.apiGet("entries/latest_items.json", { section_id: sectionId, }); const text = formatLatestItems( results as Parameters<typeof formatLatestItems>[0], client.getAccountCache() ); return { content: [{ type: "text", text }] }; } - src/server.ts:1526-1554 (registration)Registration of the whooing_latest_items tool with description, inputSchema (optional section_id), and readOnlyHint annotation.
server.registerTool( "whooing_latest_items", { description: "Get recent unique transaction items from the past 60 days. " + "Useful for autocomplete suggestions when adding new entries.", inputSchema: { section_id: z .string() .optional() .describe("Section ID. Defaults to WHOOING_SECTION_ID env var."), }, annotations: { readOnlyHint: true }, }, async (args) => { const sectionId = args.section_id ?? client.defaultSectionId; await client.loadAccounts(sectionId); const results = await client.apiGet("entries/latest_items.json", { section_id: sectionId, }); const text = formatLatestItems( results as Parameters<typeof formatLatestItems>[0], client.getAccountCache() ); return { content: [{ type: "text", text }] }; } ); - src/server.ts:1532-1537 (schema)Input schema for whooing_latest_items: optional section_id string parameter.
inputSchema: { section_id: z .string() .optional() .describe("Section ID. Defaults to WHOOING_SECTION_ID env var."), }, - src/formatters.ts:754-776 (helper)formatLatestItems function that formats the API results (array of LatestItem) into a human-readable markdown string with account names resolved from cache.
export function formatLatestItems( results: LatestItem[], accounts: Map<string, AccountInfo> ): string { const lines: string[] = []; lines.push("## 최근 거래 항목 (자동완성용)"); lines.push(""); if (!Array.isArray(results) || results.length === 0) { lines.push("최근 60일간 거래 항목이 없습니다."); return lines.join("\n"); } for (const item of results) { const lName = accounts.get(item.l_account_id)?.name ?? item.l_account_id; const rName = accounts.get(item.r_account_id)?.name ?? item.r_account_id; lines.push( `- **${item.item}** ${formatAmount(item.money)} [${lName} ← ${rName}]` ); } return lines.join("\n"); } - src/formatters.ts:3-9 (helper)formatAmount helper used by formatLatestItems to format monetary amounts in Korean won (KRW) with locale formatting.
function formatAmount(amount: number | string | null | undefined): string { const numeric = Number(amount ?? 0); if (!Number.isFinite(numeric)) { return `${amount ?? 0}원`; } return numeric.toLocaleString("ko-KR") + "원"; }