UNPKG

@aot-tech/clockify-mcp-server

Version:

MCP Server for Clockify time tracking integration with AI tools

143 lines (142 loc) 4.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTeamManagersTool = exports.getAllGroupsTool = exports.getAllUsersTool = exports.getCurrentUserTool = void 0; const api_1 = require("../config/api"); const users_1 = require("../clockify-sdk/users"); const zod_1 = require("zod"); const entries_1 = require("./entries"); exports.getCurrentUserTool = { name: api_1.TOOLS_CONFIG.users.current.name, description: api_1.TOOLS_CONFIG.users.current.description, parameters: {}, handler: async () => { const response = await users_1.usersService.getCurrent(); const user = { id: response.data.id, name: response.data.name, email: response.data.email, }; return { content: [ { type: "text", text: JSON.stringify(user), }, ], }; }, }; exports.getAllUsersTool = { name: api_1.TOOLS_CONFIG.users.all.name, description: api_1.TOOLS_CONFIG.users.all.description, parameters: { workspaceId: zod_1.z .string() .describe('The id of the workspace that gonna search for the users'), name: zod_1.z .string() .describe('The name of the user that gonna be search').optional(), projectId: zod_1.z .string() .describe('The id of the project that gonna search for the users').optional(), }, handler: async (params) => { try { const result = await users_1.usersService.getAllUsers(params); const formmatedResults = result?.data?.map((entry) => ({ id: entry?.id, name: entry?.name, email: entry?.email, profilePicture: entry?.profilePicture, activeWorkspace: entry?.activeWorkspace, })); return { content: [ { type: 'text', text: `Clockify Users information with id, name, email, profilePicture: ${JSON.stringify(formmatedResults, null, 2)}`, json: formmatedResults, }, ], }; } catch (error) { throw new Error(`Failed to retrieve users: ${error.message}`); } }, }; exports.getAllGroupsTool = { name: api_1.TOOLS_CONFIG.users.allGroups.name, description: api_1.TOOLS_CONFIG.users.allGroups.description, parameters: { workspaceId: zod_1.z .string() .describe('The id of the workspace that gonna search for the entries'), projectId: zod_1.z .string() .describe('The id of the project that gonna search for the entries').optional(), name: zod_1.z .string() .describe('The name of the group that gonna be search').optional(), }, handler: async (params) => { try { const result = await users_1.usersService.getAllGroups(params); return { content: [ { type: 'text', text: `Clockify Groups for workspace and project and name: ${JSON.stringify(result?.data, null, 2)}`, }, ], }; } catch (error) { const errorMessage = (0, entries_1.extractErrorMessage)(error); return { content: [ { type: 'text', text: `Error retrieving groups: ${errorMessage}`, }, ], }; } }, }; exports.getTeamManagersTool = { name: api_1.TOOLS_CONFIG.users.teamManagers.name, description: api_1.TOOLS_CONFIG.users.teamManagers.description, parameters: { workspaceId: zod_1.z .string() .describe('The id of the workspace that gonna search for the entries'), userId: zod_1.z .string() .describe('The id of the user that gonna search for the entries'), }, handler: async (params) => { try { const result = await users_1.usersService.getTeamManagers(params); return { content: [ { type: 'text', text: JSON.stringify(result?.data), }, ], }; } catch (error) { const errorMessage = (0, entries_1.extractErrorMessage)(error); return { content: [ { type: 'text', text: `Error retrieving team managers: ${errorMessage}`, }, ], }; } } };