Skip to main content
Glama

getUserTimeEntriesByName

Retrieve time entries for a specific user by name (partial or case-insensitive match) within optional date ranges using ISO8601 format.

Instructions

List time entries for a user by name (case-insensitive, partial match allowed). Optional: start, end (ISO8601).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endNoEnd date (ISO8601, optional)
startNoStart date (ISO8601, optional)
userNameYesUser name (partial/case-insensitive)

Implementation Reference

  • The main handler logic for the 'getUserTimeEntriesByName' tool. It resolves the user ID by searching users by name (case-insensitive partial match), then fetches the time entries for that user using the Clockify API, with optional date range.
    case "getUserTimeEntriesByName": { const { userName, start, end } = request.params.arguments || {}; if (!userName || typeof userName !== "string") { throw new Error("userName is required"); } // Fetch users const users = await clockifyFetch(`/workspaces/${workspaceId}/users`); // Define a type for user type User = { id: string; name: string }; // Find user by name (case-insensitive, partial match) const userMatch = (users as User[]).find( (u) => u.name && u.name.toLowerCase().includes(userName.toLowerCase()), ); if (!userMatch) { throw new Error(`No user found matching name: ${userName}`); } let url = `/workspaces/${workspaceId}/user/${userMatch.id}/time-entries`; const params = []; if (typeof start === "string" && start) params.push(`start=${encodeURIComponent(start)}`); if (typeof end === "string" && end) params.push(`end=${encodeURIComponent(end)}`); if (params.length) url += `?${params.join("&")}`; const entries = await clockifyFetch(url); return { content: [ { type: "text", text: JSON.stringify(entries, null, 2), }, ], }; }
  • The input schema for the 'getUserTimeEntriesByName' tool, defining the expected parameters: userName (required), start and end (optional). Returned by listToolsHandler.
    { name: "getUserTimeEntriesByName", description: "List time entries for a user by name (case-insensitive, partial match allowed). Optional: start, end (ISO8601).", inputSchema: { type: "object", properties: { userName: { type: "string", description: "User name (partial/case-insensitive)", }, start: { type: "string", description: "Start date (ISO8601, optional)", }, end: { type: "string", description: "End date (ISO8601, optional)", }, }, required: ["userName"], }, },
  • src/index.ts:49-49 (registration)
    Registration of the callToolHandler, which dispatches to the specific tool handler based on name.
    server.setRequestHandler(CallToolRequestSchema, callToolHandler);
  • src/index.ts:43-43 (registration)
    Registration of listToolsHandler, which lists the tool including its schema.
    server.setRequestHandler(ListToolsRequestSchema, listToolsHandler);
  • Helper function used by the handler to make authenticated API calls to Clockify, including fetching users and time entries.
    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(); }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/inakianduaga/clockify-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server