update_timeslip
Modify an existing timeslip entry to update hours worked, project details, dates, or comments for accurate time tracking in FreeAgent.
Instructions
Update an existing timeslip
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>"
},
"name": "update_timeslip"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Timeslip ID | |
| task | No | Task URL | |
| user | No | User URL | |
| project | No | Project URL | |
| dated_on | No | Date (YYYY-MM-DD) | |
| hours | No | Hours worked (e.g. "1.5") | |
| comment | No | Optional comment |
Implementation Reference
- src/index.ts:214-229 (handler)Main handler logic for the 'update_timeslip' tool: parses arguments, filters valid update fields, invokes the client method, and formats the response.
case 'update_timeslip': { const { id, ...updates } = request.params.arguments as { id: string } & Record<string, unknown>; // Only include valid update fields const validUpdates: Partial<TimeslipAttributes> = {}; if (typeof updates.task === 'string') validUpdates.task = updates.task; if (typeof updates.user === 'string') validUpdates.user = updates.user; if (typeof updates.project === 'string') validUpdates.project = updates.project; if (typeof updates.dated_on === 'string') validUpdates.dated_on = updates.dated_on; if (typeof updates.hours === 'string') validUpdates.hours = updates.hours; if (typeof updates.comment === 'string') validUpdates.comment = updates.comment; const timeslip = await this.client.updateTimeslip(id, validUpdates); return { content: [{ type: 'text', text: JSON.stringify(timeslip, null, 2) }] }; } - src/index.ts:133-149 (registration)Registration of the 'update_timeslip' tool in the ListTools response, defining name, description, and JSON input schema.
{ name: 'update_timeslip', description: 'Update an existing timeslip', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Timeslip ID' }, task: { type: 'string', description: 'Task URL' }, user: { type: 'string', description: 'User URL' }, project: { type: 'string', description: 'Project URL' }, dated_on: { type: 'string', description: 'Date (YYYY-MM-DD)' }, hours: { type: 'string', description: 'Hours worked (e.g. "1.5")' }, comment: { type: 'string', description: 'Optional comment' } }, required: ['id'] } }, - src/freeagent-client.ts:110-121 (helper)FreeAgentClient helper method that executes the HTTP PUT request to the FreeAgent API to update a timeslip.
async updateTimeslip(id: string, timeslip: Partial<TimeslipAttributes>): Promise<Timeslip> { try { console.error('[API] Updating timeslip:', id, timeslip); const response = await this.axiosInstance.put<TimeslipResponse>(`/timeslips/${id}`, { timeslip }); return response.data.timeslip; } catch (error) { console.error('[API] Failed to update timeslip:', error); throw error; } } - src/types.ts:1-13 (schema)TypeScript interface defining the structure of TimeslipAttributes used in update operations (Partial used in client method).
export interface TimeslipAttributes { url?: string; task: string; user: string; project: string; dated_on: string; hours: string; comment?: string; billed_on_invoice?: string; created_at?: string; updated_at?: string; timer?: TimerAttributes; }