toggl_stop_timer
Stop the currently running timer in Toggl Track to end time tracking sessions and update work logs.
Instructions
Stop the currently running timer
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:520-550 (handler)The main handler logic for the 'toggl_stop_timer' tool. It checks if there's a currently running timer, stops it using the TogglAPI, hydrates the entry with cached data (project/workspace names), and returns a formatted JSON response.case 'toggl_stop_timer': { const current = await api.getCurrentTimeEntry(); if (!current) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'No timer currently running' }) }] }; } const stopped = await api.stopTimer(current.workspace_id, current.id); await ensureCache(); const hydrated = await cache.hydrateTimeEntries([stopped]); return { content: [{ type: 'text', text: JSON.stringify({ success: true, message: 'Timer stopped', entry: hydrated[0] }, null, 2) }] }; }
- src/index.ts:218-226 (schema)The tool definition including name, description, and input schema (no parameters required). This is used for tool listing and validation.{ name: 'toggl_stop_timer', description: 'Stop the currently running timer', inputSchema: { type: 'object', properties: {}, required: [] }, },
- src/toggl-api.ts:221-224 (helper)Supporting utility method in TogglAPI class that stops a timer by updating the time entry with the current timestamp via the Toggl API PUT request.async stopTimer(workspaceId: number, timeEntryId: number): Promise<TimeEntry> { const now = new Date().toISOString(); return this.updateTimeEntry(workspaceId, timeEntryId, { stop: now }); }
- src/index.ts:386-388 (registration)Registration of the tool list handler, which returns the tools array containing 'toggl_stop_timer' when clients query available tools.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });