import { z } from "zod";
import { makeApiRequest } from "../api.js";
import _ from 'lodash'
/**
* Tool to get current user information from Clockify API.
*/
export const iamTool = {
name: "clockify-whoami",
config: {
description: `
Get current user information from Clockify API.
PREREQUISITE: Must be called first before any other tool from this server.
`,
inputSchema: {},
outputSchema: {
id: z.string().describe("The user id of the current user"),
email: z.string().describe("The email of the current user"),
name: z.string().describe("The name of the current user"),
activeWorkspace: z.string().describe("The id of the active workspace"),
defaultWorkspace: z.string().describe("The id of the default workspace")
}
},
handler: async () => {
const result = await makeApiRequest("/user");
const structuredContent = _.pick(result, ['id', 'email', 'name', 'activeWorkspace', 'defaultWorkspace'])
return {
content: [{
type: "text",
text: JSON.stringify(structuredContent, null, 2)
}],
structuredContent: structuredContent || {}
};
}
};