create_task
Define work types for time tracking by creating tasks that can be assigned to projects, specifying details like name, billable status, and hourly rates.
Instructions
Create a new task that can be assigned to projects for time tracking. Tasks define what type of work is being performed.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Task name (required) | |
| billable_by_default | No | Whether this task is billable by default | |
| default_hourly_rate | No | Default hourly rate for this task | |
| is_default | No | Whether this is a default task | |
| is_active | No | Whether the task is active |
Implementation Reference
- src/tools/tasks.ts:58-73 (handler)Implementation of the CreateTaskHandler which executes the tool logic.
class CreateTaskHandler implements ToolHandler { constructor(private readonly config: BaseToolConfig) {} async execute(args: Record<string, any>): Promise<CallToolResult> { try { const validatedArgs = validateInput(CreateTaskSchema, args, 'create task'); logger.info('Creating task via Harvest API'); const task = await this.config.harvestClient.createTask(validatedArgs); return { content: [{ type: 'text', text: JSON.stringify(task, null, 2) }], }; } catch (error) { return handleMCPToolError(error, 'create_task'); } } - src/schemas/task.ts:67-73 (schema)Input schema validation for creating a task.
export const CreateTaskSchema = z.object({ name: z.string().min(1, 'Task name is required'), billable_by_default: z.boolean().optional().default(true), default_hourly_rate: z.number().min(0).optional(), is_default: z.boolean().optional().default(false), is_active: z.boolean().optional().default(true), }); - src/tools/tasks.ts:148-166 (registration)Registration of the 'create_task' tool with its schema definition and handler.
{ tool: { name: 'create_task', description: 'Create a new task that can be assigned to projects for time tracking. Tasks define what type of work is being performed.', inputSchema: { type: 'object', properties: { name: { type: 'string', minLength: 1, description: 'Task name (required)' }, billable_by_default: { type: 'boolean', description: 'Whether this task is billable by default' }, default_hourly_rate: { type: 'number', minimum: 0, description: 'Default hourly rate for this task' }, is_default: { type: 'boolean', description: 'Whether this is a default task' }, is_active: { type: 'boolean', description: 'Whether the task is active' }, }, required: ['name'], additionalProperties: false, }, }, handler: new CreateTaskHandler(config), },