UNPKG

@aot-tech/clockify-mcp-server

Version:

MCP Server for Clockify time tracking integration with AI tools

134 lines (133 loc) 5.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSummaryReportTool = exports.getDetailedReportTool = void 0; const zod_1 = require("zod"); const api_1 = require("../config/api"); const reports_1 = require("../clockify-sdk/reports"); exports.getDetailedReportTool = { name: api_1.TOOLS_CONFIG.reports.detailed.name, description: api_1.TOOLS_CONFIG.reports.detailed.description, parameters: { workspaceId: zod_1.z .string() .describe('The ID of the workspace to generate the report for'), dateRangeStart: zod_1.z .coerce .date() .describe('Start date for the report period (ISO format)'), dateRangeEnd: zod_1.z .coerce .date() .describe('End date for the report period (ISO format)'), users: zod_1.z .array(zod_1.z.string()) .optional() .describe('Array of user IDs to include in the report'), projects: zod_1.z .array(zod_1.z.string()) .optional() .describe('Array of project IDs to include in the report'), clients: zod_1.z .array(zod_1.z.string()) .optional() .describe('Array of client IDs to include in the report'), tags: zod_1.z .array(zod_1.z.string()) .optional() .describe('Array of tag IDs to include in the report'), includeTimeEntries: zod_1.z .boolean() .optional() .default(true) .describe('Whether to include detailed time entries in the report'), }, handler: async (params) => { try { const result = await reports_1.reportsService.getDetailedReport(params); const reportInfo = `Detailed report generated successfully for workspace ${params.workspaceId}`; let formattedData = ''; if (result.data) { formattedData = JSON.stringify(result.data, null, 2); } return { content: [ { type: 'text', text: `${reportInfo}\n\nReport Data:\n${formattedData}`, }, ], }; } catch (error) { throw new Error(`Failed to generate detailed report: ${error.message}`); } }, }; exports.getSummaryReportTool = { name: api_1.TOOLS_CONFIG.reports.summary.name, description: api_1.TOOLS_CONFIG.reports.summary.description, parameters: { workspaceId: zod_1.z .string() .describe('The ID of the workspace to generate the report for'), dateRangeStart: zod_1.z .coerce .date() .describe('Start date for the report period (ISO format)'), dateRangeEnd: zod_1.z .coerce .date() .describe('End date for the report period (ISO format)'), projects: zod_1.z .array(zod_1.z.string()) .optional() .describe('Array of project IDs to include in the report'), groups: zod_1.z .array(zod_1.z.string()) .optional() .describe('Array of group types for the report (e.g., ["USER", "TIMEENTRY"])'), users: zod_1.z.array(zod_1.z.string()) .optional() .describe('Array of user IDs to include in the report'), }, handler: async (params) => { try { const result = await reports_1.reportsService.getSummaryReport(params); const reportInfo = `Summary report generated successfully`; let formattedData = ''; if (result?.data) { let modifiedData = { ...result.data }; if (modifiedData.totals && Array.isArray(modifiedData.totals) && modifiedData.totals.length > 0) { modifiedData.totals = modifiedData.totals.map((item) => ({ ...item, totalTimeInHours: item?.totalTime ? item.totalTime / 3600 : 0, totalBillableTimeInHours: item?.totalBillableTime ? item.totalBillableTime / 3600 : 0, })); } modifiedData.groupOne = modifiedData.groupOne.map((item) => { const transformed = { ...item, durationInHours: item?.duration ? item.duration / 3600 : 0, }; return transformed; }); formattedData = JSON.stringify(modifiedData, null, 2); } else { console.log('No result.data found:', result); formattedData = JSON.stringify(result, null, 2); } return { content: [ { type: 'text', text: `${reportInfo}\n\nReport Data:\n${formattedData}`, }, ], }; } catch (error) { throw new Error(`Failed to generate summary report: ${error.message}`); } }, };