MCPcopy
hub / github.com/callumalpass/tasknotes / registerTimeTrackingTools

Method registerTimeTrackingTools

src/services/MCPService.ts:687–829  ·  view source on GitHub ↗
(server: McpServer)

Source from the content-addressed store, hash-verified

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

Callers 1

registerToolsMethod · 0.95

Calls 14

getToolRegistrarMethod · 0.95
errorResultMethod · 0.95
jsonResultMethod · 0.95
getErrorMessageMethod · 0.95
computeTimeSummaryFunction · 0.90
computeTaskTimeDataFunction · 0.90
getActiveTimeSessionMethod · 0.80
getTaskInfoMethod · 0.65
updateTaskMethod · 0.65
isCompletedStatusMethod · 0.65
startTimeTrackingMethod · 0.45

Tested by

no test coverage detected