create_task
Add tasks to Dida365 with details like title, project, due date, priority, and tags. Tasks without a project go to the inbox.
Instructions
创建新任务。可以指定标题、所属项目、截止日期、优先级、标签等。不指定项目则放入收集箱。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | 任务标题 | |
| project_id | No | 项目ID(可选,不填则放入收集箱) | |
| content | No | 任务内容/描述(可选) | |
| start_date | No | 开始日期(可选,ISO 8601格式,如 '2026-03-15T09:00:00+0800') | |
| due_date | No | 截止日期(可选,ISO 8601格式,如 '2026-03-15T18:00:00+0800') | |
| priority | No | 优先级(0=无, 1=低, 3=中, 5=高) | |
| is_all_day | No | 是否全天任务(可选) | |
| tags | No | 标签列表(可选) |
Implementation Reference
- src/dida_mcp/client.py:121-174 (handler)Implementation of the create_task tool logic in the DidaClient class, which makes the HTTP request to the Dida365 API to create a task.
def create_task( self, title: str, project_id: Optional[str] = None, content: Optional[str] = None, desc: Optional[str] = None, start_date: Optional[str] = None, due_date: Optional[str] = None, priority: int = 0, is_all_day: Optional[bool] = None, time_zone: Optional[str] = None, tags: Optional[List[str]] = None, ) -> Dict: """ 创建新任务 Args: title: 任务标题 project_id: 项目ID(不填则放入收集箱) content: 任务内容/描述 desc: 纯文本描述 start_date: 开始日期 (ISO 8601, 例如: "2026-03-15T09:00:00+0800") due_date: 截止日期 (ISO 8601) priority: 优先级 (0=无, 1=低, 3=中, 5=高) is_all_day: 是否全天任务 time_zone: 时区(例如 "Asia/Shanghai") tags: 标签列表 """ data: Dict[str, Any] = {"title": title} if project_id: data["projectId"] = project_id if content: data["content"] = content if desc: data["desc"] = desc if start_date: data["startDate"] = start_date if due_date: data["dueDate"] = due_date if priority: data["priority"] = priority if is_all_day is not None: data["isAllDay"] = is_all_day if time_zone: data["timeZone"] = time_zone else: data["timeZone"] = "Asia/Shanghai" if tags: data["tags"] = tags response = self.client.post("/task", json=data) response.raise_for_status() return response.json() - src/dida_mcp/server.py:148-187 (schema)Schema definition for the create_task tool, specifying input arguments and descriptions.
"name": "create_task", "description": "创建新任务。可以指定标题、所属项目、截止日期、优先级、标签等。不指定项目则放入收集箱。", "inputSchema": { "type": "object", "properties": { "title": {"type": "string", "description": "任务标题"}, "project_id": { "type": "string", "description": "项目ID(可选,不填则放入收集箱)", }, "content": { "type": "string", "description": "任务内容/描述(可选)", }, "start_date": { "type": "string", "description": "开始日期(可选,ISO 8601格式,如 '2026-03-15T09:00:00+0800')", }, "due_date": { "type": "string", "description": "截止日期(可选,ISO 8601格式,如 '2026-03-15T18:00:00+0800')", }, "priority": { "type": "integer", "description": "优先级(0=无, 1=低, 3=中, 5=高)", "enum": [0, 1, 3, 5], }, "is_all_day": { "type": "boolean", "description": "是否全天任务(可选)", }, "tags": { "type": "array", "items": {"type": "string"}, "description": "标签列表(可选)", }, }, "required": ["title"], }, }, - src/dida_mcp/server.py:347-359 (registration)Tool dispatching logic in the server that maps the 'create_task' request to the client method.
elif name == "create_task": task = client.create_task( title=args["title"], project_id=args.get("project_id"), content=args.get("content"), start_date=args.get("start_date"), due_date=args.get("due_date"), priority=args.get("priority", 0), is_all_day=args.get("is_all_day"), tags=args.get("tags"), ) return "✅ 任务创建成功!\n\n%s" % format_task(task)