complete_task
Mark a Chatwork task as done by specifying the room ID and task ID.
Instructions
Mark a task as done.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| room_id | Yes | The unique identifier of the Chatwork room. | |
| task_id | Yes | The unique identifier of the task. |
Implementation Reference
- src/tools/completeTask.ts:5-33 (handler)The main executor for the complete_task tool. It calls client.updateTaskStatus(room_id, task_id, 'done') on the ChatworkClient API and returns a text result or error.
export const completeTaskTool = { name: "complete_task", description: "Mark a task as done.", schema: CompleteTaskSchema, executor: async (client: ChatworkClient, args: z.infer<typeof CompleteTaskSchema>) => { const { room_id, task_id } = args; try { const result = await client.updateTaskStatus(room_id, task_id, "done"); return { content: [ { type: "text" as const, text: `Task ${result.task_id} marked as done in room ${room_id}.`, }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Failed to complete task: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, }; - src/schemas/tasks.ts:15-18 (schema)Zod input validation schema for the complete_task tool: requires room_id (number) and task_id (number).
export const CompleteTaskSchema = z.object({ room_id: z.number().describe("The unique identifier of the Chatwork room."), task_id: z.number().describe("The unique identifier of the task."), }); - src/index.ts:93-102 (registration)Registration of the complete_task tool with the MCP server using server.tool(), wiring name, description, schema, and executor.
server.tool( completeTaskTool.name, completeTaskTool.description, completeTaskTool.schema.shape, async (args) => { // @ts-ignore return completeTaskTool.executor(client, args); } ); - src/api/client.ts:127-140 (helper)The ChatworkClient.updateTaskStatus() method that makes the PUT API call to /rooms/{roomId}/tasks/{taskId}/status with the status body.
async updateTaskStatus(roomId: number, taskId: number, status: "open" | "done" | "limit"): Promise<{ task_id: number }> { try { const response = await this.client.put<{ task_id: number }>( `/rooms/${roomId}/tasks/${taskId}/status`, new URLSearchParams({ body: status }) ); return response.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Chatwork API Error (Update Task Status Room ${roomId}): ${error.message} - ${JSON.stringify(error.response?.data)}`); } throw error; } } - src/tools/index.ts:8-8 (registration)Re-exports the completeTaskTool module from the tools barrel file.
export * from "./completeTask.js";