stop_timer
Stop a running timer and finalize the time entry with calculated hours.
Instructions
Stop a running timer and finalize the time entry with calculated hours.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the running time entry to stop |
Implementation Reference
- src/tools/time-entries.ts:135-151 (handler)StopTimerHandler class implementing ToolHandler. Validates args with StopTimerSchema, calls harvestClient.stopTimer(), and returns the resulting time entry as JSON. Errors are caught and handled via handleMCPToolError.
class StopTimerHandler implements ToolHandler { constructor(private readonly config: BaseToolConfig) {} async execute(args: Record<string, any>): Promise<CallToolResult> { try { const validatedArgs = validateInput(StopTimerSchema, args, 'stop timer'); logger.info('Stopping timer via Harvest API', { timeEntryId: validatedArgs.id }); const timeEntry = await this.config.harvestClient.stopTimer(validatedArgs); return { content: [{ type: 'text', text: JSON.stringify(timeEntry, null, 2) }], }; } catch (error) { return handleMCPToolError(error, 'stop_timer'); } } } - src/tools/time-entries.ts:318-332 (registration)Registration of the 'stop_timer' tool in the registerTimeEntryTools function. Maps tool name 'stop_timer' with its input schema (id required) and handler (StopTimerHandler).
{ tool: { name: 'stop_timer', description: 'Stop a running timer and finalize the time entry with calculated hours.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'The ID of the running time entry to stop' }, }, required: ['id'], additionalProperties: false, }, }, handler: new StopTimerHandler(config), }, - src/schemas/time-entry.ts:170-172 (schema)StopTimerSchema Zod schema: validates input expects an object with a single required field: id (positive integer).
export const StopTimerSchema = z.object({ id: z.number().int().positive(), // Time entry ID }); - src/schemas/time-entry.ts:185-185 (schema)StopTimerInput type derived from StopTimerSchema.
export type StopTimerInput = z.infer<typeof StopTimerSchema>; - src/client/harvest-api.ts:126-127 (helper)Harvest API client delegates stopTimer to TimeEntriesClient. Entry point for the API call chain.
async stopTimer(input: StopTimerInput): Promise<any> { return this.timeEntriesClient.stopTimer(input);