update_list
Modify existing list contents by replacing items with a new array to add, remove, or reorder elements 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:370-394 (handler)Handler function that checks if the list exists by ID, updates the items in the global 'lists' Map, and returns a success message with old and new item counts or an error if list not found.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:354-369 (schema)Input schema definition using Zod for validating list_id (string) and items (array of strings), along with tool description.{ 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.", ), }, },
- src/index.ts:352-396 (registration)Registration of the 'update_list' tool using McpServer.registerTool, including schema and handler.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:138-138 (helper)Global Map storing all lists by ID, used by update_list to check existence and update contents.const lists = new Map<string, string[]>();