create_task
Assign a task to one or more users in a Chatwork room with a description and optional due date.
Instructions
Assign a task to a user in a Chatwork room.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| room_id | Yes | The unique identifier of the Chatwork room. | |
| body | Yes | Task description/body. | |
| to_ids | Yes | Array of account IDs to assign the task to. | |
| limit | No | Task due date (Unix timestamp). |
Implementation Reference
- src/tools/createTask.ts:5-20 (handler)Defines the create_task tool handler. The executor calls client.createTask with room_id, body, to_ids, and optional limit, then returns the result as JSON.
export const createTaskTool = { name: "create_task", description: "Assign a task to a user in a Chatwork room.", schema: CreateTaskSchema, executor: async (client: ChatworkClient, args: z.infer<typeof CreateTaskSchema>) => { const result = await client.createTask(args.room_id, args.body, args.to_ids, args.limit); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2), }, ], }; }, }; - src/schemas/tasks.ts:3-8 (schema)Input schema for create_task tool: requires room_id (number), body (string), to_ids (array of numbers), and optional limit (number, Unix timestamp).
export const CreateTaskSchema = z.object({ room_id: z.number().describe("The unique identifier of the Chatwork room."), body: z.string().describe("Task description/body."), to_ids: z.array(z.number()).describe("Array of account IDs to assign the task to."), limit: z.number().optional().describe("Task due date (Unix timestamp)."), }); - src/index.ts:64-72 (registration)Registration of create_task tool with the MCP server using server.tool().
server.tool( createTaskTool.name, createTaskTool.description, createTaskTool.schema.shape, async (args) => { // @ts-ignore return createTaskTool.executor(client, args); } ); - src/api/client.ts:74-94 (helper)API client method that sends a POST request to /rooms/{roomId}/tasks to create a task on Chatwork.
async createTask(roomId: number, body: string, toIds: number[], limit?: number): Promise<{ task_ids: number[] }> { try { const params = new URLSearchParams(); params.append("body", body); params.append("to_ids", toIds.join(",")); if (limit) { params.append("limit", limit.toString()); } const response = await this.client.post<{ task_ids: number[] }>( `/rooms/${roomId}/tasks`, params ); return response.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Chatwork API Error (Create Task Room ${roomId}): ${error.message} - ${JSON.stringify(error.response?.data)}`); } throw error; } }