update_list
Modify existing lists by replacing items with new arrays to add, remove, or reorder content in the par5-mcp server.
Instructions
Updates an existing list by replacing its items with a new array.
WHEN TO USE:
To modify the contents of an existing list
To add or remove items from a list
To reorder items in a list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | The list ID returned by create_list. | |
| items | Yes | The new array of items to replace the existing list contents. |
Implementation Reference
- src/index.ts:357-381 (handler)Handler function for the 'update_list' tool. Checks if the list exists, updates the items in the shared 'lists' Map, and returns a success message with old and new item counts.async ({ list_id, items }) => { if (!lists.has(list_id)) { return { content: [ { type: "text", text: `Error: No list found with ID "${list_id}". The list may have been deleted or the ID is incorrect. Use create_list to create a new list.`, }, ], isError: true, }; } const oldCount = lists.get(list_id)?.length; lists.set(list_id, items); return { content: [ { type: "text", text: `Successfully updated list "${list_id}". Changed from ${oldCount} items to ${items.length} items.`, }, ], }; },
- src/index.ts:348-355 (schema)Zod inputSchema for 'update_list' tool defining parameters: list_id (string) and items (array of strings).inputSchema: { list_id: z.string().describe("The list ID returned by create_list."), items: z .array(z.string()) .describe( "The new array of items to replace the existing list contents.", ), },
- src/index.ts:339-382 (registration)server.registerTool call registering the 'update_list' tool with its metadata (description and inputSchema) and handler function.server.registerTool( "update_list", { description: `Updates an existing list by replacing its items with a new array. WHEN TO USE: - To modify the contents of an existing list - To add or remove items from a list - To reorder items in a list`, inputSchema: { list_id: z.string().describe("The list ID returned by create_list."), items: z .array(z.string()) .describe( "The new array of items to replace the existing list contents.", ), }, }, async ({ list_id, items }) => { if (!lists.has(list_id)) { return { content: [ { type: "text", text: `Error: No list found with ID "${list_id}". The list may have been deleted or the ID is incorrect. Use create_list to create a new list.`, }, ], isError: true, }; } const oldCount = lists.get(list_id)?.length; lists.set(list_id, items); return { content: [ { type: "text", text: `Successfully updated list "${list_id}". Changed from ${oldCount} items to ${items.length} items.`, }, ], }; }, );
- src/index.ts:125-125 (helper)Shared 'lists' Map<string, string[]> used by update_list (and other list tools) to store list items by ID.const lists = new Map<string, string[]>();