add_todo
Create a new reminder or task with optional description and natural language time parsing for automated notifications.
Instructions
添加待办事项
Args: title: 待办事项标题 remind_time: 提醒时间(可选),支持自然语言如"明天下午3点" description: 待办事项描述(可选)
Returns: 包含待办ID和确认信息的字典
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| remind_time | No | ||
| description | No |
Implementation Reference
- src/mcp_reminder/server.py:142-193 (handler)The `add_todo` tool handler, registered with the MCP server, responsible for parsing the reminder time, creating a `Todo` object, and persisting it via the storage layer.
@mcp.tool() def add_todo(title: str, remind_time: str = "", description: str = "") -> dict: """ 添加待办事项 Args: title: 待办事项标题 remind_time: 提醒时间(可选),支持自然语言如"明天下午3点" description: 待办事项描述(可选) Returns: 包含待办ID和确认信息的字典 """ if not title: return { "success": False, "error": "待办事项标题不能为空" } # 解析提醒时间 parsed_remind_time = None if remind_time: parsed_remind_time = parse_time(remind_time) if not parsed_remind_time: return { "success": False, "error": f"无法解析提醒时间: {remind_time}" } # 创建待办事项 todo = Todo( title=title, description=description, remind_time=parsed_remind_time ) # 保存待办 storage.add_todo(todo) logger.info(f"添加待办: {todo.title}, 提醒时间: {todo.remind_time}") message = f"已添加待办: {title}" if parsed_remind_time: message += f",将在 {parsed_remind_time} 提醒" return { "success": True, "todo_id": todo.id, "title": todo.title, "remind_time": todo.remind_time, "message": message }