get_time_entries
Retrieve time entries for a user in Clockify by applying filters such as date range, project, task, tags, or running status. Manage and organize time tracking data efficiently using workspace and user IDs.
Instructions
Get time entries for a user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| consideredRunning | No | Include running time entries | |
| description | No | Filter by description | |
| end | No | End date filter (ISO 8601) | |
| hydrated | No | Include additional data | |
| inProgress | No | Filter by running status | |
| page | No | Page number (default: 1) | |
| pageSize | No | Page size (default: 50, max: 5000) | |
| project | No | Filter by project ID | |
| projectRequired | No | Filter entries that require project | |
| start | No | Start date filter (ISO 8601) | |
| tags | No | Filter by tag IDs (comma-separated) | |
| task | No | Filter by task ID | |
| taskRequired | No | Filter entries that require task | |
| userId | No | User ID (optional, defaults to current user) | |
| workspaceId | Yes | Workspace ID |
Implementation Reference
- src/index.ts:911-945 (handler)The core handler function implementing the get_time_entries tool logic. It constructs the Clockify API endpoint based on whether userId is provided, appends filter parameters as query string, fetches time entries, and returns a formatted text list of entries.private async getTimeEntries(args: any) { const { workspaceId, userId, ...params } = args; // Build query parameters const queryParams = new URLSearchParams(); Object.entries(params).forEach(([key, value]) => { if (value !== undefined && value !== null) { queryParams.append(key, String(value)); } }); const endpoint = userId ? `/workspaces/${workspaceId}/user/${userId}/time-entries` : `/workspaces/${workspaceId}/time-entries`; const fullEndpoint = queryParams.toString() ? `${endpoint}?${queryParams.toString()}` : endpoint; const timeEntries = await this.makeRequest(fullEndpoint); return { content: [ { type: "text", text: `Found ${timeEntries.length} time entries:\n${timeEntries .map((entry: any) => `- ${entry.description || "No description"} | ${entry.timeInterval.start} - ${entry.timeInterval.end || "Ongoing"} | ${entry.timeInterval.duration || "Running"}` ) .join("\n")}`, }, ], isError: false, }; }
- src/index.ts:303-322 (schema)JSON Schema defining the input parameters for the get_time_entries tool, specifying types, descriptions, and required fields like workspaceId.inputSchema: { type: "object", properties: { workspaceId: { type: "string", description: "Workspace ID" }, userId: { type: "string", description: "User ID (optional, defaults to current user)" }, description: { type: "string", description: "Filter by description" }, start: { type: "string", description: "Start date filter (ISO 8601)" }, end: { type: "string", description: "End date filter (ISO 8601)" }, project: { type: "string", description: "Filter by project ID" }, task: { type: "string", description: "Filter by task ID" }, tags: { type: "string", description: "Filter by tag IDs (comma-separated)" }, projectRequired: { type: "boolean", description: "Filter entries that require project" }, taskRequired: { type: "boolean", description: "Filter entries that require task" }, consideredRunning: { type: "boolean", description: "Include running time entries" }, hydrated: { type: "boolean", description: "Include additional data" }, inProgress: { type: "boolean", description: "Filter by running status" }, page: { type: "number", description: "Page number (default: 1)" }, pageSize: { type: "number", description: "Page size (default: 50, max: 5000)" }, }, required: ["workspaceId"],
- src/index.ts:301-323 (registration)Registration of the get_time_entries tool in the ListTools response, including name, description, and full input schema.name: "get_time_entries", description: "Get time entries for a user", inputSchema: { type: "object", properties: { workspaceId: { type: "string", description: "Workspace ID" }, userId: { type: "string", description: "User ID (optional, defaults to current user)" }, description: { type: "string", description: "Filter by description" }, start: { type: "string", description: "Start date filter (ISO 8601)" }, end: { type: "string", description: "End date filter (ISO 8601)" }, project: { type: "string", description: "Filter by project ID" }, task: { type: "string", description: "Filter by task ID" }, tags: { type: "string", description: "Filter by tag IDs (comma-separated)" }, projectRequired: { type: "boolean", description: "Filter entries that require project" }, taskRequired: { type: "boolean", description: "Filter entries that require task" }, consideredRunning: { type: "boolean", description: "Include running time entries" }, hydrated: { type: "boolean", description: "Include additional data" }, inProgress: { type: "boolean", description: "Filter by running status" }, page: { type: "number", description: "Page number (default: 1)" }, pageSize: { type: "number", description: "Page size (default: 50, max: 5000)" }, }, required: ["workspaceId"], },
- src/index.ts:734-736 (registration)Dispatch logic in the CallToolRequestSchema handler that validates input and invokes the getTimeEntries handler method.case "get_time_entries": if (!args?.workspaceId) throw new McpError(ErrorCode.InvalidParams, 'workspaceId is required'); return await this.getTimeEntries(args as any);