do_mark_task_as_done
Mark tasks as completed in the Do realm using the input task record name. Part of the addTaskManager MCP Server, ensuring tasks follow the Assess-Decide-Do framework workflow.
Instructions
Mark tasks as completed in Do realm.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskRecordName | Yes | Task record name |
Implementation Reference
- src/index.ts:524-533 (registration)Registration of the 'do_mark_task_as_done' tool in the listTools response, defining its name, description, and input schema requiring taskRecordName.name: 'do_mark_task_as_done', description: 'Mark tasks as completed in Do realm.', inputSchema: { type: 'object', properties: { taskRecordName: { type: 'string', description: 'Task record name' } }, required: ['taskRecordName'] } },
- src/index.ts:1415-1428 (handler)Core handler implementation. Validates the task exists and is in Do realm (ID 3). Simulates completion by generating current timestamp and returns success message indicating task marked done and moved to 'Done' collection (mock; production would update CloudKit record).private async markTaskAsDone(taskRecordName: string) { // Validate that task is in Do realm before marking as done const item = await this.mockFetchItem(taskRecordName, 'Task'); if (!item) { throw new McpError(ErrorCode.InvalidParams, `Task ${taskRecordName} not found`); } if (item.realmId !== REALM_DO_ID) { throw new McpError(ErrorCode.InvalidParams, `Task ${taskRecordName} must be in Do realm to mark as done. Current realm: ${item.realmId}. Move to Do realm first.`); } const completionTime = new Date().toISOString(); // Mock marking task as done via CloudKit - this would set realmId to 4 (Done) and move to Done collection return { content: [{ type: 'text', text: `Task ${taskRecordName} marked as done at ${completionTime}. Moved to Done collection (realm 4).` }] }; }
- src/index.ts:732-734 (registration)Tool call routing in the CallToolRequestSchema handler switch statement. Validates input arguments and delegates to the markTaskAsDone handler function.case 'do_mark_task_as_done': this.validateArgs(args, ['taskRecordName']); return await this.markTaskAsDone(args.taskRecordName);
- src/index.ts:1172-1198 (helper)Helper function used by the handler for mock-fetching item data to validate realm before marking as done. Simulates CloudKit query based on recordName patterns.private async mockFetchItem(itemRecordName: string, itemType: 'Task' | 'Project'): Promise<any> { // Mock different scenarios based on record name patterns const baseItem = { recordName: itemRecordName, type: itemType, lastModified: new Date().toISOString() }; // Simulate different states for validation testing if (itemRecordName.includes('assess')) { return { ...baseItem, realmId: REALM_ASSESS_ID, contextRecordName: null, endDate: null }; } else if (itemRecordName.includes('undecided')) { return { ...baseItem, realmId: REALM_DECIDE_ID, contextRecordName: null, endDate: null }; } else if (itemRecordName.includes('stalled')) { const yesterday = new Date(Date.now() - 86400000).toISOString(); return { ...baseItem, realmId: REALM_DECIDE_ID, contextRecordName: 'context_work', endDate: yesterday }; } else if (itemRecordName.includes('ready')) { const tomorrow = new Date(Date.now() + 86400000).toISOString(); return { ...baseItem, realmId: REALM_DECIDE_ID, contextRecordName: 'context_work', endDate: tomorrow }; } else if (itemRecordName.includes('do')) { const today = new Date().toISOString(); return { ...baseItem, realmId: REALM_DO_ID, contextRecordName: 'context_work', endDate: today }; } else { // Default to Assess realm item return { ...baseItem, realmId: REALM_ASSESS_ID, contextRecordName: null, endDate: null }; } }