reorder_checklist_item
Move a checklist item to a new position by specifying its current and desired index, enabling organized task management within structured workflows.
Instructions
Moves a checklist item to a new position.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_index | Yes | The current index of the checklist item (0-based) | |
| to_index | Yes | The new index for the checklist item (0-based) |
Implementation Reference
- src/index.ts:908-952 (handler)The handler function that implements the core logic for reordering a checklist item. It validates the from_index and to_index parameters, moves the item in the checklist array using splice, recalculates progress, and persists the updated task data to the config file.private async reorderChecklistItem(args: any): Promise<any> { if (args?.from_index === undefined || args?.to_index === undefined) { throw new McpError(ErrorCode.InvalidParams, 'From index and to index are required'); } try { const taskData = await this.readTaskData(); // Check if the indices are valid if (args.from_index < 0 || args.from_index >= taskData.checklist.length) { throw new McpError(ErrorCode.InvalidParams, `Invalid from index: ${args.from_index}`); } if (args.to_index < 0 || args.to_index > taskData.checklist.length) { throw new McpError(ErrorCode.InvalidParams, `Invalid to index: ${args.to_index}`); } // Move the checklist item const [item] = taskData.checklist.splice(args.from_index, 1); taskData.checklist.splice(args.to_index, 0, item); // Write the updated task data to the file await this.writeTaskData(taskData); return { content: [ { type: 'text', text: 'Checklist item reordered successfully.', }, ], }; } catch (error) { console.error('Error reordering checklist item:', error); return { content: [ { type: 'text', text: `Error reordering checklist item: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- src/index.ts:309-322 (schema)Input schema defining the parameters for the tool: from_index and to_index as required numbers.inputSchema: { type: 'object', properties: { from_index: { type: 'number', description: 'The current index of the checklist item (0-based)' }, to_index: { type: 'number', description: 'The new index for the checklist item (0-based)' } }, required: ['from_index', 'to_index'] }
- src/index.ts:306-323 (registration)Registration of the tool in the ListTools response, providing name, description, and input schema for discovery.{ name: 'reorder_checklist_item', description: 'Moves a checklist item to a new position.', inputSchema: { type: 'object', properties: { from_index: { type: 'number', description: 'The current index of the checklist item (0-based)' }, to_index: { type: 'number', description: 'The new index for the checklist item (0-based)' } }, required: ['from_index', 'to_index'] } },
- src/index.ts:440-441 (registration)Switch case in the CallToolRequest handler that routes calls to the reorderChecklistItem method.case 'reorder_checklist_item': return await this.reorderChecklistItem(request.params.arguments);