Skip to main content
Glama

json_import

Import multiple to-dos and projects into Things 3 from JSON data with support for nested structures.

Instructions

JSON批量导入待办事项和项目。支持复杂的嵌套结构。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesJSON数据数组,包含to-do和project对象
authTokenNo授权令牌(如包含更新操作则必需)
revealNo是否显示第一个创建的项

Implementation Reference

  • The main handler function for the 'json_import' tool. It processes the input arguments, checks for updates requiring auth, builds a Things URL scheme command using buildThingsUrl('json', params), opens it, 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}个项目)`,
          },
        ],
      };
    }
  • Input schema definition for the json_import tool, specifying the expected JSON data array, optional authToken, and reveal flag.
    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)
    Dispatch case in the CallToolRequestSchema handler that routes calls to the json_import handler function.
    case 'json_import':
      return await this.handleJsonImport(args);
  • src/index.js:360-381 (registration)
    Tool descriptor registration in the ListToolsRequestSchema response, defining name, description, and schema.
    {
      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'],
      },
    },
  • Helper function specifically for building Things URLs for JSON imports, handling JSON serialization. Used indirectly via the general buildThingsUrl in the handler.
    export function buildJsonUrl(data, options = {}) {
      // JSON需要先序列化再编码
      const jsonString = JSON.stringify(data);
    
      const params = {
        data: jsonString,
        ...options,
      };
    
      return buildThingsUrl('json', params);
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Mieluoxxx/things_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server