get_record_by_identifier
Retrieve DEVONthink records using UUIDs for cross-database access or numeric IDs with database specification to locate documents and metadata efficiently.
Instructions
Get a DEVONthink record using its UUID or ID. UUID lookup works across all open databases. Numeric ID lookup requires databaseName to be specified.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uuid | No | UUID of the record (preferred — works across all databases) | |
| id | No | Numeric record ID (requires databaseName) | |
| databaseName | No | Database name (required when using numeric id) |
Implementation Reference
- The complete definition and handler for the get_record_by_identifier tool.
export const getRecordByIdTool = defineTool({ name: "get_record_by_identifier", description: "Get a DEVONthink record using its UUID or ID. " + "UUID lookup works across all open databases. " + "Numeric ID lookup requires databaseName to be specified.", schema: z.object({ uuid: z.string().optional().describe("UUID of the record (preferred — works across all databases)"), id: z.number().int().nonnegative().optional().describe("Numeric record ID (requires databaseName)"), databaseName: z.string().optional().describe("Database name (required when using numeric id)"), }), run: async (args, executor) => { const { uuid, id, databaseName } = args; if (!uuid && id === undefined) { return { error: "Either uuid or id must be provided" }; } const script = ` ${JXA_APP} var uuid = ${jxaLiteral(uuid ?? null)}; var recordId = ${jxaLiteral(id ?? null)}; var dbName = ${jxaLiteral(databaseName ?? null)}; ${JXA_RESOLVE_DB} var record; if (uuid) { record = app.getRecordWithUuid(uuid); if (!record || !record.uuid()) throw new Error("Record not found for UUID: " + uuid); } else { if (!db) throw new Error("databaseName is required when using numeric id"); record = db.getRecordAt(recordId); if (!record || !record.uuid()) throw new Error("Record not found for ID: " + recordId); } JSON.stringify(${JXA_RECORD_PROPS}); `; const result = executor.run(script); return JSON.parse(result.stdout); }, });