Get List Items
get_list_itemsRetrieve all items from a specific shopping list in AnyList. Use this tool to view list contents for shopping or meal planning.
Instructions
Get all items on a specific shopping list.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_name | Yes | Name of the list to retrieve items from |
Implementation Reference
- src/tools/lists.ts:46-76 (handler)The handler function for 'get_list_items' that fetches the specified list and formats its items.
async ({ list_name }) => { try { const client = AnyListClient.getInstance(); await client.getLists(); const list = client.getListByName(list_name); if (!list) { return { content: [{ type: 'text', text: `List not found: "${list_name}"` }], isError: true, }; } const result = list.items.map((i) => ({ id: i.identifier, name: i.name, quantity: i.quantity ?? null, details: i.details ?? null, checked: i.checked, })); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (error) { return { content: [{ type: 'text', text: `Error fetching list items: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, - src/tools/lists.ts:39-45 (schema)Input schema definition for the 'get_list_items' tool.
{ title: 'Get List Items', description: 'Get all items on a specific shopping list.', inputSchema: z.object({ list_name: z.string().describe('Name of the list to retrieve items from'), }), }, - src/tools/lists.ts:37-77 (registration)Registration call for the 'get_list_items' tool.
server.registerTool( 'get_list_items', { title: 'Get List Items', description: 'Get all items on a specific shopping list.', inputSchema: z.object({ list_name: z.string().describe('Name of the list to retrieve items from'), }), }, async ({ list_name }) => { try { const client = AnyListClient.getInstance(); await client.getLists(); const list = client.getListByName(list_name); if (!list) { return { content: [{ type: 'text', text: `List not found: "${list_name}"` }], isError: true, }; } const result = list.items.map((i) => ({ id: i.identifier, name: i.name, quantity: i.quantity ?? null, details: i.details ?? null, checked: i.checked, })); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (error) { return { content: [{ type: 'text', text: `Error fetching list items: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, );