update_todo
Modify existing to-do items in the Things 3 app by updating titles, notes, deadlines, tags, checklist items, or completion status using the item ID.
Instructions
更新现有的待办事项。需要提供待办事项ID和授权令牌。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | 待办事项的ID(必需) | |
| authToken | No | 授权令牌(如未提供,将使用环境变量THINGS_AUTH_TOKEN) | |
| title | No | 新标题 | |
| notes | No | 新备注(替换现有) | |
| prependNotes | No | 在现有备注前添加 | |
| appendNotes | No | 在现有备注后添加 | |
| when | No | 时间安排 | |
| deadline | No | 截止日期 | |
| tags | No | 标签(替换所有) | |
| addTags | No | 添加标签 | |
| checklistItems | No | 清单项(替换所有) | |
| appendChecklistItems | No | 追加清单项 | |
| prependChecklistItems | No | 前置清单项 | |
| completed | No | 完成状态 | |
| canceled | No | 取消状态 | |
| reveal | No | 是否显示 |
Implementation Reference
- src/index.js:501-519 (handler)The main handler function that executes the logic for the 'update_todo' tool. It validates the auth token, builds the Things update URL, opens it, and returns a success message.async handleUpdateTodo(args) { const authToken = args.authToken || DEFAULT_AUTH_TOKEN; if (!authToken) { throw new Error('需要授权令牌。请设置环境变量THINGS_AUTH_TOKEN或在参数中提供authToken'); } const params = { ...args, authToken }; const url = buildThingsUrl('update', params); await this.openThingsUrl(url); return { content: [ { type: 'text', text: `✅ 待办事项更新命令已发送 (ID: ${args.id})`, }, ], }; }
- src/index.js:174-246 (schema)Input schema defining the parameters and validation rules for the 'update_todo' tool, including required 'id' and optional fields like title, notes, tags, etc.inputSchema: { type: 'object', properties: { id: { type: 'string', description: '待办事项的ID(必需)', }, authToken: { type: 'string', description: '授权令牌(如未提供,将使用环境变量THINGS_AUTH_TOKEN)', }, title: { type: 'string', description: '新标题', }, notes: { type: 'string', description: '新备注(替换现有)', }, prependNotes: { type: 'string', description: '在现有备注前添加', }, appendNotes: { type: 'string', description: '在现有备注后添加', }, when: { type: 'string', description: '时间安排', }, deadline: { type: 'string', description: '截止日期', }, tags: { type: 'string', description: '标签(替换所有)', }, addTags: { type: 'string', description: '添加标签', }, checklistItems: { type: 'array', items: { type: 'string' }, description: '清单项(替换所有)', }, appendChecklistItems: { type: 'array', items: { type: 'string' }, description: '追加清单项', }, prependChecklistItems: { type: 'array', items: { type: 'string' }, description: '前置清单项', }, completed: { type: 'boolean', description: '完成状态', }, canceled: { type: 'boolean', description: '取消状态', }, reveal: { type: 'boolean', description: '是否显示', }, }, required: ['id'], },
- src/index.js:171-247 (registration)Registration of the 'update_todo' tool in the ListToolsRequestSchema response, including name, description, and schema.{ name: 'update_todo', description: '更新现有的待办事项。需要提供待办事项ID和授权令牌。', inputSchema: { type: 'object', properties: { id: { type: 'string', description: '待办事项的ID(必需)', }, authToken: { type: 'string', description: '授权令牌(如未提供,将使用环境变量THINGS_AUTH_TOKEN)', }, title: { type: 'string', description: '新标题', }, notes: { type: 'string', description: '新备注(替换现有)', }, prependNotes: { type: 'string', description: '在现有备注前添加', }, appendNotes: { type: 'string', description: '在现有备注后添加', }, when: { type: 'string', description: '时间安排', }, deadline: { type: 'string', description: '截止日期', }, tags: { type: 'string', description: '标签(替换所有)', }, addTags: { type: 'string', description: '添加标签', }, checklistItems: { type: 'array', items: { type: 'string' }, description: '清单项(替换所有)', }, appendChecklistItems: { type: 'array', items: { type: 'string' }, description: '追加清单项', }, prependChecklistItems: { type: 'array', items: { type: 'string' }, description: '前置清单项', }, completed: { type: 'boolean', description: '完成状态', }, canceled: { type: 'boolean', description: '取消状态', }, reveal: { type: 'boolean', description: '是否显示', }, }, required: ['id'], }, },
- src/index.js:431-432 (registration)Dispatch case in the CallToolRequestSchema handler that routes 'update_todo' calls to the handleUpdateTodo function.case 'update_todo': return await this.handleUpdateTodo(args);
- src/utils.js:84-93 (helper)Helper function used by the handler to construct the Things URL scheme for the 'update' command with provided parameters.export function buildThingsUrl(command, params = {}) { const baseUrl = `things:///${command}`; const queryString = buildQueryString(params); if (!queryString) { return baseUrl; } return `${baseUrl}?${queryString}`; }