Skip to main content
Glama

duplicate_record

Create independent copies of records in different database groups. Duplicates remain separate from originals — editing one does not affect the other. Specify destination group UUID to place the copy.

Instructions

Duplicate a record to any destination group, creating an independent copy. Unlike replicants, duplicates are completely separate records — editing one does not affect the other. The duplicate can be placed in a different database from the original. Destination group UUID is required. Returns the properties of the newly created duplicate.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uuidNoUUID of the record to duplicate
recordIdNoNumeric record ID (requires databaseName)
recordPathNoRecord path within the database (requires databaseName)
destinationGroupUuidYesUUID of the destination group for the duplicate
databaseNameNoDatabase name (required for recordId or recordPath lookups)

Implementation Reference

  • The 'run' function handles the logic for duplicating a DEVONthink record by constructing and executing a JXA script.
    run: async (args, executor) => {
      const { uuid, recordId, recordPath, destinationGroupUuid, databaseName } = args;
    
      const script = `
        ${JXA_APP}
        var uuid = ${jxaLiteral(uuid ?? null)};
        var recordId = ${jxaLiteral(recordId ?? null)};
        var recordPath = ${jxaLiteral(recordPath ?? null)};
        var recordName = null;
        var dbName = ${jxaLiteral(databaseName ?? null)};
        var destinationGroupUuid = ${jxaLiteral(destinationGroupUuid)};
    
        ${JXA_RESOLVE_DB}
        ${JXA_RESOLVE_RECORD}
    
        var destGroup = app.getRecordWithUuid(destinationGroupUuid);
        if (!destGroup || !destGroup.uuid()) throw new Error("Destination group not found for UUID: " + destinationGroupUuid);
    
        var duplicate = app.duplicate({record: record, to: destGroup});
        if (!duplicate || !duplicate.uuid()) throw new Error("Duplicate operation failed");
    
        var record = duplicate;
        JSON.stringify(${JXA_RECORD_PROPS});
      `;
    
      const result = executor.run(script);
      return JSON.parse(result.stdout);
    },
  • The Zod schema defines the input parameters for the 'duplicate_record' tool.
    schema: z.object({
      uuid: z.string().optional().describe("UUID of the record to duplicate"),
      recordId: z.number().int().nonnegative().optional().describe("Numeric record ID (requires databaseName)"),
      recordPath: z.string().optional().describe("Record path within the database (requires databaseName)"),
      destinationGroupUuid: z.string().describe("UUID of the destination group for the duplicate"),
      databaseName: z.string().optional().describe("Database name (required for recordId or recordPath lookups)"),
    }),
  • The tool is defined and exported as 'duplicateRecordTool' using the 'defineTool' helper.
    export const duplicateRecordTool = defineTool({
      name: "duplicate_record",
      description:
        "Duplicate a record to any destination group, creating an independent copy. " +
        "Unlike replicants, duplicates are completely separate records — editing one does not affect the other. " +
        "The duplicate can be placed in a different database from the original. " +
        "Destination group UUID is required. " +
        "Returns the properties of the newly created duplicate.",
      schema: z.object({
        uuid: z.string().optional().describe("UUID of the record to duplicate"),
        recordId: z.number().int().nonnegative().optional().describe("Numeric record ID (requires databaseName)"),
        recordPath: z.string().optional().describe("Record path within the database (requires databaseName)"),
        destinationGroupUuid: z.string().describe("UUID of the destination group for the duplicate"),
        databaseName: z.string().optional().describe("Database name (required for recordId or recordPath lookups)"),
      }),
      run: async (args, executor) => {
        const { uuid, recordId, recordPath, destinationGroupUuid, databaseName } = args;
    
        const script = `
          ${JXA_APP}
          var uuid = ${jxaLiteral(uuid ?? null)};
          var recordId = ${jxaLiteral(recordId ?? null)};
          var recordPath = ${jxaLiteral(recordPath ?? null)};
          var recordName = null;
          var dbName = ${jxaLiteral(databaseName ?? null)};
          var destinationGroupUuid = ${jxaLiteral(destinationGroupUuid)};
    
          ${JXA_RESOLVE_DB}
          ${JXA_RESOLVE_RECORD}
    
          var destGroup = app.getRecordWithUuid(destinationGroupUuid);
          if (!destGroup || !destGroup.uuid()) throw new Error("Destination group not found for UUID: " + destinationGroupUuid);
    
          var duplicate = app.duplicate({record: record, to: destGroup});
          if (!duplicate || !duplicate.uuid()) throw new Error("Duplicate operation failed");
    
          var record = duplicate;
          JSON.stringify(${JXA_RECORD_PROPS});
        `;
    
        const result = executor.run(script);
        return JSON.parse(result.stdout);
      },
    });

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/mnott/Devon'

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