json_import
Import multiple to-dos and projects into Things 3 from JSON data arrays, supporting complex nested structures for batch task management.
Instructions
JSON批量导入待办事项和项目。支持复杂的嵌套结构。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | JSON数据数组,包含to-do和project对象 | |
| authToken | No | 授权令牌(如包含更新操作则必需) | |
| reveal | No | 是否显示第一个创建的项 |
Implementation Reference
- src/index.js:583-611 (handler)The handler function that implements the core logic of the 'json_import' tool. It processes the input arguments, stringifies the data, checks for update operations requiring authToken, builds a Things URL scheme using buildThingsUrl('json', params), executes it via openThingsUrl, and returns a success message.async handleJsonImport(args) { const authToken = args.authToken || DEFAULT_AUTH_TOKEN; const params = { data: JSON.stringify(args.data), reveal: args.reveal, }; // 如果数据中包含更新操作,需要授权令牌 const hasUpdate = args.data.some(item => item.operation === 'update'); if (hasUpdate && !authToken) { throw new Error('JSON数据包含更新操作,需要授权令牌'); } if (authToken) { params.authToken = authToken; } const url = buildThingsUrl('json', params); await this.openThingsUrl(url); return { content: [ { type: 'text', text: `✅ JSON导入命令已发送 (${args.data.length}个项目)`, }, ], }; }
- src/index.js:360-381 (schema)The input schema and metadata for the 'json_import' tool, defined in the ListTools response. Specifies the expected input structure including required 'data' array.{ name: 'json_import', description: 'JSON批量导入待办事项和项目。支持复杂的嵌套结构。', inputSchema: { type: 'object', properties: { data: { type: 'array', description: 'JSON数据数组,包含to-do和project对象', }, authToken: { type: 'string', description: '授权令牌(如包含更新操作则必需)', }, reveal: { type: 'boolean', description: '是否显示第一个创建的项', }, }, required: ['data'], }, },
- src/index.js:445-446 (registration)The dispatch case in the CallToolRequestSchema handler that routes 'json_import' calls to the handleJsonImport method.case 'json_import': return await this.handleJsonImport(args);