create_time_entry
Log work hours in Clockify by creating time entries with start times, descriptions, and optional project, task, or tag assignments.
Instructions
Create a new time entry
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspaceId | Yes | Workspace ID | |
| description | No | Time entry description | |
| start | Yes | Start time (ISO 8601 format) | |
| end | No | End time (ISO 8601 format, optional for ongoing entries) | |
| projectId | No | Project ID (optional) | |
| taskId | No | Task ID (optional) | |
| tagIds | No | Array of tag IDs (optional) | |
| billable | No | Whether the entry is billable (optional) |
Implementation Reference
- src/index.ts:881-909 (handler)The core handler function that processes input arguments, formats dates to ISO 8601, makes a POST request to Clockify's /workspaces/{workspaceId}/time-entries API endpoint to create the time entry, and returns a formatted success message with entry details.private async createTimeEntry(args: any) { const { workspaceId, ...timeEntryData } = args; // Ensure start time is in ISO format if (!timeEntryData.start.includes("T")) { timeEntryData.start = new Date(timeEntryData.start).toISOString(); } // If end time is provided, ensure it's in ISO format if (timeEntryData.end && !timeEntryData.end.includes("T")) { timeEntryData.end = new Date(timeEntryData.end).toISOString(); } const timeEntry = await this.makeRequest( `/workspaces/${workspaceId}/time-entries`, "POST", timeEntryData ); return { content: [ { type: "text", text: `Time entry created successfully!\nID: ${timeEntry.id}\nDescription: ${timeEntry.description || "No description"}\nStart: ${timeEntry.timeInterval.start}\nEnd: ${timeEntry.timeInterval.end || "Ongoing"}`, }, ], isError: false, }; }
- src/index.ts:283-299 (registration)Registers the create_time_entry tool in the ListToolsRequestSchema response, including its description and detailed inputSchema for validation.name: "create_time_entry", description: "Create a new time entry", inputSchema: { type: "object", properties: { workspaceId: { type: "string", description: "Workspace ID" }, description: { type: "string", description: "Time entry description" }, start: { type: "string", description: "Start time (ISO 8601 format)" }, end: { type: "string", description: "End time (ISO 8601 format, optional for ongoing entries)" }, projectId: { type: "string", description: "Project ID (optional)" }, taskId: { type: "string", description: "Task ID (optional)" }, tagIds: { type: "array", items: { type: "string" }, description: "Array of tag IDs (optional)" }, billable: { type: "boolean", description: "Whether the entry is billable (optional)" }, }, required: ["workspaceId", "start"], }, },
- src/index.ts:731-733 (registration)In the CallToolRequestSchema handler's switch statement, maps incoming create_time_entry calls to the createTimeEntry method, with basic param validation.case "create_time_entry": if (!args?.workspaceId) throw new McpError(ErrorCode.InvalidParams, 'workspaceId is required'); return await this.createTimeEntry(args as any);
- src/index.ts:17-26 (schema)TypeScript interface defining the TimeEntry structure, which aligns with the tool's input schema properties.interface TimeEntry { id?: string; description?: string; start: string; end?: string; projectId?: string; taskId?: string; tagIds?: string[]; billable?: boolean; }