(server: McpServer)
| 685 | // Time Tracking Tools |
| 686 | |
| 687 | private registerTimeTrackingTools(server: McpServer): void { |
| 688 | const tool = this.getToolRegistrar(server); |
| 689 | |
| 690 | tool( |
| 691 | "tasknotes_start_time_tracking", |
| 692 | { |
| 693 | description: "Start a time tracking session on a task", |
| 694 | inputSchema: { |
| 695 | id: z.string().describe("Task file path"), |
| 696 | description: z.string().optional().describe("Description for the time session"), |
| 697 | }, |
| 698 | }, |
| 699 | async ({ id, description }: StartTimeTrackingArgs) => { |
| 700 | try { |
| 701 | const task = await this.cacheManager.getTaskInfo(id); |
| 702 | if (!task) { |
| 703 | return this.errorResult("Task not found"); |
| 704 | } |
| 705 | |
| 706 | let updatedTask = await this.taskService.startTimeTracking(task); |
| 707 | |
| 708 | // If description was provided, update the latest time entry |
| 709 | if ( |
| 710 | description && |
| 711 | updatedTask.timeEntries && |
| 712 | updatedTask.timeEntries.length > 0 |
| 713 | ) { |
| 714 | const latestEntry = |
| 715 | updatedTask.timeEntries[updatedTask.timeEntries.length - 1]; |
| 716 | if (latestEntry && !latestEntry.endTime) { |
| 717 | latestEntry.description = description; |
| 718 | updatedTask = await this.taskService.updateTask(updatedTask, { |
| 719 | timeEntries: updatedTask.timeEntries, |
| 720 | }); |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | return this.jsonResult(updatedTask); |
| 725 | } catch (error: unknown) { |
| 726 | return this.errorResult(this.getErrorMessage(error)); |
| 727 | } |
| 728 | } |
| 729 | ); |
| 730 | |
| 731 | tool( |
| 732 | "tasknotes_stop_time_tracking", |
| 733 | { |
| 734 | description: "Stop the active time tracking session on a task", |
| 735 | inputSchema: { id: z.string().describe("Task file path") }, |
| 736 | }, |
| 737 | async ({ id }: TaskIdArgs) => { |
| 738 | try { |
| 739 | const task = await this.cacheManager.getTaskInfo(id); |
| 740 | if (!task) { |
| 741 | return this.errorResult("Task not found"); |
| 742 | } |
| 743 | const updatedTask = await this.taskService.stopTimeTracking(task); |
| 744 |
no test coverage detected