create_time_entry
Automate time tracking by creating new entries in Clockify. Specify workspace, start and end times, project, task, tags, and billing status to manage time efficiently.
Instructions
Create a new time entry
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| billable | No | Whether the entry is billable (optional) | |
| description | No | Time entry description | |
| end | No | End time (ISO 8601 format, optional for ongoing entries) | |
| projectId | No | Project ID (optional) | |
| start | Yes | Start time (ISO 8601 format) | |
| tagIds | No | Array of tag IDs (optional) | |
| taskId | No | Task ID (optional) | |
| workspaceId | Yes | Workspace ID |
Implementation Reference
- src/index.ts:881-908 (handler)Core handler function for create_time_entry tool. Formats dates to ISO, makes POST request to Clockify /workspaces/{workspaceId}/time-entries API, and returns success response 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-298 (schema)Input schema definition for the create_time_entry tool, specifying parameters, types, descriptions, and required fields.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)Registration and dispatch logic in the CallToolRequestSchema handler that routes calls to the createTimeEntry method.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:252-299 (registration)The create_time_entry tool is included in the tools array returned by ListToolsRequestSchema handler for tool discovery.// User & Workspace Management { name: "get_current_user", description: "Get information about the current user", inputSchema: { type: "object", properties: {}, }, }, { name: "get_workspaces", description: "Get all workspaces for the current user", inputSchema: { type: "object", properties: {}, }, }, { name: "get_workspace_users", description: "Get all users in a workspace", inputSchema: { type: "object", properties: { workspaceId: { type: "string", description: "Workspace ID" }, }, required: ["workspaceId"], }, }, // Time Entry Management { 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:17-26 (schema)TypeScript interface defining the structure of a TimeEntry, matching the tool's input schema.interface TimeEntry { id?: string; description?: string; start: string; end?: string; projectId?: string; taskId?: string; tagIds?: string[]; billable?: boolean; }