Skip to main content
Glama

getTimeEntries

Retrieve time entries for the authenticated user within specified date ranges using ISO8601 format. Simplify tracking and reporting with customizable start and end dates.

Instructions

List time entries for the authenticated user. Optional: start, end (ISO8601).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endNoEnd date (ISO8601, optional)
startNoStart date (ISO8601, optional)

Implementation Reference

  • The switch case in callToolHandler that implements the getTimeEntries tool. It constructs the Clockify API URL for the current user's time entries with optional start and end parameters, fetches the data, and returns it as JSON.
    case "getTimeEntries": { const { start, end } = request.params.arguments || {}; let url = `/workspaces/${workspaceId}/user/${userId}/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), }, ], }; }
  • src/handlers.ts:43-61 (registration)
    The tool definition in listToolsHandler, registering 'getTimeEntries' with its description and input schema (optional start and end dates as ISO8601 strings).
    { name: "getTimeEntries", description: "List time entries for the authenticated user. Optional: start, end (ISO8601).", inputSchema: { type: "object", properties: { start: { type: "string", description: "Start date (ISO8601, optional)", }, end: { type: "string", description: "End date (ISO8601, optional)", }, }, required: [], }, },
  • Input schema for getTimeEntries tool, defining optional 'start' and 'end' properties as strings.
    inputSchema: { type: "object", properties: { start: { type: "string", description: "Start date (ISO8601, optional)", }, end: { type: "string", description: "End date (ISO8601, optional)", }, }, required: [], },
  • clockifyFetch helper function used by the 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(); }
  • getApiKey helper function to retrieve the Clockify API key from environment.
    function getApiKey(): string { const apiKey = process.env.CLOCKIFY_API_KEY; if (!apiKey) { throw new Error("CLOCKIFY_API_KEY is not set in MCP config."); } return apiKey; }

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