reorder_checklist_item
Move checklist items to different positions to organize task sequences. Specify current and new positions using zero-based indexes.
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 for the 'reorder_checklist_item' tool. It validates the from_index and to_index, reads the current task data, moves the checklist item using array splice, updates and saves the task data, and returns a success or error message.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)The input schema definition for the 'reorder_checklist_item' tool, specifying required from_index and to_index as numbers with descriptions.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)The switch case in the CallToolRequest handler that routes calls to the reorderChecklistItem method.case 'reorder_checklist_item': return await this.reorderChecklistItem(request.params.arguments);
- src/index.ts:306-323 (registration)The tool registration in the ListTools response, including name, description, and input schema.{ 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'] } },