listUsers
Retrieve a complete list of all users within a Clockify workspace. This tool enables workspace admins to efficiently manage and review user access and roles.
Instructions
List all users in the workspace.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers.ts:229-239 (handler)The switch case that implements the core logic of the listUsers tool: fetches users from Clockify workspace API and formats response as JSON.case "listUsers": { const users = await clockifyFetch(`/workspaces/${workspaceId}/users`); return { content: [ { type: "text", text: JSON.stringify(users, null, 2), }, ], }; }
- src/handlers.ts:79-83 (schema)Tool schema definition for listUsers, provided by listToolsHandler, specifying name, description, and empty input schema.{ name: "listUsers", description: "List all users in the workspace.", inputSchema: { type: "object", properties: {}, required: [] }, },
- src/index.ts:43-43 (registration)Registers the listToolsHandler function, which exposes the listUsers tool schema to MCP clients.server.setRequestHandler(ListToolsRequestSchema, listToolsHandler);
- src/index.ts:49-49 (registration)Registers the callToolHandler function, which handles execution of the listUsers tool via switch case.server.setRequestHandler(CallToolRequestSchema, callToolHandler);
- src/handlers.ts:13-32 (helper)Helper function used by listUsers handler to make authenticated API calls to Clockify.async function clockifyFetch(endpoint: string, options: RequestInit = {}) { const apiKey = getApiKey(); const baseUrl = "https://api.clockify.me/api/v1"; const url = endpoint.startsWith("http") ? endpoint : `${baseUrl}${endpoint}`; const headers = { "X-Api-Key": apiKey, "Content-Type": "application/json", ...(options.headers || {}), }; const response = await fetch(url, { ...options, headers }); if (!response.ok) { const text = await response.text(); console.error( `[Error] Clockify API ${url} failed: ${response.status} ${text}`, ); throw new Error(`Clockify API error: ${response.status} ${text}`); } return response.json(); }